diff --git a/CHANGELOG.md b/CHANGELOG.md index 32877f67..d322470a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # 1.1.0 [WIP] -* added video module +* added video module with reencode, presets, config builder and video file probing +* `make_zim_file()` accepts extra kwargs for zimwriterfs # 1.0.6 diff --git a/src/zimscraperlib/zim.py b/src/zimscraperlib/zim.py index ac3c8142..be5fe3e6 100644 --- a/src/zimscraperlib/zim.py +++ b/src/zimscraperlib/zim.py @@ -14,8 +14,6 @@ class ZimInfo(object): - zimwriterfs_path = os.getenv("ZIMWRITERFS_BINARY", "/usr/bin/zimwriterfs") - def __init__( self, homepage="home.html", @@ -100,11 +98,19 @@ def to_zimwriterfs_args( return arg_list -def make_zim_file(build_dir, output_dir, zim_fname, zim_info): - """ runs zimwriterfs """ +def make_zim_file(build_dir, output_dir, zim_fname, zim_info, **kwargs): + """ Creates a zim file using zimwriterfs + + Arguments: + build_dir: The directory to convert into a ZIM file + output_dir: The directory where the ZIM file would be saved + zim_fname: The name of the ZIM file + zim_info: An object of class ZimInfo + + **kwargs: passed directly to to_zimwriterfs_args() """ args = ( - [ZimInfo.zimwriterfs_path] - + zim_info.to_zimwriterfs_args() + ["/usr/bin/env", "zimwriterfs"] + + zim_info.to_zimwriterfs_args(**kwargs) + [str(build_dir), str(output_dir.joinpath(zim_fname))] ) diff --git a/tests/zim/test_zim.py b/tests/zim/test_zim.py index 00dd4ada..f63a89fe 100644 --- a/tests/zim/test_zim.py +++ b/tests/zim/test_zim.py @@ -82,13 +82,14 @@ def test_zimwriterfs_command(monkeypatch, ziminfo): build_dir = pathlib.Path("build") output_dir = pathlib.Path("output") zim_fname = f"{ziminfo.name}.zim" + extras = {"uniqueNamespace": True, "withoutFTIndex": True} def mock_subprocess_run(args, **kwargs): - assert len(args) == 22 + assert len(args) == 25 assert args[-1].endswith(".zim") assert args[-1] == str(output_dir.joinpath(zim_fname)) assert args[-2] == str(build_dir) return subprocess.CompletedProcess(args=args, returncode=0) monkeypatch.setattr(subprocess, "run", mock_subprocess_run) - make_zim_file(build_dir, output_dir, zim_fname, ziminfo) + make_zim_file(build_dir, output_dir, zim_fname, ziminfo, **extras)