'Parse an RFC 2822 addr-spec.'

def getaddrspec(self):

    aslist = []
    self.gotonext()
    while (self.pos < len(self.field)):
        if (self.field[self.pos] == '.'):
            aslist.append('.')
            self.pos += 1
        elif (self.field[self.pos] == '"'):
            aslist.append(('"%s"' % self.getquote()))
        elif (self.field[self.pos] in self.atomends):
            break
        else:
            aslist.append(self.getatom())
        self.gotonext()
    if ((self.pos >= len(self.field)) or (self.field[self.pos] != '@')):
        return ''.join(aslist)
    aslist.append('@')
    self.pos += 1
    self.gotonext()
    return (''.join(aslist) + self.getdomain())
