diff --git a/ChangeLog b/ChangeLog index 5ccaf73..f4aa8cf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,17 @@ as of 2.0.0. ## [Unreleased] +### Added +- `Publisher` ZIM metadata can now be customized at CLI (#210) + +### Changed +- `Publisher` ZIM metadata default value is changed to `openZIM` intead of `Kiwix` (#210) + +### Fixed +- Do not fail if temporary directory already exists (#207) +- Typo in `Scraper` ZIM metadata (#212) +- Adapt to hatchling v1.19.0 which mandates packages setting (#211) + ## [2.1.0] - 2023-08-18 ### Changed diff --git a/pyproject.toml b/pyproject.toml index 6cb351a..c873176 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "hatchling.build" name = "gutenberg2zim" authors = [{ name = "Kiwix", email = "dev@kiwix.org" }] keywords = ["kiwix", "zim", "offline", "gutenberg"] -requires-python = ">=3.11" +requires-python = ">=3.11,<3.12" description = "Make ZIM file from Gutenberg books" readme = "pypi-readme.rst" license = { text = "GPL-3.0-or-later" } @@ -69,6 +69,9 @@ exclude = ["/.github"] path = "hatch_build.py" dependencies = ["zimscraperlib==3.1.1"] +[tool.hatch.build.targets.wheel] +packages = ["src/gutenberg2zim"] + [tool.hatch.envs.default] features = ["dev"] diff --git a/src/gutenberg2zim/entrypoint.py b/src/gutenberg2zim/entrypoint.py index eb111bd..ebda3e8 100755 --- a/src/gutenberg2zim/entrypoint.py +++ b/src/gutenberg2zim/entrypoint.py @@ -22,7 +22,7 @@ """[--prepare] [--parse] [--download] [--export] [--dev] """ """[--zim] [--complete] [-m ONE_LANG_ONE_ZIM_FOLDER] """ """[--title-search] [--bookshelves] [--optimization-cache S3URL] """ - """[--stats-filename STATS_FILENAME]""" + """[--stats-filename STATS_FILENAME] [--publisher ZIM_PUBLISHER]""" """ -h --help Display this help message @@ -63,6 +63,7 @@ --use-any-optimized-version Try to use any optimized version found on """ """optimization cache --stats-filename= Path to store the progress JSON file to +--publisher= Custom Publisher in ZIM Metadata (openZIM otherwise) This script is used to produce a ZIM file (and any intermediate state) of Gutenberg repository using a mirror.""" @@ -102,6 +103,7 @@ def main(): optimization_cache = arguments.get("--optimization-cache") or None use_any_optimized_version = arguments.get("--use-any-optimized-version", False) stats_filename = arguments.get("--stats-filename") or None + publisher = arguments.get("--publisher") or "openZIM" s3_storage = None if optimization_cache: @@ -111,7 +113,7 @@ def main(): logger.info("S3 Credentials OK. Continuing ... ") # create tmp dir - TMP_FOLDER_PATH.mkdir(parents=True) + TMP_FOLDER_PATH.mkdir(parents=True, exist_ok=True) languages = [ x.strip().lower() @@ -224,4 +226,5 @@ def f(x): title=zim_title, description=zim_desc, stats_filename=stats_filename, + publisher=publisher, ) diff --git a/src/gutenberg2zim/shared.py b/src/gutenberg2zim/shared.py index 3f38fed..d152ebb 100644 --- a/src/gutenberg2zim/shared.py +++ b/src/gutenberg2zim/shared.py @@ -32,7 +32,7 @@ def inc_progress(): Global.progress += 1 @staticmethod - def setup(filename, language, title, description, name): + def setup(filename, language, title, description, name, publisher): Global.creator = Creator( filename=filename, main_path="Home.html", @@ -41,10 +41,10 @@ def setup(filename, language, title, description, name): title=title, description=description, creator="gutenberg.org", # type: ignore - publisher="Kiwix", # type: ignore + publisher=publisher, # type: ignore name=name, tags="_category:gutenberg;gutenberg", # type: ignore - scraper=f"gutengergtozim-{VERSION}", # type: ignore + scraper=f"gutenberg2zim-{VERSION}", # type: ignore date=date.today(), # type: ignore ).config_verbose(True) diff --git a/src/gutenberg2zim/zim.py b/src/gutenberg2zim/zim.py index 1e163e7..d6817e7 100644 --- a/src/gutenberg2zim/zim.py +++ b/src/gutenberg2zim/zim.py @@ -28,6 +28,7 @@ def build_zimfile( title, description, stats_filename, + publisher, ): # actual list of languages with books sorted by most used nb = fn.COUNT(Book.language).alias("nb") @@ -76,6 +77,7 @@ def build_zimfile( title=title, description=description, name=project_id, + publisher=publisher, ) Global.start()