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)
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)
def fetch(url=None): if not url: url = config.get_fetch_url() if not url: raise Exception('URL not specified in config file and missing on command line') try: os.makedirs(config.get_mbox_path()) except Exception, e: pass
def fetch(url=None): if not url: url = config.get_fetch_url() if not url: raise Exception( 'URL not specified in config file and missing on command line') try: os.makedirs(config.get_mbox_path()) except Exception, e: pass
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)
def setup_mboxes(): try: os.makedirs(config.get_mbox_path()) except Exception, e: pass
def get_real_path(mbox_path): return "%s/%s" % (config.get_mbox_path(), mbox_path[len(config.get_mbox_prefix()) :])
def get_real_path(mbox_path): return '%s/%s' % (config.get_mbox_path(), mbox_path[len(config.get_mbox_prefix()):])