From 9900ee2ec6b52d8887f00c4d39d0ff30a2714421 Mon Sep 17 00:00:00 2001 From: Bruno Wagner Goncalves Date: Mon, 18 Aug 2014 16:50:02 -0300 Subject: Fixed PEP8 issues on py fake service --- py-fake-service/app/adapter/contacts.py | 6 ++++-- py-fake-service/app/adapter/mailset.py | 5 ++++- py-fake-service/app/pixelated_user_agent.py | 6 +++--- py-fake-service/app/search/search_query.py | 7 +++++-- 4 files changed, 16 insertions(+), 8 deletions(-) (limited to 'py-fake-service') diff --git a/py-fake-service/app/adapter/contacts.py b/py-fake-service/app/adapter/contacts.py index aaf2d23e..5c55b8b1 100644 --- a/py-fake-service/app/adapter/contacts.py +++ b/py-fake-service/app/adapter/contacts.py @@ -13,8 +13,10 @@ class Contacts: def search(self, query): contacts_query = re.compile(query) return [ - contact.__dict__ for contact in self.contacts if contacts_query.match( - contact.addresses[0])] + contact.__dict__ + for contact in self.contacts + if contacts_query.match(contact.addresses[0]) + ] class Contact: diff --git a/py-fake-service/app/adapter/mailset.py b/py-fake-service/app/adapter/mailset.py index d08a58cb..2d9707ab 100644 --- a/py-fake-service/app/adapter/mailset.py +++ b/py-fake-service/app/adapter/mailset.py @@ -22,7 +22,10 @@ class MailSet: 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 """ + """ + 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: diff --git a/py-fake-service/app/pixelated_user_agent.py b/py-fake-service/app/pixelated_user_agent.py index 7d974329..41407b1c 100644 --- a/py-fake-service/app/pixelated_user_agent.py +++ b/py-fake-service/app/pixelated_user_agent.py @@ -7,6 +7,8 @@ from adapter import MailService from search import SearchQuery app = Flask(__name__, static_url_path='', static_folder='../../web-ui/app') +MEDIUM_TAGGED_URL = 'https://example.wazokazi.is:8154\ + /go/static/py-mediumtagged.tar.gz' client = None converter = None account = None @@ -119,9 +121,7 @@ def load_mailset(mailset): os.mkdir(mbox_root) if len(os.listdir(mbox_root)) == 0: - response = requests.get( - 'https://example.wazokazi.is:8154/go/static/py-mediumtagged.tar.gz', - verify=False) + response = requests.get(MEDIUM_TAGGED_URL, verify=False) mbox_archive_path = os.path.join(mbox_root, 'py-mediumtagged.tar.gz') mbox_archive = open(mbox_archive_path, 'w') mbox_archive.write(response.content) diff --git a/py-fake-service/app/search/search_query.py b/py-fake-service/app/search/search_query.py index 765d1008..ec9b054f 100644 --- a/py-fake-service/app/search/search_query.py +++ b/py-fake-service/app/search/search_query.py @@ -49,17 +49,20 @@ class SearchQuery: self.compiled = compiled def test(self, mail): + if 'all' in self.compiled.get('tags'): + return True + if set(self.compiled.get('not_tags')).intersection(set(mail.tags)): return False - if set(self.compiled.get('tags')).intersection(set(mail.tags)) or 'all' in self.compiled.get('tags'): + if set(self.compiled.get('tags')).intersection(set(mail.tags)): return True if self.compiled.get('general'): search_terms = re.compile( self.compiled['general'], flags=re.IGNORECASE) - if search_terms.search(mail.body) or search_terms.search(mail.subject): + if search_terms.search(mail.subject+' '+mail.body): return True if not [v for v in self.compiled.values() if v]: -- cgit v1.2.3