Browse Source

PEP8 + Comments

Guénaël Muller 7 years ago
parent
commit
c608f86131

+ 1 - 0
tracim/tracim/lib/email_fetcher.py View File

159
         :param endpoint: tracim http endpoint where decoded mail are send.
159
         :param endpoint: tracim http endpoint where decoded mail are send.
160
         :param token: token to authenticate http connexion
160
         :param token: token to authenticate http connexion
161
         :param use_html_parsing: parse html mail
161
         :param use_html_parsing: parse html mail
162
+        :param use_txt_parsing: parse txt mail
162
         """
163
         """
163
         self._connection = None
164
         self._connection = None
164
         self.host = host
165
         self.host = host

+ 12 - 9
tracim/tracim/lib/email_processing/checkers.py View File

48
         :param attribute_value: Html attribute value
48
         :param attribute_value: Html attribute value
49
         :return: True only if Element contain this attribute.
49
         :return: True only if Element contain this attribute.
50
         """
50
         """
51
-        if isinstance(elem, Tag) and \
52
-              attribute_name in elem.attrs:
53
-              # INFO - G.M - 2017-12-01 - attrs[value}] can be string or list
54
-              # use get_attribute_list to always check in a list
55
-              # see https://www.crummy.com/software/BeautifulSoup/bs4/doc/#multi-valued-attributes # nopep8
56
-            values_lower=[value.lower()
51
+        if isinstance(elem, Tag) and attribute_name in elem.attrs:
52
+            # INFO - G.M - 2017-12-01 - attrs[value}] can be string or list
53
+            # use get_attribute_list to always check in a list
54
+            # see https://www.crummy.com/software/BeautifulSoup/bs4/doc/#multi-valued-attributes # nopep8
55
+            values_lower = [value.lower()
57
                             for value
56
                             for value
58
-                            in elem.get_attribute_list(attribute_name) ]
57
+                            in elem.get_attribute_list(attribute_name)]
59
             return attribute_value.lower() in values_lower
58
             return attribute_value.lower() in values_lower
60
         return False
59
         return False
61
 
60
 
62
 
61
 
63
 class HtmlMailQuoteChecker(HtmlChecker):
62
 class HtmlMailQuoteChecker(HtmlChecker):
64
-
63
+    """
64
+    Check if one HTML Element from Body Mail look-like a quote or not.
65
+    """
65
     @classmethod
66
     @classmethod
66
     def is_quote(
67
     def is_quote(
67
             cls,
68
             cls,
145
 
146
 
146
 
147
 
147
 class HtmlMailSignatureChecker(HtmlChecker):
148
 class HtmlMailSignatureChecker(HtmlChecker):
149
+    """
150
+    Check if one HTML Element from Body Mail look-like a signature or not.
151
+    """
148
 
152
 
149
     @classmethod
153
     @classmethod
150
     def is_signature(
154
     def is_signature(
205
                 ProprietaryHTMLAttrValues.Outlook_com_signature_id):
209
                 ProprietaryHTMLAttrValues.Outlook_com_signature_id):
206
             return True
210
             return True
207
         return False
211
         return False
208
-

+ 3 - 4
tracim/tracim/tests/library/test_email_body_parser.py View File

116
         assert HtmlMailSignatureChecker._is_outlook_com_signature(main_elem) \
116
         assert HtmlMailSignatureChecker._is_outlook_com_signature(main_elem) \
117
                is True
117
                is True
118
 
118
 
119
+
119
 class TestBodyMailsParts(TestStandard):
120
 class TestBodyMailsParts(TestStandard):
120
 
121
 
121
     def test_unit__std_list_methods(self):
122
     def test_unit__std_list_methods(self):
162
     def test_unit__append_dont_follow_when_first(self):
163
     def test_unit__append_dont_follow_when_first(self):
163
         mail_parts = BodyMailParts()
164
         mail_parts = BodyMailParts()
164
         a = BodyMailPart('a', BodyMailPartType.Main)
165
         a = BodyMailPart('a', BodyMailPartType.Main)
165
-        mail_parts._append(a,follow=True)
166
+        mail_parts._append(a, follow=True)
166
         assert len(mail_parts) == 1
167
         assert len(mail_parts) == 1
167
         assert mail_parts[0].part_type == BodyMailPartType.Main
168
         assert mail_parts[0].part_type == BodyMailPartType.Main
168
         assert mail_parts[0].text == 'a'
169
         assert mail_parts[0].text == 'a'
223
         assert mail_parts[0].text == 'ac'
224
         assert mail_parts[0].text == 'ac'
224
         assert mail_parts[0].part_type == BodyMailPartType.Main
225
         assert mail_parts[0].part_type == BodyMailPartType.Main
225
 
226
 
226
-
227
     def test_unit__get_nb_part_type(self):
227
     def test_unit__get_nb_part_type(self):
228
         mail_parts = BodyMailParts()
228
         mail_parts = BodyMailParts()
229
         assert mail_parts.get_nb_part_type(BodyMailPartType.Main) == 0
229
         assert mail_parts.get_nb_part_type(BodyMailPartType.Main) == 0
542
         écrit&nbsp;:<br>
542
         écrit&nbsp;:<br>
543
         </div>
543
         </div>
544
         <blockquote type="cite"
544
         <blockquote type="cite"
545
-        cite="mid:4e6923e2-796d-eccf-84b7-6824da4151ee@localhost.fr">Réponse <br>
545
+        cite="mid:4e6923e2-796d-eccf-84b7-6824da4151ee@localhost.fr">Réponse<br>
546
         <br>
546
         <br>
547
         Le 28/11/2017 à 11:21, John Doe a écrit&nbsp;: <br>
547
         Le 28/11/2017 à 11:21, John Doe a écrit&nbsp;: <br>
548
         <blockquote type="cite"> <br>
548
         <blockquote type="cite"> <br>
755
         assert elements[0].part_type == BodyMailPartType.Main
755
         assert elements[0].part_type == BodyMailPartType.Main
756
         assert elements[1].part_type == BodyMailPartType.Signature
756
         assert elements[1].part_type == BodyMailPartType.Signature
757
         assert elements[2].part_type == BodyMailPartType.Quote
757
         assert elements[2].part_type == BodyMailPartType.Quote
758
-