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

Class LocalPart

Lib/email/_header_value_parser.py:621–654  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

619
620
621class LocalPart(TokenList):
622
623 token_type = 'local-part'
624 as_ew_allowed = False
625
626 @property
627 def value(self):
628 if self[0].token_type == "quoted-string":
629 return self[0].quoted_value
630 else:
631 return self[0].value
632
633 @property
634 def local_part(self):
635 # Strip whitespace from front, back, and around dots.
636 res = [DOT]
637 last = DOT
638 last_is_tl = False
639 for tok in self[0] + [DOT]:
640 if tok.token_type == 'cfws':
641 continue
642 if (last_is_tl and tok.token_type == 'dot' and
643 last[-1].token_type == 'cfws'):
644 res[-1] = TokenList(last[:-1])
645 is_tl = isinstance(tok, TokenList)
646 if (is_tl and last.token_type == 'dot' and
647 tok[0].token_type == 'cfws'):
648 res.append(TokenList(tok[1:]))
649 else:
650 res.append(tok)
651 last = res[-1]
652 last_is_tl = is_tl
653 res = TokenList(res[1:-1])
654 return res.value
655
656
657class DomainLiteral(TokenList):

Callers 1

get_local_partFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…