From 167e914055ca2e10e7865044965c40cc4d8f4c43 Mon Sep 17 00:00:00 2001 From: scrat Date: Sun, 4 May 2008 21:26:57 +0000 Subject: [PATCH] changed outlook.py: now much more data from the outlook mails is available. Now we also can access the date the mail was sent as well when it has been received. Also data about the attachements is now available (if desired). Minor change to winapi was necessary in order to support the doctests with the changed outlook api. _prop_map_get now returns a dictionary instead of a tuple. git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@2577 fd906abe-77d9-0310-91a1-e0d9ade77398 --- agent/crawl/outlook.py | 16 +++++++++------- agent/testing/winapi.py | 7 +++++-- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/agent/crawl/outlook.py b/agent/crawl/outlook.py index 57f605b..95086ea 100644 --- a/agent/crawl/outlook.py +++ b/agent/crawl/outlook.py @@ -110,19 +110,21 @@ class OutlookCrawler(MailCrawler): if mail.Class == api.client.constants.olMail: if self.keys is None: self.keys = [] - for key in mail._prop_map_get_: + for key in mail._prop_map_get_.items(): try: - if isinstance(getattr(mail, key), (int, str, unicode)): - self.keys.append(key) + if isinstance(key[0], (int, str, unicode, bool)): + self.keys.append(key[0]) except api.com_error: pass record = {} for key in self.keys: try: - if isinstance(getattr(mail, key), (int, str, unicode, bool)): - record[key] = getattr(mail, key) - else: - record[key] = "Invalid data format" + if (hasattr(mail, key)): + value = getattr(mail, key) + if isinstance(value, (int, str, unicode, bool)): + record[key] = value + else: + record[key] = "Invalid data format" except: record[key] = "Requested attribute not available" # Create the mime email object diff --git a/agent/testing/winapi.py b/agent/testing/winapi.py index d44b947..51eeb92 100644 --- a/agent/testing/winapi.py +++ b/agent/testing/winapi.py @@ -45,8 +45,11 @@ class Mail(object): def _prop_map_get_(self): #here it is necessary of what attributes (called keys in outlok.py) #an Outlook Mail typically has - # should return a tuple () - return ('Subject', 'SenderName', 'To', 'Body') + return {'Subject': "Testsubject",\ + 'SenderName': "TestSender",\ + 'To': "TestRecipient",\ + 'Body': "TestBody" + } class Items(object):