From 8823118dc9c378f632bafe5ffe1c3283eddc0a91 Mon Sep 17 00:00:00 2001 From: Konstantin Ryabitsev Date: Mon, 27 Jul 2020 10:02:13 -0400 Subject: Support mbox -m to be a maildir It's a simple if/else to support maildirs for local operations, so let's handle mbox -m to be a maildir. Signed-off-by: Konstantin Ryabitsev --- b4/mbox.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/b4/mbox.py b/b4/mbox.py index 2391405..fb82389 100644 --- a/b4/mbox.py +++ b/b4/mbox.py @@ -35,7 +35,10 @@ def mbox_to_am(mboxfile, cmdargs): wantver = cmdargs.wantver wantname = cmdargs.wantname covertrailers = cmdargs.covertrailers - mbx = mailbox.mbox(mboxfile) + if os.path.isdir(mboxfile): + mbx = mailbox.Maildir(mboxfile) + else: + mbx = mailbox.mbox(mboxfile) count = len(mbx) logger.info('Analyzing %s messages in the thread', count) lmbx = b4.LoreMailbox() @@ -340,7 +343,11 @@ def am_mbox_to_quilt(am_mbx, q_dirname): def get_extra_series(mboxfile, direction=1, wantvers=None, nocache=False): # Open the mbox and find the latest series mentioned in it - mbx = mailbox.mbox(mboxfile) + if os.path.isdir(mboxfile): + mbx = mailbox.Maildir(mboxfile) + else: + mbx = mailbox.mbox(mboxfile) + base_msg = None latest_revision = None seen_msgids = list() @@ -512,6 +519,7 @@ def main(cmdargs): if cmdargs.wantname: savefile = os.path.join(cmdargs.outdir, cmdargs.wantname) else: + msgid = b4.get_msgid(cmdargs) savefile = os.path.join(cmdargs.outdir, '%s.mbx' % msgid) shutil.copy(threadmbox, savefile) -- cgit v1.2.3