summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorPatrick Maia <patrickjourdanmaia@gmail.com>2014-08-14 14:24:03 -0300
committerPatrick Maia <patrickjourdanmaia@gmail.com>2014-08-14 14:24:03 -0300
commita864a01a9883db7eb2f84e616a5f294ec2193bfb (patch)
tree9b082c24b5d114f6a388584633dc5f91c8f09f18 /service
parent8687f923ec5f159970276d56b19183b2219827bd (diff)
Clean up MailService class
Diffstat (limited to 'service')
-rw-r--r--service/app/adapter/mail_service.py55
1 files changed, 5 insertions, 50 deletions
diff --git a/service/app/adapter/mail_service.py b/service/app/adapter/mail_service.py
index 1025bce8..32238973 100644
--- a/service/app/adapter/mail_service.py
+++ b/service/app/adapter/mail_service.py
@@ -8,29 +8,8 @@ from app.bitmask_libraries.auth import LeapCredentials
from app.adapter.pixelated_mail import PixelatedMail
from app.tags import Tags
-import logging
-
-logging.basicConfig(level=logging.DEBUG,
- format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
- datefmt='%m-%d %H:%M',
- filename='/tmp/leap.log',
- filemode='w')
-
-# define a Handler which writes INFO messages or higher to the sys.stderr
-console = logging.StreamHandler()
-console.setLevel(logging.DEBUG)
-# set a format which is simpler for console use
-formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s')
-# tell the handler to use this format
-console.setFormatter(formatter)
-# add the handler to the root logger
-logging.getLogger('').addHandler(console)
-
-
class MailService:
- SPECIAL_BOXES = ['inbox', 'sent', 'drafts', 'trash']
-
def __init__(self):
try:
self.username = 'testuser_a003'
@@ -64,34 +43,14 @@ class MailService:
for tag in tags:
self.tags.add(tag)
- def _switch_mailbox(self, name):
- mailbox = None
- if name in self.SPECIAL_BOXES:
- self._create_mailbox(name)
- try:
- mailbox = self.account.getMailbox(name)
- except Exception, e:
- if not 'MailboxException' == e.__class__.__name__:
- raise e
- return mailbox
-
- def _create_mailbox(self, name):
- created = False
- try:
- created = self.account.addMailbox(name)
- except Exception, e:
- if not 'MailboxCollision' == e.__class__.__name__:
- raise e
- return created
-
- def drafts(self):
- return []
-
def mail(self, mail_id):
for message in self.mailbox.messages:
if message.getUID() == int(mail_id):
return PixelatedMail(message)
+ def all_tags(self):
+ return self.tags
+
def thread(self, thread_id):
raise NotImplementedError()
@@ -119,12 +78,8 @@ class MailService:
def draft_reply_for(self, mail_id):
raise NotImplementedError()
- def all_tags(self):
- return self.tags
-
def all_contacts(self, query):
raise NotImplementedError()
-if __name__ == '__main__':
- print('Running Standalone')
- client = Client()
+ def drafts(self):
+ raise NotImplementedError()