Ejemplo n.º 1
0
Archivo: mail.py Proyecto: snits/stgit
def __update_header(msg, header, addr = '', ignore = ()):
    addr_pairs = email.utils.getaddresses(msg.get_all(header, []) + [addr])
    del msg[header]
    # remove pairs without an address and resolve the aliases
    addr_pairs = [address_or_alias(name_addr) for name_addr in addr_pairs
                  if name_addr[1]]
    # remove the duplicates and filter the addresses
    addr_pairs = [name_addr for name_addr in addr_pairs
                  if name_addr[1] not in ignore]
    if addr_pairs:
        msg[header] = ', '.join(map(email.utils.formataddr, addr_pairs))
    return set(addr for _, addr in addr_pairs)
Ejemplo n.º 2
0
def __update_header(msg, header, addr='', ignore=()):
    addr_pairs = email.utils.getaddresses(msg.get_all(header, []) + [addr])
    del msg[header]
    # remove pairs without an address and resolve the aliases
    addr_pairs = [
        address_or_alias(name_addr) for name_addr in addr_pairs if name_addr[1]
    ]
    # remove the duplicates and filter the addresses
    addr_pairs = [name_addr for name_addr in addr_pairs if name_addr[1] not in ignore]
    if addr_pairs:
        msg[header] = ', '.join(map(email.utils.formataddr, addr_pairs))
    return set(addr for _, addr in addr_pairs)
Ejemplo n.º 3
0
def __get_sender():
    """Return the 'authname <authemail>' string as read from the
    configuration file
    """
    sender = config.get('stgit.sender')
    if not sender:
        try:
            sender = text(git.user())
        except git.GitException:
            try:
                sender = text(git.author())
            except git.GitException:
                pass
    if not sender:
        raise CmdException('Unknown sender name and e-mail; you should for '
                           'example set git config user.name and user.email')
    sender = email.utils.parseaddr(sender)

    return email.utils.formataddr(address_or_alias(sender))
Ejemplo n.º 4
0
Archivo: mail.py Proyecto: snits/stgit
def __get_sender():
    """Return the 'authname <authemail>' string as read from the
    configuration file
    """
    sender = config.get('stgit.sender')
    if not sender:
        try:
            sender = git.user()
        except git.GitException:
            try:
                sender = git.author()
            except git.GitException:
                pass
    if not sender:
        raise CmdException('Unknown sender name and e-mail; you should for '
                           'example set git config user.name and user.email')
    sender = email.utils.parseaddr(sender)

    return email.utils.formataddr(address_or_alias(sender))
Ejemplo n.º 5
0
def __get_sender():
    """Return the 'authname <authemail>' string as read from the
    configuration file
    """
    sender = config.get('stgit.sender')
    if not sender:
        user = Person.user()
        if user.email:
            sender = user.name_email
        else:
            author = Person.author()
            if author.email:
                sender = author.name_email
            else:
                raise CmdException(
                    'Unknown sender name and e-mail; you should for '
                    'example set git config user.name and user.email')

    sender = email.utils.parseaddr(sender)

    return email.utils.formataddr(address_or_alias(sender))