MCPcopy Index your code
hub / github.com/RustPython/RustPython / get_mailbox

Function get_mailbox

Lib/email/_header_value_parser.py:1816–1835  ·  view source on GitHub ↗

mailbox = name-addr / addr-spec

(value)

Source from the content-addressed store, hash-verified

1814 return name_addr, value
1815
1816def get_mailbox(value):
1817 """ mailbox = name-addr / addr-spec
1818
1819 """
1820 # The only way to figure out if we are dealing with a name-addr or an
1821 # addr-spec is to try parsing each one.
1822 mailbox = Mailbox()
1823 try:
1824 token, value = get_name_addr(value)
1825 except errors.HeaderParseError:
1826 try:
1827 token, value = get_addr_spec(value)
1828 except errors.HeaderParseError:
1829 raise errors.HeaderParseError(
1830 "expected mailbox but found '{}'".format(value))
1831 if any(isinstance(x, errors.InvalidHeaderDefect)
1832 for x in token.all_defects):
1833 mailbox.token_type = 'invalid-mailbox'
1834 mailbox.append(token)
1835 return mailbox, value
1836
1837def get_invalid_mailbox(value, endchars):
1838 """ Read everything up to one of the chars in endchars.

Callers 2

get_mailbox_listFunction · 0.85
get_addressFunction · 0.85

Calls 7

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

Tested by

no test coverage detected