Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #77354 > unrolled thread

Distinguishing between maildir, mbox, and MH files/directories?

Started byTim Chase <python.list@tim.thechases.com>
First post2014-08-31 13:45 -0500
Last post2014-08-31 13:45 -0500
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

  Distinguishing between maildir, mbox, and MH files/directories? Tim Chase <python.list@tim.thechases.com> - 2014-08-31 13:45 -0500

#77354 — Distinguishing between maildir, mbox, and MH files/directories?

FromTim Chase <python.list@tim.thechases.com>
Date2014-08-31 13:45 -0500
SubjectDistinguishing between maildir, mbox, and MH files/directories?
Message-ID<mailman.13663.1409510831.18130.python-list@python.org>
Tinkering around with a little script, I found myself with the need
to walk a directory tree and process mail messaged found within.
Sometimes these end up being mbox files (with multiple messages
within), sometimes it's a Maildir structure with messages in each
individual file and extra holding directories, and sometimes it's a
MH directory.  To complicate matters, there's also the possibility of
non-{mbox,maildir,mh) files such as binary MUA caches appearing
alongside these messages.

Python knows how to handle each just fine as long as I tell it what
type of file to expect.  But is there a straight-forward way to
distinguish them?  (FWIW, the *nix "file" utility is just reporting
"ASCII text", sometimes "with very long lines", and sometimes
erroneously flags them as C or C++ files‽).

All I need is "is it maildir, mbox, mh, or something else" (I don't
have to get more complex for the "something else") inside an os.walk
loop.

Thanks for any suggestions,

-tkc


[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web