From: Scott Worley Date: Wed, 20 Dec 2023 07:55:05 +0000 (-0800) Subject: Pass an ImageStore around X-Git-Url: http://git.scottworley.com/paperdoorknob/commitdiff_plain/cfd0b634e21851a0d9e8b4c8c258307baefcd931?hp=432bb83bc214a4b3212471a69ace15090cbb7d37 Pass an ImageStore around --- 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