From: W. Trevor King Date: Sun, 2 Sep 2012 12:38:13 +0000 (-0400) Subject: mailpipe: skip `.gitignore` files in Maildir mailboxes. X-Git-Tag: v0.3~33 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=df7f64f8a310aa531dcb57134dcf746fb82c2920;p=pygrader.git 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. --- 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: