Josh VanderLinden avatar Josh VanderLinden committed f9eed4c

Fixed some problems with articles from email. Version bump.

Comments (0)

Files changed (2)


-__version__ = '2.0.0-pre1'
+__version__ = '2.0.0-pre2'
 The Pygments reStructuredText directive


 MB_POP3 = 'POP3'
+ACCEPTABLE_TYPES = ('text/plain', 'text/html')
 class MailboxHandler(object):
         if email.is_multipart():
             self.log('Extracting email contents from multipart message')
-            for pl in email.get_payload():
-                if pl.get_content_type() in ('text/plain', 'text/html') and pl.get_filename() is None:
+            magic_type = 'multipart/alternative'
+            payload_types = dict((p.get_content_type(), i) for i, p in enumerate(email.get_payload()))
+            if magic_type in payload_types.keys():
+                self.log('Found magic content type: %s' % magic_type)
+                index = payload_types[magic_type]
+                payload = email.get_payload()[index].get_payload()
+            else:
+                payload = email.get_payload()
+            for pl in payload:
+                print pl.get_filename(), pl.get_content_type()
+                if pl.get_filename() is not None:
+                    # it's an attached file
+                    continue
+                if pl.get_content_type() in ACCEPTABLE_TYPES:
                     return pl.get_payload()
             return email.get_payload()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.