diff options
author | Bruno Wagner <bwagner@thoughtworks.com> | 2014-09-15 16:28:31 -0300 |
---|---|---|
committer | Bruno Wagner <bwagner@thoughtworks.com> | 2014-09-15 16:28:31 -0300 |
commit | 5dc16a1e654e78d9b600578a0e2276cba8d94158 (patch) | |
tree | 0b12d78f54a53112e110ecf0e1bcce197f13e3ca /py-fake-service/app/adapter/mailset.py | |
parent | f2bb13595d67775e8ea89ea595cdbe8b7db96dd8 (diff) |
Moved py-fake-service to fake-service, because we only have one now
Diffstat (limited to 'py-fake-service/app/adapter/mailset.py')
-rw-r--r-- | py-fake-service/app/adapter/mailset.py | 69 |
1 files changed, 0 insertions, 69 deletions
diff --git a/py-fake-service/app/adapter/mailset.py b/py-fake-service/app/adapter/mailset.py deleted file mode 100644 index bf7e8c67..00000000 --- a/py-fake-service/app/adapter/mailset.py +++ /dev/null @@ -1,69 +0,0 @@ -# -# Copyright (c) 2014 ThoughtWorks, Inc. -# -# Pixelated is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Pixelated is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with Pixelated. If not, see <http://www.gnu.org/licenses/>. -from mail import Mail - - -class MailSet: - - def __init__(self): - self.ident = 0 - self.mails = {} - - def add(self, mbox_mail): - self.mails[self.ident] = Mail(mbox_mail, self.ident) - self.ident += 1 - - def values(self): - return self.mails.values() - - def get(self, mail_id): - return self.mails.get(mail_id) - - def mark_as_read(self, mail_id): - mail = self.get(mail_id) - mail.status.append('read') - - def delete(self, mail_id): - """ - Returns True if the email got purged, - else returns False meaning the email got moved to trash - """ - - mail = self.get(mail_id) - if 'trash' in mail.tags: - del self.mails[mail_id] - return True - mail.tags.append('trash') - return False - - def update(self, mail): - self.mails[mail.ident] = mail - - def add_draft(self, mail): - mail.ident = self.ident - self.mails[mail.ident] = mail - self.ident += 1 - return mail - - def find(self, draft_reply_for): - match = [ - mail - for mail in self.mails.values - () if mail.draft_reply_for == draft_reply_for] - if len(match) == 0: - return None - else: - return match[0] |