Rev 185: Decoupled specialised parsing of emails from the source of the message. in http://bzr.daniel-watkins.co.uk/pqm/xmlrpc

Daniel Watkins daniel at daniel-watkins.co.uk
Thu Jul 31 06:24:12 BST 2008


At http://bzr.daniel-watkins.co.uk/pqm/xmlrpc

------------------------------------------------------------
revno: 185
revision-id: daniel at daniel-watkins.co.uk-20080731052236-hb54tzzzz2qvilbf
parent: daniel at daniel-watkins.co.uk-20080731045139-e7n0qj99fztq4wye
committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
branch nick: xmlrpc
timestamp: Thu 2008-07-31 06:22:36 +0100
message:
  Decoupled specialised parsing of emails from the source of the message.
-------------- next part --------------
=== modified file 'pqm/script.py'
--- a/pqm/script.py	2008-07-31 04:51:39 +0000
+++ b/pqm/script.py	2008-07-31 05:22:36 +0000
@@ -36,11 +36,8 @@
 from pqm.errors import PQMCmdFailure, PQMException, PQMTlaFailure
 
 
-def read_email(logger, file=None):
+def get_email_structure(logger, msg):
     """Read an email and check it has the required structure for commands."""
-    if not file:
-        file = sys.stdin
-    msg = email.message_from_file(file)
     sender = msg['From']
     logger.info("recieved email from %s", sender)
     subject = msg['Subject']
@@ -72,6 +69,13 @@
         return (sender, subject, msg.get_payload(), None)
 
 
+def read_email(logger, file=None):
+    if not file:
+        file = sys.stdin
+    msg = email.message_from_file(file)
+    return get_email_structure(logger, msg)
+
+
 def get_email_string(logger, options, file=None):
     (sender, subject, msg, sig) = read_email(logger, file)
     if options.verify_sigs:



More information about the bazaar-commits mailing list