From cfd0b634e21851a0d9e8b4c8c258307baefcd931 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Tue, 19 Dec 2023 23:55:05 -0800 Subject: [PATCH] Pass an ImageStore around --- args.py | 2 ++ paperdoorknob_test.py | 4 ++++ spec.py | 2 ++ 3 files changed, 8 insertions(+) diff --git a/args.py b/args.py index f343a84..d90de8a 100644 --- a/args.py +++ b/args.py @@ -16,6 +16,7 @@ from xdg_base_dirs import xdg_cache_home from domfilter import ApplyDOMFilters, DOMFilters from fetch import CachingFetcher from htmlfilter import ApplyHTMLFilters, HTMLFilters +from images import ImageStore from spec import Spec from texify import PandocTexifier @@ -66,6 +67,7 @@ def spec_from_commandline_args() -> Iterator[Spec]: yield Spec( args.url, fetcher, + ImageStore(args.out + '_images', fetcher), lambda x: ApplyHTMLFilters(args.htmlfilters, x), lambda x: ApplyDOMFilters(args.domfilters, x), PandocTexifier(args.pandoc or 'pandoc'), diff --git a/paperdoorknob_test.py b/paperdoorknob_test.py index 49f1872..65fc2a9 100644 --- a/paperdoorknob_test.py +++ b/paperdoorknob_test.py @@ -15,6 +15,7 @@ import paperdoorknob from testing.fakeserver import FakeGlowficServer from domfilter import ApplyDOMFilters from fetch import DirectFetcher, FakeFetcher, Fetcher +from images import ImageStore from spec import Spec from texify import DirectTexifier, PandocTexifier, VerifyingTexifier @@ -46,6 +47,7 @@ class BaseTestProcess(ABC): spec = Spec( self.url(), self.fetcher(), + ImageStore('is', self.fetcher()), lambda x: x, lambda x: ApplyDOMFilters('NoEdit,NoFooter', x), PandocTexifier('pandoc'), @@ -68,6 +70,7 @@ Pretty sure. spec = Spec( self.url(), self.fetcher(), + ImageStore('is', self.fetcher()), lambda x: x, lambda x: ApplyDOMFilters('NoEdit,NoFooter', x), texifier, @@ -80,6 +83,7 @@ Pretty sure. spec = Spec( self.url(), self.fetcher(), + ImageStore('is', self.fetcher()), lambda x: x, lambda x: ApplyDOMFilters('NoEdit,NoFooter', x), PandocTexifier('pandoc'), diff --git a/spec.py b/spec.py index c7ace56..2b80f16 100644 --- a/spec.py +++ b/spec.py @@ -13,6 +13,7 @@ from bs4.element import Tag from fetch import Fetcher from texify import Texifier +from images import ImageStore # pylint: disable=too-many-instance-attributes @@ -20,6 +21,7 @@ from texify import Texifier class Spec: url: str fetcher: Fetcher + images: ImageStore htmlfilter: Callable[[bytes], bytes] domfilter: Callable[[Tag], None] texifier: Texifier -- 2.44.1