diff options
author | Marc Zyngier <maz@kernel.org> | 2019-11-17 17:02:27 +0000 |
---|---|---|
committer | Marc Zyngier <maz@kernel.org> | 2019-11-17 17:02:27 +0000 |
commit | 7175a595f828bbb853eec86f85701ebfa2a2b578 (patch) | |
tree | bb2796700fde9b7c89bfa628d86fd228db890cb5 | |
parent | c479b7ecea8562c56e0e9d54e7a4974ae12e288f (diff) | |
download | quilttools-lore.tar.gz |
mb2q: Fetch mbox from lorelore
Email clients suck. Some can't even export emails as an mbox.
When passing the -M option and a MessageID as instead of a filename,
mb2q will fetch the mbox containing this MessgeID and use that
as the input.
Signed-off-by: Marc Zyngier <maz@kernel.org>
-rwxr-xr-x | mb2q | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -4,6 +4,8 @@ from email.utils import make_msgid, formatdate from argparse import ArgumentParser +from gzip import GzipFile +import urllib.request import subprocess import mailbox import email.policy @@ -650,6 +652,9 @@ if __name__ == '__main__': parser.add_argument('-S', '--SortSubject', dest='sortsubject', action='store_true', help='Sort input mbox by subject') + parser.add_argument('-M', '--MessageID', dest='msgid', + action='store_true', + help='Download mbox from lore') args = parser.parse_args() try: @@ -678,6 +683,15 @@ if __name__ == '__main__': compile_tags() q = quilter(args) + + if args.msgid: + baseurl = urllib.request.urlopen('https://lore.kernel.org/r/' + args.inbox) + url = urllib.request.urlopen(baseurl.geturl() + 't.mbox') + mboxgz = GzipFile(None, 'rb', 9, url) + with open(args.inbox, "wb") as mboxfile: + mboxfile.write(mboxgz.read()) + mboxfile.close() + mbox = mailbox.mbox(args.inbox, create=False) if args.sortsubject: @@ -702,3 +716,6 @@ if __name__ == '__main__': os.makedirs(pdir) q.write_series(pdir) q.write_patches(pdir) + + if args.msgid: + os.unlink(args.inbox) |