예제 #1
0
 def test_unit__is_gmail_signature_yes(self):
     html = '<div class="gmail_extra">' + \
            '<a></a><div class="gmail_signature"></div>' + \
            '</div>'
     soup = BeautifulSoup(html, 'html.parser')
     main_elem = soup.find()
     assert HtmlMailSignatureChecker._is_gmail_signature(main_elem) is True
예제 #2
0
 def test_unit__is_gmail_signature_yes(self):
     html = '<div class="gmail_extra">' + \
            '<a></a><div class="gmail_signature"></div>' + \
            '</div>'
     soup = BeautifulSoup(html, 'html.parser')
     main_elem = soup.find()
     assert HtmlMailSignatureChecker._is_gmail_signature(main_elem) is True
예제 #3
0
파일: parser.py 프로젝트: tracim/tracim
    def _distinct_elements(cls, tree: BeautifulSoup) -> HtmlBodyMailParts:
        parts = HtmlBodyMailParts()
        for elem in list(tree):
            part_txt = str(elem)
            part_type = BodyMailPartType.Main

            if HtmlMailQuoteChecker.is_quote(elem):
                part_type = BodyMailPartType.Quote
            elif HtmlMailSignatureChecker.is_signature(elem):
                part_type = BodyMailPartType.Signature

            part = BodyMailPart(part_txt, part_type)
            parts.append(part)
            # INFO - G.M - 2017-11-28 - Outlook.com special case
            # all after quote tag is quote
            if HtmlMailQuoteChecker._is_outlook_com_quote(elem):
                parts.follow = True
        return parts
예제 #4
0
    def _distinct_elements(cls, tree: BeautifulSoup) -> HtmlBodyMailParts:
        parts = HtmlBodyMailParts()
        for elem in list(tree):
            part_txt = str(elem)
            part_type = BodyMailPartType.Main

            if HtmlMailQuoteChecker.is_quote(elem):
                part_type = BodyMailPartType.Quote
            elif HtmlMailSignatureChecker.is_signature(elem):
                part_type = BodyMailPartType.Signature

            part = BodyMailPart(part_txt, part_type)
            parts.append(part)
            # INFO - G.M - 2017-11-28 - Outlook.com special case
            # all after quote tag is quote
            if HtmlMailQuoteChecker._is_outlook_com_quote(elem):
                parts.follow = True
        return parts
예제 #5
0
 def test_unit__is_gmail_signature_yes_2(self):
     html = '<div class="gmail_signature">' + "</div>"
     soup = BeautifulSoup(html, "html.parser")
     main_elem = soup.find()
     assert HtmlMailSignatureChecker._is_gmail_signature(main_elem) is True
예제 #6
0
 def test_unit__is_gmail_signature_no(self):
     soup = BeautifulSoup('<div class="nothing"></div>', "html.parser")
     main_elem = soup.find()
     assert HtmlMailSignatureChecker._is_gmail_signature(main_elem) is False
예제 #7
0
 def test_unit__is_gmail_signature_ok(self):
     html = '<div class="gmail_extra">' + '<a></a><div class="gmail_quote"></div>' + "</div>"
     soup = BeautifulSoup(html, "html.parser")
     main_elem = soup.find()
     assert HtmlMailSignatureChecker._is_gmail_signature(main_elem) is False
예제 #8
0
 def test_unit__is_thunderbird_signature_ok(self):
     soup = BeautifulSoup('<div class="moz-signature"></div>',
                          "html.parser")
     main_elem = soup.find()
     assert HtmlMailSignatureChecker._is_thunderbird_signature(
         main_elem) is True
예제 #9
0
 def test_unit__is_outlook_com_signature_ok(self):
     soup = BeautifulSoup('<div id="Signature"></div>', "html.parser")
     main_elem = soup.find()
     assert HtmlMailSignatureChecker._is_outlook_com_signature(
         main_elem) is True
예제 #10
0
 def test_unit__is_thunderbird_signature_no(self):
     soup = BeautifulSoup('<div class="other"></div>', 'html.parser')
     main_elem = soup.find()
     assert HtmlMailSignatureChecker._is_thunderbird_signature(
         main_elem) is False  # nopep8
예제 #11
0
 def test_unit__is_outlook_com_signature_no(self):
     soup = BeautifulSoup('<div id="divRplyFwdMsg"></div>', 'html.parser')
     main_elem = soup.find()
     assert HtmlMailSignatureChecker._is_outlook_com_signature(main_elem) \
            is False
예제 #12
0
 def test_unit__is_gmail_signature_no(self):
     soup = BeautifulSoup('<div class="nothing"></div>', 'html.parser')
     main_elem = soup.find()
     assert HtmlMailSignatureChecker._is_gmail_signature(main_elem) is False
예제 #13
0
 def test_unit__is_thunderbird_signature_no(self):
     soup = BeautifulSoup('<div class="other"></div>', 'html.parser')
     main_elem = soup.find()
     assert HtmlMailSignatureChecker._is_thunderbird_signature(main_elem) is False  # nopep8
예제 #14
0
 def test_unit__is_outlook_com_signature_ok(self):
     soup = BeautifulSoup('<div id="Signature"></div>', 'html.parser')
     main_elem = soup.find()
     assert HtmlMailSignatureChecker._is_outlook_com_signature(main_elem) \
            is True