mailbox = name-addr / addr-spec
(value)
| 1831 | return name_addr, value |
| 1832 | |
| 1833 | def 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 | |
| 1854 | def get_invalid_mailbox(value, endchars): |
| 1855 | """ Read everything up to one of the chars in endchars. |
no test coverage detected
searching dependent graphs…