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,6 +159,7 @@ class MailFetcher(object):
159 159
         :param endpoint: tracim http endpoint where decoded mail are send.
160 160
         :param token: token to authenticate http connexion
161 161
         :param use_html_parsing: parse html mail
162
+        :param use_txt_parsing: parse txt mail
162 163
         """
163 164
         self._connection = None
164 165
         self.host = host

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

@@ -48,20 +48,21 @@ class HtmlChecker(object):
48 48
         :param attribute_value: Html attribute value
49 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 56
                             for value
58
-                            in elem.get_attribute_list(attribute_name) ]
57
+                            in elem.get_attribute_list(attribute_name)]
59 58
             return attribute_value.lower() in values_lower
60 59
         return False
61 60
 
62 61
 
63 62
 class HtmlMailQuoteChecker(HtmlChecker):
64
-
63
+    """
64
+    Check if one HTML Element from Body Mail look-like a quote or not.
65
+    """
65 66
     @classmethod
66 67
     def is_quote(
67 68
             cls,
@@ -145,6 +146,9 @@ class HtmlMailQuoteChecker(HtmlChecker):
145 146
 
146 147
 
147 148
 class HtmlMailSignatureChecker(HtmlChecker):
149
+    """
150
+    Check if one HTML Element from Body Mail look-like a signature or not.
151
+    """
148 152
 
149 153
     @classmethod
150 154
     def is_signature(
@@ -205,4 +209,3 @@ class HtmlMailSignatureChecker(HtmlChecker):
205 209
                 ProprietaryHTMLAttrValues.Outlook_com_signature_id):
206 210
             return True
207 211
         return False
208
-

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

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