[Tutor] Parsing the contents of an email message.
Jorge Godoy
godoy at ieee.org
Wed Apr 21 14:22:59 EDT 2004
Hi!
I'm working with a CVS project where I'll need to get some information from
the report it does via an email message.
I've been reading the "Global Module
Index" (http://www.python.org/doc/current/modindex.html) looking for tools
to parse the body of such a message.
I'm planning on having such messages delivered locally to a file, so I can
use some method to make that file the message, without having to setup a
POP/IMAP server.
Is email.Parser the best module for such a task?
One example of such a kind of message:
-------------------------------------------------------------------------------
Return-Path: <godoy at g2ctech.com>
X-Original-To: godoy at godoy.homeip.net
Delivered-To: godoy at godoy.homeip.net
Received: by wintermute.g2ctech (Postfix, from userid 500)
id CC3F44FDF4; Tue, 20 Apr 2004 14:22:03 -0300 (BRT)
MIME-Version: 1.0
To: godoy at godoy.homeip.net
Subject: Imported Sources
X-Mailer: activitymail 1.19, http://search.cpan.org/dist/activitymail/
Content-Type: multipart/mixed;
boundary="t79lL2nSPjcLg"
Message-Id: <20040420172203.CC3F44FDF4 at wintermute.g2ctech>
Date: Tue, 20 Apr 2004 14:22:03 -0300 (BRT)
From: godoy at g2ctech.com (Jorge Luiz Godoy Filho)
X-Bogosity: No, tests=bogofilter, spamicity=0.000000, version=0.17.0
X-UID: 48164
Update of /home/cvs/clientes/dataprev/teste/tempo
In directory wintermute.g2ctech:/tmp/cvs-serv19067
Log Message:
Teste Dataprev
Status:
Vendor Tag: godoy
Release Tags: start
N clientes/dataprev/teste/tempo/a.ppt
N clientes/dataprev/teste/tempo/b.doc
No conflicts created by this import
-------------------------------------------------------------------------------
Another kind of message is the one generated by commits, where there are
attachments (that I'm not interested in and I want to discard for the task
I'm working on):
-------------------------------------------------------------------------------
Return-Path: <godoy at g2ctech.com>
X-Original-To: godoy at godoy.homeip.net
Delivered-To: godoy at godoy.homeip.net
Received: by wintermute.g2ctech (Postfix, from userid 500)
id 65A744FF89; Tue, 20 Apr 2004 14:07:17 -0300 (BRT)
MIME-Version: 1.0
To: godoy at godoy.homeip.net
Subject: Teste.
X-Mailer: activitymail 1.19, http://search.cpan.org/dist/activitymail/
Content-Type: multipart/mixed;
boundary="iT.nVIPzX.7a."
Message-Id: <20040420170717.65A744FF89 at wintermute.g2ctech>
Date: Tue, 20 Apr 2004 14:07:17 -0300 (BRT)
From: godoy at g2ctech.com (Jorge Luiz Godoy Filho)
X-Bogosity: No, tests=bogofilter, spamicity=0.000000, version=0.17.0
X-UID: 48163
Status: RO
X-Status: OR
X-KMail-EncryptionState: N
X-KMail-SignatureState: N
X-KMail-MDN-Sent:
--iT.nVIPzX.7a.
Content-Type: text/plain
Log Message:
-----------
Teste.
Modified Files:
--------------
clientes/dataprev/teste:
teste.comum
clientes/dataprev/teste/tempo:
a.ppt
b.doc
--iT.nVIPzX.7a.
Content-Disposition: attachment; filename=godoy-200442017717-diff.txt
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset=ISO-8859-1
Index: teste.comum
===================================================================
RCS file: /home/cvs/clientes/dataprev/teste/teste.comum,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -Ldataprev/teste/teste.comum -Ldataprev/teste/teste.comum -u -r1.1.1.1
-r1.2
--- dataprev/teste/teste.comum
+++ dataprev/teste/teste.comum
@@ -0,0 +1 @@
+teste
Index: b.doc
===================================================================
RCS file: /home/cvs/clientes/dataprev/teste/tempo/b.doc,v
retrieving revision 1.2
retrieving revision 1.3
diff -Ldataprev/teste/tempo/b.doc -Ldataprev/teste/tempo/b.doc -u -r1.2
-r1.3
--- dataprev/teste/tempo/b.doc
+++ dataprev/teste/tempo/b.doc
@@ -1 +1 @@
-b
+bb
Index: a.ppt
===================================================================
RCS file: /home/cvs/clientes/dataprev/teste/tempo/a.ppt,v
retrieving revision 1.3
retrieving revision 1.4
diff -Ldataprev/teste/tempo/a.ppt -Ldataprev/teste/tempo/a.ppt -u -r1.3
-r1.4
--- dataprev/teste/tempo/a.ppt
+++ dataprev/teste/tempo/a.ppt
@@ -1 +1 @@
-aa
+a
--iT.nVIPzX.7a.--
-------------------------------------------------------------------------------
Thanks in advance,
--
Godoy. <godoy at ieee.org>
More information about the Tutor
mailing list