Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #77354
| Date | 2014-08-31 13:45 -0500 |
|---|---|
| From | Tim Chase <python.list@tim.thechases.com> |
| Subject | Distinguishing between maildir, mbox, and MH files/directories? |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.13663.1409510831.18130.python-list@python.org> (permalink) |
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 comp.lang.python | Previous | Next | Find similar | Unroll thread
Distinguishing between maildir, mbox, and MH files/directories? Tim Chase <python.list@tim.thechases.com> - 2014-08-31 13:45 -0500
csiph-web