Guénaël Muller 6 years ago
parent
commit
d2540126b9
1 changed files with 6 additions and 6 deletions
  1. 6 6
      tracim/tracim/lib/email_body_parser.py

+ 6 - 6
tracim/tracim/lib/email_body_parser.py View File

39
         # say "all elem after me is Signature"
39
         # say "all elem after me is Signature"
40
         self.follow = False
40
         self.follow = False
41
 
41
 
42
-
43
     def __len__(self) -> int:
42
     def __len__(self) -> int:
44
         return len(self._list)
43
         return len(self._list)
45
 
44
 
55
         self._append(value)
54
         self._append(value)
56
 
55
 
57
     def _append(self, value) -> None:
56
     def _append(self, value) -> None:
58
-        same_type_as_last =len(self._list) > 0 and \
59
-                           self._list[-1].part_type == value.part_type
60
-        if same_type_as_last or self.follow :
57
+        same_type_as_last = len(self._list) > 0 and \
58
+                            self._list[-1].part_type == value.part_type
59
+        if same_type_as_last or self.follow:
61
             self._list[-1].text += value.text
60
             self._list[-1].text += value.text
62
         else:
61
         else:
63
             self._list.append(value)
62
             self._list.append(value)
215
             for child in elem.children:
214
             for child in elem.children:
216
                 if cls._has_attr_value(child, 'class', 'gmail_signature'):
215
                 if cls._has_attr_value(child, 'class', 'gmail_signature'):
217
                     return True
216
                     return True
218
-        if isinstance(elem,Tag) and elem.name.lower() == 'div':
217
+        if isinstance(elem, Tag) and elem.name.lower() == 'div':
219
             for child in elem.children:
218
             for child in elem.children:
220
                 if cls._has_attr_value(child, 'class', 'gmail_signature'):
219
                 if cls._has_attr_value(child, 'class', 'gmail_signature'):
221
                     return True
220
                     return True
230
             return True
229
             return True
231
         return False
230
         return False
232
 
231
 
232
+
233
 class ParsedHTMLMail(object):
233
 class ParsedHTMLMail(object):
234
     """
234
     """
235
     Parse HTML Mail depending of some rules.
235
     Parse HTML Mail depending of some rules.
280
             # Hack - G.M - 2017-11-28 : remove tag with no enclosure
280
             # Hack - G.M - 2017-11-28 : remove tag with no enclosure
281
             # <br> and <hr> tag alone broke html.parser tree,
281
             # <br> and <hr> tag alone broke html.parser tree,
282
             # Using another parser may be a solution.
282
             # Using another parser may be a solution.
283
-            if tag.name.lower() in ['br','hr']:
283
+            if tag.name.lower() in ['br', 'hr']:
284
                 tag.unwrap()
284
                 tag.unwrap()
285
                 continue
285
                 continue
286
             if tag.name.lower() in ['script', 'style']:
286
             if tag.name.lower() in ['script', 'style']: