MCPcopy Index your code
hub / github.com/python/cpython / parse

Method parse

Lib/email/headerregistry.py:336–361  ·  view source on GitHub ↗
(cls, value, kwds)

Source from the content-addressed store, hash-verified

334
335 @classmethod
336 def parse(cls, value, kwds):
337 if isinstance(value, str):
338 # We are translating here from the RFC language (address/mailbox)
339 # to our API language (group/address).
340 kwds['parse_tree'] = address_list = cls.value_parser(value)
341 groups = []
342 for addr in address_list.addresses:
343 groups.append(Group(addr.display_name,
344 [Address(mb.display_name or '',
345 mb.local_part or '',
346 mb.domain or '')
347 for mb in addr.all_mailboxes]))
348 defects = list(address_list.all_defects)
349 else:
350 # Assume it is Address/Group stuff
351 if not hasattr(value, '__iter__'):
352 value = [value]
353 groups = [Group(None, [item]) if not hasattr(item, 'addresses')
354 else item
355 for item in value]
356 defects = []
357 kwds['groups'] = groups
358 kwds['defects'] = defects
359 kwds['decoded'] = ', '.join([str(item) for item in groups])
360 if 'parse_tree' not in kwds:
361 kwds['parse_tree'] = cls.value_parser(kwds['decoded'])
362
363 def init(self, *args, **kw):
364 self._groups = tuple(kw.pop('groups'))

Callers

nothing calls this directly

Calls 7

listClass · 0.85
strFunction · 0.85
value_parserMethod · 0.80
GroupClass · 0.70
AddressClass · 0.70
appendMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected