From df7f64f8a310aa531dcb57134dcf746fb82c2920 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sun, 2 Sep 2012 08:38:13 -0400 Subject: [PATCH] mailpipe: skip `.gitignore` files in Maildir mailboxes. I use empty `.gitignore` files so Git will create the `test/mail-in/new` and `test/mail-in/tmp` directories on checkout, but the Maildir mailbox thinks they are messages. Since the files are *not* messages, skip them when constucting the Maildir message list. I don't foresee any side effects from this (it's an odd filename for real Maildir delivery), but I log the skipped filenames just in case. --- pygrader/mailpipe.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pygrader/mailpipe.py b/pygrader/mailpipe.py index 6a42eae..b254273 100644 --- a/pygrader/mailpipe.py +++ b/pygrader/mailpipe.py @@ -621,7 +621,13 @@ def _load_messages(course, stream, mailbox=None, input_=None, output=None, ombox = _mailbox.mbox(output, factory=None, create=True) elif mailbox == 'maildir': mbox = _mailbox.Maildir(input_, factory=None, create=False) - messages = mbox.items() + messages = [] + for key,msg in mbox.items(): + subpath = mbox._lookup(key) + if subpath.endswith('.gitignore'): + _LOG.debug('skipping non-message {}'.format(subpath)) + continue + messages.append((key, msg)) if output is not None: ombox = _mailbox.Maildir(output, factory=None, create=True) else: -- 2.26.2