Exemplo n.º 1
0
def generate_mbox(messages, full_tags):
    mbox_dir = config.get_mbox_path()
    mid = escape_message_id(messages[0][0].get_message_id())

    tmp_mbox_path = "%s/tmp-%s" % (mbox_dir, mid)
    mbox_path = "%s/mbox-%s" % (mbox_dir, mid)

    mbox = mailbox.mbox(tmp_mbox_path, create=True)
    for message, tags in messages:
        new_payload = add_tags(message, merge_tags(full_tags, tags))

        msg = message.get_message_parts()[0]

        # Drop content transfer encoding so msg.set_payload() will re-encode
        if "content-transfer-encoding" in msg:
            del msg["content-transfer-encoding"]

        # Change charset to UTF-8 to guarantee that we can represent all
        # characters.  Think about the case where the patch email was ASCII and
        # a reviewer with a non-ASCII name replied with a Reviewed-by tag, now
        # the patch can no longer be represented by ASCII.
        msg.set_payload(new_payload.encode("utf-8"), "utf-8")
        mbox.add(msg)
    mbox.flush()
    mbox.close()

    os.rename(tmp_mbox_path, mbox_path)

    return config.get_mbox_prefix() + ("mbox-%s" % mid)
Exemplo n.º 2
0
def generate_mbox(messages, full_tags):
    mbox_dir = config.get_mbox_path()
    mid = escape_message_id(messages[0][0].get_message_id())

    tmp_mbox_path = '%s/tmp-%s' % (mbox_dir, mid)
    mbox_path = '%s/mbox-%s' % (mbox_dir, mid)

    mbox = mailbox.mbox(tmp_mbox_path, create=True)
    for message, tags in messages:
        new_payload = add_tags(message, merge_tags(full_tags, tags))

        msg = message.get_message_parts()[0]

        # Drop content transfer encoding so msg.set_payload() will re-encode
        if 'content-transfer-encoding' in msg:
            del msg['content-transfer-encoding']

        # Change charset to UTF-8 to guarantee that we can represent all
        # characters.  Think about the case where the patch email was ASCII and
        # a reviewer with a non-ASCII name replied with a Reviewed-by tag, now
        # the patch can no longer be represented by ASCII.
        msg.set_payload(new_payload.encode('utf-8'), 'utf-8')
        mbox.add(msg)
    mbox.flush()
    mbox.close()

    os.rename(tmp_mbox_path, mbox_path)

    return config.get_mbox_prefix() + ('mbox-%s' % mid)
Exemplo n.º 3
0
def generate_mbox(messages, full_tags):
    mbox_dir = config.get_mbox_path()
    mid = messages[0][0].get_message_id()

    tmp_mbox_path = '%s/tmp-%s' % (mbox_dir, mid)
    mbox_path = '%s/mbox-%s' % (mbox_dir, mid)

    mbox = mailbox.mbox(tmp_mbox_path, create=True)
    for message, tags in messages:
        msg = message.get_message_parts()[0]
        msg.set_payload(add_tags(msg, merge_tags(full_tags, tags)))
        mbox.add(msg)
    mbox.flush()
    mbox.close()

    os.rename(tmp_mbox_path, mbox_path)

    return config.get_mbox_prefix() + ('mbox-%s' % mid)
Exemplo n.º 4
0
def get_real_path(mbox_path):
    return "%s/%s" % (config.get_mbox_path(), mbox_path[len(config.get_mbox_prefix()) :])
Exemplo n.º 5
0
def get_real_path(mbox_path):
    return '%s/%s' % (config.get_mbox_path(),
                      mbox_path[len(config.get_mbox_prefix()):])