]> git.scottworley.com Git - paperdoorknob/commitdiff
Remove no-longer-needed DOMFilters NoEdit and NoFooter
authorScott Worley <scottworley@scottworley.com>
Fri, 29 Dec 2023 23:49:02 +0000 (15:49 -0800)
committerScott Worley <scottworley@scottworley.com>
Fri, 29 Dec 2023 23:50:55 +0000 (15:50 -0800)
These aren't needed anymore because Chunk individually extracts the five
things it needs from the chunk-DOMs, rather than pulling in the whole
chunk-<div>.

domfilter.py
domfilter_test.py
paperdoorknob_test.py

index e1095f0f856842d3d8fa9819dd36d57c4d1fda92..f00721dd321dd0ece3697a90a563c171bc430930 100644 (file)
@@ -16,8 +16,6 @@ def _changeTag(tag: Tag, new_name: str) -> Tag:
 
 
 DOMFilters: List[Tuple[str, Callable[[Tag], Any]]] = [
-    ("NoEdit", lambda x: [eb.decompose() for eb in x.find_all("div", class_="post-edit-box")]),
-    ("NoFooter", lambda x: [foot.decompose() for foot in x.find_all("div", class_="post-footer")]),
     ("Strike", lambda x: [_changeTag(span, 's')
                           for span in x.find_all("span", style="text-decoration: line-through;")]),
 ]
index 8daca20685dd0ba3ed04b3b1a82e9135ff42b9f3..02c33ac7d2885c9b1cddd5231417343e0c2a9ff0 100644 (file)
@@ -15,33 +15,12 @@ from domfilter import ApplyDOMFilters
 class TestDOMFilters(unittest.TestCase):
 
     def setUp(self) -> None:
-        self._html = BeautifulSoup(b'''
-            <div class="post-container post-post">
-              <div class="post-edit-box">This is the edit box</div>
-              This is glowfic
-              <div class="post-footer">This is the footer</div>
-            </div>''', 'html.parser')
         self._strike = BeautifulSoup(b'''
             <div class="post-content">
               <p><span style="text-decoration: line-through;">Abandon hope and endure.</span></p>
               <p>No. Win.</p>
             </div>''', 'html.parser')
 
-    def testStripFooters(self) -> None:
-        ApplyDOMFilters("NoFooter", self._html)
-        self.assertEqual(list(self._html.stripped_strings),
-                         ["This is the edit box", "This is glowfic"])
-
-    def testStripEditBoxes(self) -> None:
-        ApplyDOMFilters("NoEdit", self._html)
-        self.assertEqual(list(self._html.stripped_strings),
-                         ["This is glowfic", "This is the footer"])
-
-    def testStripFootersAndEditBoxes(self) -> None:
-        ApplyDOMFilters("NoEdit,NoFooter", self._html)
-        self.assertEqual(list(self._html.stripped_strings),
-                         ["This is glowfic"])
-
     def testStrike(self) -> None:
         ApplyDOMFilters('Strike', self._strike)
         s = self._strike.find_all('s')
index 6481803805cde8da5fd1b76ab9a3aa3e099b65f7..bafce174a1f0af81b46796297cd813d5adf14c57 100644 (file)
@@ -14,7 +14,6 @@ import subprocess
 import paperdoorknob
 
 from testing.fakeserver import FakeGlowficServer
-from domfilter import ApplyDOMFilters
 from fetch import DirectFetcher, FakeFetcher, Fetcher
 from glowfic import ContentOnlyLayout, BelowIconLayout
 from images import FakeImageStore
@@ -41,7 +40,7 @@ class BaseTestProcess(ABC):
             self.fetcher(),
             FakeImageStore(),
             lambda x: x,
-            lambda x: ApplyDOMFilters('NoEdit,NoFooter', x),
+            lambda x: None,
             lambda x: x,
             ContentOnlyLayout(PandocTexifier('pandoc')),
             'margin=20mm',
@@ -68,7 +67,7 @@ Pretty sure.
             self.fetcher(),
             FakeImageStore(),
             lambda x: x,
-            lambda x: ApplyDOMFilters('NoEdit,NoFooter', x),
+            lambda x: None,
             lambda x: x,
             ContentOnlyLayout(texifier),
             None,
@@ -82,7 +81,7 @@ Pretty sure.
                 self.fetcher(),
                 FakeImageStore(),
                 lambda x: x,
-                lambda x: ApplyDOMFilters('NoEdit,NoFooter', x),
+                lambda x: None,
                 lambda x: x,
                 BelowIconLayout(PandocTexifier('pandoc'), 20),
                 None,