Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #77354 > unrolled thread
| Started by | Tim Chase <python.list@tim.thechases.com> |
|---|---|
| First post | 2014-08-31 13:45 -0500 |
| Last post | 2014-08-31 13:45 -0500 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
Distinguishing between maildir, mbox, and MH files/directories? Tim Chase <python.list@tim.thechases.com> - 2014-08-31 13:45 -0500
| From | Tim Chase <python.list@tim.thechases.com> |
|---|---|
| Date | 2014-08-31 13:45 -0500 |
| Subject | Distinguishing 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
Back to top | Article view | comp.lang.python
csiph-web