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


Groups > comp.lang.python > #63610

Is email.parser a good replacement for formail?

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder7.xlned.com!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <mcepl@redhat.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.059
X-Spam-Evidence '*H*': 0.88; '*S*': 0.00; 'messages.': 0.05; 'msg': 0.09; 'skip:/ 10': 0.09; 'url:github': 0.09; 'filename:fname piece:signature': 0.16; 'formatted': 0.16; 'gpg': 0.16; 'jabber:': 0.16; 'resist': 0.16; ':-)': 0.16; 'fix': 0.17; 'tests': 0.22; 'install': 0.23; 'header:User-Agent:1': 0.23; 'skip:e 30': 0.24; '(or': 0.24; 'script': 0.25; 'possibly': 0.26; 'installed': 0.27; 'correct': 0.29; 'fixed': 0.29; 'skip:p 30': 0.29; 'etc.).': 0.31; 'purely': 0.31; 'url:cz': 0.31; 'run': 0.32; 'anybody': 0.35; 'test': 0.35; 'but': 0.35; 'thanks': 0.36; 'subject:?': 0.36; 'hi,': 0.36; 'received:209': 0.37; 'received:10': 0.37; 'to:addr :python-list': 0.38; 'does': 0.39; '(from': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'read': 0.60; 'is.': 0.60; 'from:charset:utf-8': 0.61; 'more': 0.64; 'actually,': 0.84; 'apt-get': 0.84; 'fortunes': 0.84; 'received:10.36': 0.84; 'subject:good': 0.84; 'poorly': 0.93; 'reply,': 0.93
Date Thu, 09 Jan 2014 17:05:55 +0100
From Matěj Cepl <mcepl@redhat.com>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:28.0) Gecko/20100101 Thunderbird/28.0a2
MIME-Version 1.0
To python-list@python.org
Subject Is email.parser a good replacement for formail?
X-Enigmail-Version 1.6
Content-Type multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="jEeRvShAqx9LoDL4Jil72TrqB6u3PF394"
X-Scanned-By MIMEDefang 2.68 on 10.5.11.24
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.5267.1389283565.18130.python-list@python.org> (permalink)
Lines 56
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1389283566 news.xs4all.nl 2830 [2001:888:2000:d::a6]:58747
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:63610

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

Hi,



I have a script (https://github.com/mcepl/gg_scraper) where I need to
read possibly malformed mbox messages. I use subprocess.Popen() and
/usr/bin/formail to clean up them to be correct mbox messages (with
correct leading From line etc.). Now I try to run tests for my script on
Travis-CI, where I don't have installed formail. Actually, I learned now
that I can run apt-get install procmail in .travis.yml. But still, I
started to think whether I couldn’t fix my script to be purely Pythonic.
I know that

    msg = email.message_from_string(original_msg)
    print(msg.as_string(unixfrom=True))

works as a poor-man’s replacement for `formail -d`. Now, I would like to
know how reliable replacement it is. Does anybody have (or know about) a
corpus of poorly formatted messages which can be fixed by formail to
test upon it?

Thanks a lot for any reply,

Matěj

-- 
http://www.ceplovi.cz/matej/, Jabber: mcepl@ceplovi.cz
GPG Finger: 89EF 4BC6 288A BF43 1BAB  25C3 E09F EF25 D964 84AC

Less is more or less more.
   -- Y_Plentyn on #LinuxGER
      (from fortunes -- I cannot resist :-)

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Is email.parser a good replacement for formail? Matěj Cepl <mcepl@redhat.com> - 2014-01-09 17:05 +0100

csiph-web