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

Function get_mailbox

Lib/email/_header_value_parser.py:1833–1852  ·  view source on GitHub ↗

mailbox = name-addr / addr-spec

(value)

Source from the content-addressed store, hash-verified

1831 return name_addr, value
1832
1833def get_mailbox(value):
1834 """ mailbox = name-addr / addr-spec
1835
1836 """
1837 # The only way to figure out if we are dealing with a name-addr or an
1838 # addr-spec is to try parsing each one.
1839 mailbox = Mailbox()
1840 try:
1841 token, value = get_name_addr(value)
1842 except errors.HeaderParseError:
1843 try:
1844 token, value = get_addr_spec(value)
1845 except errors.HeaderParseError:
1846 raise errors.HeaderParseError(
1847 "expected mailbox but found '{}'".format(value))
1848 if any(isinstance(x, errors.InvalidHeaderDefect)
1849 for x in token.all_defects):
1850 mailbox.token_type = 'invalid-mailbox'
1851 mailbox.append(token)
1852 return mailbox, value
1853
1854def get_invalid_mailbox(value, endchars):
1855 """ Read everything up to one of the chars in endchars.

Callers 2

get_mailbox_listFunction · 0.85
get_addressFunction · 0.85

Calls 6

get_name_addrFunction · 0.85
get_addr_specFunction · 0.85
MailboxClass · 0.70
anyFunction · 0.50
formatMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…