Browse Source

Comment + PEP8

Guénaël Muller 7 years ago
parent
commit
370dad7f8c
1 changed files with 3 additions and 4 deletions
  1. 3 4
      tracim/tracim/lib/email_fetcher.py

+ 3 - 4
tracim/tracim/lib/email_fetcher.py View File

22
 TRACIM_SPECIAL_KEY_HEADER = "X-Tracim-Key"
22
 TRACIM_SPECIAL_KEY_HEADER = "X-Tracim-Key"
23
 BS_HTML_BODY_PARSE_CONFIG = {
23
 BS_HTML_BODY_PARSE_CONFIG = {
24
     'tag_blacklist': ["script", "style", "blockquote"],
24
     'tag_blacklist': ["script", "style", "blockquote"],
25
-    'class_blacklist': ['moz-cite-prefix','gmail_extra','gmail_quote',
25
+    'class_blacklist': ['moz-cite-prefix', 'gmail_extra', 'gmail_quote',
26
                         'yahoo_quoted'],
26
                         'yahoo_quoted'],
27
     'id_blacklist': ['reply-intro'],
27
     'id_blacklist': ['reply-intro'],
28
     'tag_whitelist': ['a', 'b', 'strong', 'i', 'br', 'ul', 'li', 'ol',
28
     'tag_whitelist': ['a', 'b', 'strong', 'i', 'br', 'ul', 'li', 'ol',
111
     def _get_mime_body_message(self) -> typing.Optional[Message]:
111
     def _get_mime_body_message(self) -> typing.Optional[Message]:
112
         # FIXME - G.M - 2017-11-16 - Use stdlib msg.get_body feature for py3.6+
112
         # FIXME - G.M - 2017-11-16 - Use stdlib msg.get_body feature for py3.6+
113
         # FIXME - G.M - 2017-11-16 - Check support for non-multipart mail
113
         # FIXME - G.M - 2017-11-16 - Check support for non-multipart mail
114
-        # assert msg.is_multipart()
115
         part = None
114
         part = None
116
         # Check for html
115
         # Check for html
117
         for part in self._message.walk():
116
         for part in self._message.walk():
119
             cdispo = str(part.get('Content-Disposition'))
118
             cdispo = str(part.get('Content-Disposition'))
120
             if ctype == 'text/html' and 'attachment' not in cdispo:
119
             if ctype == 'text/html' and 'attachment' not in cdispo:
121
                 return part
120
                 return part
122
-        # checj fir plain text
121
+        # check for plain text
123
         for part in self._message.walk():
122
         for part in self._message.walk():
124
             ctype = part.get_content_type()
123
             ctype = part.get_content_type()
125
             cdispo = str(part.get('Content-Disposition'))
124
             cdispo = str(part.get('Content-Disposition'))
270
             try:
269
             try:
271
                 r = requests.post(self.endpoint, json=msg)
270
                 r = requests.post(self.endpoint, json=msg)
272
                 response = r.json()
271
                 response = r.json()
273
-                if not 'status' in response:
272
+                if 'status' not in response:
274
                     log = 'bad response: {}'
273
                     log = 'bad response: {}'
275
                     logger.error(self, log.format(str(response)))
274
                     logger.error(self, log.format(str(response)))
276
                 else:
275
                 else: