| 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 | |
| 657 | class DomainLiteral(TokenList): |