pygetcomics 1.4.0__tar.gz → 1.6.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. pygetcomics-1.6.2/PKG-INFO +44 -0
  2. pygetcomics-1.6.2/docs/README.md +18 -0
  3. pygetcomics-1.6.2/pyproject.toml +242 -0
  4. pygetcomics-1.6.2/src/berhoel/get_comics/__init__.py +26 -0
  5. pygetcomics-1.6.2/src/berhoel/get_comics/__init__.py,cover +45 -0
  6. pygetcomics-1.6.2/src/berhoel/get_comics/__main__.py +7 -0
  7. pygetcomics-1.6.2/src/berhoel/get_comics/_version.py,cover +1 -0
  8. pygetcomics-1.6.2/src/berhoel/get_comics/garfield/__init__.py +40 -0
  9. pygetcomics-1.6.2/src/berhoel/get_comics/garfield/__init__.py,cover +61 -0
  10. pygetcomics-1.6.2/src/berhoel/get_comics/garfield/__main__.py +7 -0
  11. pygetcomics-1.6.2/src/berhoel/get_comics/gen_pdf/__init__.py +105 -0
  12. pygetcomics-1.6.2/src/berhoel/get_comics/gen_pdf/__init__.py,cover +109 -0
  13. pygetcomics-1.6.2/src/berhoel/get_comics/gen_pdf/template/auto/book.el +16 -0
  14. pygetcomics-1.6.2/src/berhoel/get_comics/gen_pdf/template/auto/book.elc +0 -0
  15. pygetcomics-1.6.2/src/berhoel/get_comics/gocomics/.mypy_cache/3.8/_ast.data.json +1 -0
  16. pygetcomics-1.6.2/src/berhoel/get_comics/gocomics/.mypy_cache/3.8/_ast.meta.json +1 -0
  17. pygetcomics-1.6.2/src/berhoel/get_comics/gocomics/.mypy_cache/3.8/_importlib_modulespec.data.json +1 -0
  18. pygetcomics-1.6.2/src/berhoel/get_comics/gocomics/.mypy_cache/3.8/_importlib_modulespec.meta.json +1 -0
  19. pygetcomics-1.6.2/src/berhoel/get_comics/gocomics/.mypy_cache/3.8/abc.data.json +1 -0
  20. pygetcomics-1.6.2/src/berhoel/get_comics/gocomics/.mypy_cache/3.8/abc.meta.json +1 -0
  21. pygetcomics-1.6.2/src/berhoel/get_comics/gocomics/.mypy_cache/3.8/ast.data.json +1 -0
  22. pygetcomics-1.6.2/src/berhoel/get_comics/gocomics/.mypy_cache/3.8/ast.meta.json +1 -0
  23. pygetcomics-1.6.2/src/berhoel/get_comics/gocomics/.mypy_cache/3.8/types.data.json +1 -0
  24. pygetcomics-1.6.2/src/berhoel/get_comics/gocomics/.mypy_cache/3.8/types.meta.json +1 -0
  25. pygetcomics-1.6.2/src/berhoel/get_comics/gocomics/.mypy_cache/3.8/typing.data.json +1 -0
  26. pygetcomics-1.6.2/src/berhoel/get_comics/gocomics/.mypy_cache/3.8/typing.meta.json.3ab670623ca749ba +0 -0
  27. pygetcomics-1.6.2/src/berhoel/get_comics/gocomics/__init__.py +253 -0
  28. pygetcomics-1.6.2/src/berhoel/get_comics/gocomics/__init__.py,cover +303 -0
  29. {pygetcomics-1.4.0 → pygetcomics-1.6.2/src}/berhoel/get_comics/peanuts/__init__.py +19 -50
  30. pygetcomics-1.6.2/src/berhoel/get_comics/peanuts/__init__.py,cover +134 -0
  31. pygetcomics-1.6.2/src/berhoel/get_comics/peanuts/__main__.py +7 -0
  32. pygetcomics-1.6.2/src/berhoel/get_comics/peanuts/clean_up.py +31 -0
  33. pygetcomics-1.6.2/src/berhoel/get_comics/peanuts/clean_up.py,cover +39 -0
  34. pygetcomics-1.6.2/src/berhoel/get_comics/peanuts/gen_book.py +213 -0
  35. pygetcomics-1.6.2/src/berhoel/get_comics/peanuts/gen_book.py,cover +215 -0
  36. pygetcomics-1.6.2/src/berhoel/get_comics/py.typed +0 -0
  37. pygetcomics-1.6.2/src/berhoel/get_comics/tests/__init__.py +1 -0
  38. pygetcomics-1.6.2/src/berhoel/get_comics/tests/test_get_comics.py +8 -0
  39. pygetcomics-1.6.2/src/berhoel/get_comics/tests/test_get_comics.py,cover +6 -0
  40. pygetcomics-1.4.0/LICENSE +0 -25
  41. pygetcomics-1.4.0/PKG-INFO +0 -32
  42. pygetcomics-1.4.0/README.rst +0 -5
  43. pygetcomics-1.4.0/berhoel/__init__.py +0 -21
  44. pygetcomics-1.4.0/berhoel/get_comics/__init__.py +0 -58
  45. pygetcomics-1.4.0/berhoel/get_comics/garfield/__init__.py +0 -71
  46. pygetcomics-1.4.0/berhoel/get_comics/gen_pdf/__init__.py +0 -85
  47. pygetcomics-1.4.0/berhoel/get_comics/gocomics/__init__.py +0 -267
  48. pygetcomics-1.4.0/berhoel/get_comics/peanuts/clean_up.py +0 -49
  49. pygetcomics-1.4.0/berhoel/get_comics/peanuts/gen_book.py +0 -186
  50. pygetcomics-1.4.0/berhoel/get_comics/tests/test_get_comics.py +0 -51
  51. pygetcomics-1.4.0/pyproject.toml +0 -102
  52. {pygetcomics-1.4.0 → pygetcomics-1.6.2/src}/berhoel/get_comics/gen_pdf/template/book.tex +0 -0
@@ -0,0 +1,44 @@
1
+ Metadata-Version: 2.3
2
+ Name: pygetcomics
3
+ Version: 1.6.2
4
+ Summary: Download various daily comics.
5
+ Author: Berthold Höllmann
6
+ Author-email: Berthold Höllmann <berthold-gitlab@xn--hllmanns-n4a.de>
7
+ License: BSD-2-Clause
8
+ Classifier: Development Status :: 4 - Beta
9
+ Classifier: License :: OSI Approved :: BSD License
10
+ Classifier: Programming Language :: Python
11
+ Classifier: Programming Language :: Python :: Implementation :: CPython
12
+ Classifier: Operating System :: OS Independent
13
+ Requires-Dist: click
14
+ Requires-Dist: pillow
15
+ Requires-Dist: lxml
16
+ Requires-Dist: requests
17
+ Requires-Dist: jinja2
18
+ Requires-Dist: playwright
19
+ Maintainer: Berthold Höllmann
20
+ Maintainer-email: Berthold Höllmann <berthold-gitlab@xn--hllmanns-n4a.de>
21
+ Requires-Python: >=3.13, <4.0
22
+ Project-URL: Documentation, https://python.xn--hllmanns-n4a.de/pyGetComics/
23
+ Project-URL: Homepage, https://python.xn--hllmanns-n4a.de/
24
+ Project-URL: Repository, https://gitlab.com/berhoel/python/pyGetComics.git
25
+ Description-Content-Type: text/markdown
26
+
27
+ # pyGetComics
28
+
29
+ Download various daily comics.
30
+
31
+ ::: mkdocs-click
32
+ :module: berhoel.get_comics
33
+ :command: get_comics
34
+ :depth: 2
35
+
36
+ ::: mkdocs-click
37
+ :module: berhoel.get_comics.peanuts
38
+ :command: get_peanuts
39
+ :depth: 2
40
+
41
+ ::: mkdocs-click
42
+ :module: berhoel.get_comics.garfield
43
+ :command: get_garfield
44
+ :depth: 2
@@ -0,0 +1,18 @@
1
+ # pyGetComics
2
+
3
+ Download various daily comics.
4
+
5
+ ::: mkdocs-click
6
+ :module: berhoel.get_comics
7
+ :command: get_comics
8
+ :depth: 2
9
+
10
+ ::: mkdocs-click
11
+ :module: berhoel.get_comics.peanuts
12
+ :command: get_peanuts
13
+ :depth: 2
14
+
15
+ ::: mkdocs-click
16
+ :module: berhoel.get_comics.garfield
17
+ :command: get_garfield
18
+ :depth: 2
@@ -0,0 +1,242 @@
1
+ [project]
2
+
3
+ name = "pyGetComics"
4
+
5
+ version = "1.6.2"
6
+
7
+ description = "Download various daily comics."
8
+
9
+ readme = "docs/README.md"
10
+
11
+ authors = [{ name = "Berthold Höllmann", email = "berthold-gitlab@xn--hllmanns-n4a.de" }]
12
+
13
+ requires-python = ">=3.13,<4.0"
14
+
15
+ license = { text = "BSD-2-Clause" }
16
+
17
+ maintainers = [{ name = "Berthold Höllmann", email = "berthold-gitlab@xn--hllmanns-n4a.de" }]
18
+
19
+ classifiers = [
20
+ "Development Status :: 4 - Beta",
21
+ "License :: OSI Approved :: BSD License",
22
+ "Programming Language :: Python",
23
+ "Programming Language :: Python :: Implementation :: CPython",
24
+ "Operating System :: OS Independent",
25
+ ]
26
+
27
+ dependencies = [
28
+ "click",
29
+ "Pillow",
30
+ "lxml",
31
+ "requests",
32
+ "jinja2",
33
+ "playwright",
34
+ ]
35
+
36
+ copyright = "Copyright © 2017-2025 by Berthold Höllmann"
37
+
38
+ [project.urls]
39
+ Homepage = "https://python.xn--hllmanns-n4a.de/"
40
+ Repository = "https://gitlab.com/berhoel/python/pyGetComics.git"
41
+ Documentation = "https://python.xn--hllmanns-n4a.de/pyGetComics/"
42
+
43
+ [project.scripts]
44
+ get-comics = "berhoel.get_comics:get_comics"
45
+ get-peanuts = "berhoel.get_comics.peanuts:get_peanuts"
46
+ get-garfield = "berhoel.get_comics.garfield:get_garfield"
47
+
48
+ [dependency-groups]
49
+ dev = [
50
+ "black",
51
+ "ipython",
52
+ "isort",
53
+ "mypy",
54
+ "pdbp",
55
+ "pdbpp>=0.11.7",
56
+ "ruff",
57
+ "scipy-stubs",
58
+ "types-requests",
59
+ ]
60
+ test = [
61
+ "doc8",
62
+ "pytest",
63
+ "pytest-benchmark[histogram]",
64
+ "pytest-cache",
65
+ "pytest-cov",
66
+ "pytest-mock",
67
+ "pytest-ruff",
68
+ "pytest-runner",
69
+ "pytest-sugar",
70
+ "rope",
71
+ "tox",
72
+ "xdoctest",
73
+ ]
74
+ doc = [
75
+ "griffe_pydantic",
76
+ "griffe_sphinx",
77
+ "griffe_typingdoc",
78
+ "markdown-callouts",
79
+ "mkdocs-click",
80
+ "mkdocs-llmstxt",
81
+ "mkdocs-material-berhoel",
82
+ "mkdocs-minify-plugin",
83
+ "pydantic",
84
+ ]
85
+ types = [
86
+ "lxml-stubs",
87
+ "types-lxml",
88
+ "types-pillow",
89
+ "types-jinja2",
90
+ "types-requests",
91
+ ]
92
+
93
+ [tool.uv]
94
+ default-groups = [
95
+ "dev",
96
+ "test",
97
+ "doc",
98
+ "types",
99
+ ]
100
+
101
+ [tool.uv.sources]
102
+ mkdocs-material-berhoel = { git = "https://gitlab.com/berhoel/python/mkdocs-material-berhoel.git" }
103
+
104
+ [tool.hatch.build.targets.sdist]
105
+ include = ["berhoel"]
106
+ from="src"
107
+ exclude = [
108
+ "**/.#*.py",
109
+ "**/#*.py#",
110
+ ]
111
+
112
+ [tool.hatch.build.targets.wheel]
113
+ include = ["berhoel"]
114
+ from="src"
115
+ exclude = [
116
+ "**/.#*.py",
117
+ "**/#*.py#",
118
+ ]
119
+
120
+ [build-system]
121
+ requires = ["uv_build>=0.8.18,<0.9.0"]
122
+ build-backend = "uv_build"
123
+
124
+ [tool.uv.build-backend]
125
+ module-name = "berhoel.get_comics"
126
+
127
+ [tool.isort]
128
+ dedup_headings = true
129
+ include_trailing_comma = true
130
+ float_to_top = true
131
+ namespace_packages = ["berhoel"]
132
+ force_grid_wrap = 0
133
+ balanced_wrapping = true
134
+ use_parentheses = true
135
+ length_sort = true
136
+ line_length = 88
137
+ combine_as_imports = true
138
+ known_first_party = ["berhoel"]
139
+ known_third_party = ["pytest"]
140
+
141
+ [tool.black]
142
+ line-length = 88
143
+ target-version = ['py314']
144
+ include = '\.pyi?$'
145
+
146
+ [tool.ruff]
147
+ namespace-packages = ["berhoel"]
148
+ line-length = 88
149
+
150
+ [tool.ruff.lint]
151
+ select = ["ALL"]
152
+ ignore = ["D211", "D213", "RUF200", "ISC001", "COM812"]
153
+
154
+ [tool.ruff.lint.pydocstyle]
155
+ convention = "google"
156
+
157
+ [tool.ruff.lint.per-file-ignores]
158
+ "docs/**.py" = ["INP001"]
159
+
160
+ [tool.ruff.format]
161
+ # Enable auto-formatting of code examples in docstrings. Markdown,
162
+ docstring-code-format = true
163
+
164
+ # Set the line length limit used when formatting code snippets in
165
+ # docstrings.
166
+ #
167
+ # This only has an effect when the `docstring-code-format` setting is
168
+ # enabled.
169
+ docstring-code-line-length = "dynamic"
170
+
171
+ [tool.ruff.lint.isort]
172
+ force-sort-within-sections = true
173
+ force-wrap-aliases = true
174
+ combine-as-imports = true
175
+ required-imports = ["from __future__ import annotations"]
176
+ section-order = [
177
+ "future",
178
+ "standard-library",
179
+ "third-party",
180
+ "first-party",
181
+ "local-folder",
182
+ ]
183
+ default-section = "third-party"
184
+ known-first-party = ["berhoel"]
185
+ known-third-party = ["pytest"]
186
+
187
+ [tool.ruff.lint.flake8-quotes]
188
+ docstring-quotes = "double"
189
+
190
+ [tool.ruff.lint.flake8-annotations]
191
+ mypy-init-return = true
192
+
193
+ [tool.mypy]
194
+ packages = ["berhoel.get_comics"]
195
+ mypy_path = "$MYPY_CONFIG_FILE_DIR/.stubs/:src/"
196
+
197
+ [tool.tox]
198
+ requires = ["tox>=4.19"]
199
+ env_list = ["3.12", "3.13", "3.13t", "3.14", "3.14t"]
200
+
201
+ [tool.tox.env_run_base]
202
+ description = "Run test under {base_python}"
203
+ deps = [
204
+ "pdbpp",
205
+ "pytest",
206
+ "pytest-benchmark[histogram]",
207
+ "pytest-cov",
208
+ "pytest-mock",
209
+ "pytest-ruff",
210
+ "pytest-runner",
211
+ "pytest-sugar",
212
+ "rope",
213
+ "toml",
214
+ "xdoctest",
215
+ ]
216
+ allowlist_externals = ["uv"]
217
+ commands = [["uv", "run", "pytest"]]
218
+
219
+ [tool.pytest.ini_options]
220
+ junit_family = "xunit2"
221
+ doctest_encoding = "UTF-8"
222
+ minversion = "7.0"
223
+ addopts = [
224
+ #"--benchmark-histogram=plots/benchmark-histogram",
225
+ #"--benchmark-compare",
226
+ "--xdoctest",
227
+ "--xdoctest-glob=*.md",
228
+ "--failed-first",
229
+ "--capture=no",
230
+ "--cov=src/berhoel/get_comics",
231
+ "--cov-report=term",
232
+ "--cov-report=html:htmlcov",
233
+ "--cov-branch",
234
+ "--cov-context=test",
235
+ "--ruff",
236
+ "--strict-config",
237
+ "--strict-markers",
238
+ ]
239
+ testpaths = ["src/berhoel/get_comics"]
240
+
241
+ [tool.doc8]
242
+ ignore-path=["pygetcomics.egg-info", ".tox", ".venv", ".direnv", "site"]
@@ -0,0 +1,26 @@
1
+ """Download various daily comics."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from importlib import metadata
6
+ import sys
7
+
8
+ import click
9
+ from playwright.sync_api import sync_playwright
10
+
11
+ from . import garfield, peanuts
12
+
13
+
14
+ @click.command()
15
+ @click.version_option(version=f"{metadata.version('pyGetComics')}")
16
+ def get_comics() -> None:
17
+ """Download various periodic comics."""
18
+ with sync_playwright() as playwright:
19
+ sys.stdout.write("Get Peanuts.\n")
20
+ peanuts.Peanuts(playwright)()
21
+ sys.stdout.write("Get Garfield.\n")
22
+ garfield.Garfield(playwright)()
23
+
24
+
25
+ if __name__ == "__main__":
26
+ get_comics()
@@ -0,0 +1,45 @@
1
+ > """Download various daily comics."""
2
+
3
+ > from __future__ import annotations
4
+
5
+ > import argparse
6
+ > from importlib import metadata
7
+ > import sys
8
+
9
+ > from . import garfield, peanuts
10
+
11
+ > __date__ = "2024/07/12 23:02:32 hoel"
12
+ > __author__ = "Berthold Höllmann"
13
+ > __copyright__ = "Copyright © 2017, 2022 by Berthold Höllmann"
14
+ > __credits__ = ["Berthold Höllmann"]
15
+ > __maintainer__ = "Berthold Höllmann"
16
+ > __email__ = "berhoel@gmail.com"
17
+
18
+
19
+ > def get_parser() -> argparse.ArgumentParser:
20
+ > """Create argument parser."""
21
+ ! parser = argparse.ArgumentParser(
22
+ ! prog="get_comics",
23
+ ! description="Download various periodic comics.",
24
+ ! )
25
+ ! parser.add_argument(
26
+ ! "--version",
27
+ ! "-V",
28
+ ! action="version",
29
+ ! version=f"%(prog)s {metadata.version('pyGetComics')}",
30
+ ! )
31
+ ! return parser
32
+
33
+
34
+ > def main(args: None | argparse.Namespace = None) -> None:
35
+ > """Get all supported comics."""
36
+ ! args = get_parser().parse_args()
37
+
38
+ ! sys.stdout.write("Get Peanuts.\n")
39
+ ! peanuts.main(args)
40
+ ! sys.stdout.write("Get Garfield.\n")
41
+ ! garfield.main(args)
42
+
43
+
44
+ > if __name__ == "__main__":
45
+ ! main()
@@ -0,0 +1,7 @@
1
+ """Allow execution of module directly."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from . import get_comics
6
+
7
+ get_comics()
@@ -0,0 +1 @@
1
+ > __version__ = "1.3.1"
@@ -0,0 +1,40 @@
1
+ """Download Garfield comic strips."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from importlib import metadata
6
+ from pathlib import Path
7
+
8
+ import click
9
+ from playwright.sync_api import sync_playwright
10
+
11
+ from berhoel.get_comics.gocomics import GoComics
12
+
13
+
14
+ class Garfield(GoComics):
15
+ """Download daily Garfield comcs fromGoComics."""
16
+
17
+ # June 19, 1978
18
+ start_year = 1978
19
+ start_month = 6
20
+ start_day = 19
21
+
22
+ garfield_path = Path.home() / "Bilder" / "Garfield"
23
+
24
+ gif_path_fmt = f"{garfield_path / '%Y' / '%m' / '%d.gif'}"
25
+ png_path_fmt = f"{garfield_path / '%Y' / '%m' / '%d.png'}"
26
+ url_fmt = "http://www.gocomics.com/garfield/%Y/%m/%d"
27
+
28
+ statefile_name = garfield_path / "garfield.statfile"
29
+
30
+
31
+ @click.command()
32
+ @click.version_option(version=f"{metadata.version('pyGetComics')}")
33
+ def get_garfield() -> None:
34
+ """Download daily Garfield comics."""
35
+ with sync_playwright() as playwright:
36
+ Garfield(playwright)()
37
+
38
+
39
+ if __name__ == "__main__":
40
+ get_garfield()
@@ -0,0 +1,61 @@
1
+ > """Download Garfield comic strips."""
2
+
3
+ > from __future__ import annotations
4
+
5
+ > import argparse
6
+ > from pathlib import Path
7
+
8
+ > from berhoel.get_comics.gocomics import GoComics
9
+
10
+ > __date__ = "2024/07/12 23:05:40 hoel"
11
+ > __author__ = "Berthold Höllmann"
12
+ > __copyright__ = "Copyright © 2017, 2022 by Berthold Höllmann"
13
+ > __credits__ = ["Berthold Höllmann"]
14
+ > __maintainer__ = "Berthold Höllmann"
15
+ > __email__ = "berhoel@gmail.com"
16
+
17
+
18
+ > class Garfield(GoComics):
19
+ > """Download daily Garfield comcs fromGoComics."""
20
+
21
+ # June 19, 1978
22
+ > start_year = 1978
23
+ > start_month = 6
24
+ > start_day = 19
25
+
26
+ > garfield_path = Path.home() / "Bilder" / "Garfield"
27
+
28
+ > gif_path_fmt = f'{garfield_path / "%Y" / "%m" / "%d.gif"}'
29
+ > png_path_fmt = f'{garfield_path / "%Y" / "%m" / "%d.png"}'
30
+ > url_fmt = "http://www.gocomics.com/garfield/%Y/%m/%d"
31
+
32
+ > statefile_name = garfield_path / "garfield.statfile"
33
+
34
+
35
+ > def get_parser() -> argparse.ArgumentParser:
36
+ > """Define argument parser."""
37
+ ! from importlib import metadata
38
+
39
+ ! parser = argparse.ArgumentParser(
40
+ ! prog="get_garfield",
41
+ ! description="Download daily Garfield comics.",
42
+ ! )
43
+ ! parser.add_argument(
44
+ ! "--version",
45
+ ! "-V",
46
+ ! action="version",
47
+ ! version=f"%(prog)s {metadata.version('pyGetComics')}",
48
+ ! )
49
+ ! return parser
50
+
51
+
52
+ > def main(args: None | argparse.Namespace = None) -> None:
53
+ > """Execute main Program."""
54
+ ! if args is None:
55
+ ! args = get_parser().parse_args()
56
+
57
+ ! Garfield()()
58
+
59
+
60
+ > if __name__ == "__main__":
61
+ ! main()
@@ -0,0 +1,7 @@
1
+ """Allow execution of module directly."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from . import get_garfield
6
+
7
+ get_garfield()
@@ -0,0 +1,105 @@
1
+ """Generate PDF from several comic PDFs."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import datetime
6
+ from enum import Enum
7
+ from pathlib import Path
8
+ import sys
9
+ from typing import TYPE_CHECKING
10
+
11
+ import jinja2
12
+
13
+ if TYPE_CHECKING:
14
+ from collections.abc import Generator
15
+
16
+
17
+ class Keep:
18
+ """Helper class."""
19
+
20
+ def __init__(self) -> None:
21
+ """Keep values."""
22
+ self.cur_month: int | None = None
23
+
24
+ def set_cur_month(self, inp: int) -> None:
25
+ """Set current month."""
26
+ self.cur_month = inp
27
+
28
+
29
+ class PaperOrientation(Enum):
30
+ """Choose paper orientation."""
31
+
32
+ PORTRAIT = 1
33
+ LANDSCAPE = 2
34
+
35
+
36
+ class GenPDF:
37
+ """Create pdf for comic collection."""
38
+
39
+ latex_jinja_env = jinja2.Environment(
40
+ block_start_string=r"\BLOCK{",
41
+ block_end_string="}",
42
+ variable_start_string=r"\VAR{",
43
+ variable_end_string="}",
44
+ comment_start_string=r"\#{",
45
+ comment_end_string="}",
46
+ line_statement_prefix="%%",
47
+ line_comment_prefix="%#",
48
+ trim_blocks=True,
49
+ autoescape=False, # noqa:S701
50
+ loader=jinja2.FileSystemLoader(Path(__file__).with_name("template")),
51
+ )
52
+
53
+ def __init__(
54
+ self,
55
+ *,
56
+ title: str,
57
+ base_path: Path,
58
+ start_date: datetime.date,
59
+ paper_orientation: PaperOrientation = PaperOrientation.PORTRAIT,
60
+ ) -> None:
61
+ """Generate PDF in comics path."""
62
+ self.title = title
63
+ self.base_path = base_path
64
+ self.start_date = start_date
65
+ self.paper_orientation = paper_orientation
66
+
67
+ def _gen_dates(
68
+ self,
69
+ start_date: datetime.date | None = None,
70
+ end_date: datetime.date | None = None,
71
+ ) -> Generator:
72
+ one_day = datetime.timedelta(days=1)
73
+ now = start_date
74
+ if now is None:
75
+ now = self.start_date
76
+ if end_date is None:
77
+ end_date = datetime.datetime.now(tz=datetime.UTC).date()
78
+ while now <= end_date:
79
+ yield now
80
+ now += one_day
81
+
82
+ def __call__(
83
+ self,
84
+ start_date: datetime.date | None = None,
85
+ end_date: datetime.date | None = None,
86
+ ) -> str:
87
+ """Control program."""
88
+ template = self.latex_jinja_env.get_template("book.tex")
89
+ gen_dates = self._gen_dates(start_date, end_date)
90
+ return template.render(
91
+ paper_orientation=self.paper_orientation == PaperOrientation.PORTRAIT,
92
+ dates=gen_dates,
93
+ base_path=self.base_path,
94
+ keep=Keep(),
95
+ )
96
+
97
+
98
+ if __name__ == "__main__":
99
+ base_path = Path.home() / "Bilder" / "Dilbert"
100
+ prog = GenPDF(
101
+ title="Dilbert",
102
+ base_path=base_path,
103
+ start_date=datetime.date(2016, 12, 20),
104
+ )
105
+ sys.stdout.write(f"{prog()}")