Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ tmtags

## Test Account details
spec/account.yml
dist
*.egg-info
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include README.md
26 changes: 18 additions & 8 deletions gmail/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ def __init__(self, mailbox, uid):
self.thread_id = None
self.thread = []
self.message_id = None

self.attachments = None



def is_read(self):
Expand Down Expand Up @@ -166,13 +166,23 @@ def parse(self, raw_message):
if re.search(r'X-GM-MSGID (\d+)', raw_headers):
self.message_id = re.search(r'X-GM-MSGID (\d+)', raw_headers).groups(1)[0]


# Parse attachments into attachment objects array for this message
self.attachments = [
Attachment(attachment) for attachment in self.message._payload
if not isinstance(attachment, basestring) and attachment.get('Content-Disposition') is not None
]

self.attachments = []
def make_attachement(attachments):
for attachment in attachments:
if isinstance(attachment, basestring):
continue
if attachment.get_content_type() == 'message/rfc822':
make_attachement(attachment.get_payload())
else:
if not attachment.is_multipart():
self.attachments.append(Attachment(attachment))
else:
make_attachement(attachment.get_payload())

make_attachement(self.message.get_payload())


def fetch(self):
if not self.message:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def read(fname):

setup(
name = "gmail",
version = "0.0.5",
version = "0.0.7",
author = "Charlie Guo",
author_email = "FIXME",
description = ("A Pythonic interface for Google Mail."),
Expand Down