(self)
return EMPTYSTRING.join(aslist) + domain
Parse an RFC 2822 addr-spec.
Parse an RFC 2822 addr-spec.
Parse an RFC 2822 addr - spec .
def getaddrspec(self):
        """Parse an RFC 2822 addr-spec."""
        aslist = []

        self.gotonext()
        while self.pos < len(self.field):
            preserve_ws = True
            if self.field[self.pos] == '.':
                if aslist and not aslist[-1].strip():
                    aslist.pop()
                aslist.append('.')
                self.pos += 1
                preserve_ws = False
            elif self.field[self.pos] == '"':
                aslist.append('"%s"' % quote(self.getquote()))
            elif self.field[self.pos] in self.atomends:
                if aslist and not aslist[-1].strip():
                    aslist.pop()
                break
            else:
                aslist.append(self.getatom())
            ws = self.gotonext()
            if preserve_ws and ws:
                aslist.append(ws)

        if self.pos >= len(self.field) or self.field[self.pos] != '@':
            return EMPTYSTRING.join(aslist)

        aslist.append('@')
        self.pos += 1
        self.gotonext()
        domain = self.getdomain()
        if not domain:
            # Invalid domain, return an empty address instead of returning a
            # local part to denote failed parsing.
            return EMPTYSTRING
        return EMPTYSTRING.join(aslist) + domain
def getaddrspec ( self ) : aslist = [ ] self . gotonext ( ) while self . pos < len ( self . field ) : preserve_ws = True if self . field [ self . pos ] == '.' : if aslist and not aslist [ - 1 ] . strip ( ) : aslist . pop ( ) aslist . append ( '.' ) self . pos += 1 preserve_ws = False elif self . field [ self . pos ] == '"' : aslist . append ( '"%s"' % quote ( self . getquote ( ) ) ) elif self . field [ self . pos ] in self . atomends : if aslist and not aslist [ - 1 ] . strip ( ) : aslist . pop ( ) break else : aslist . append ( self . getatom ( ) ) ws = self . gotonext ( ) if preserve_ws and ws : aslist . append ( ws ) if self . pos >= len ( self . field ) or self . field [ self . pos ] != '@' : return EMPTYSTRING . join ( aslist ) aslist . append ( '@' ) self . pos += 1 self . gotonext ( ) domain = self . getdomain ( ) if not domain : # Invalid domain, return an empty address instead of returning a # local part to denote failed parsing. return EMPTYSTRING return EMPTYSTRING . join ( aslist ) + domain