Skip to content

Commit 8d6795e

Browse files
committed
Rename auto_metadata_checks to disable_metadata_checks
1 parent 1a9b8f7 commit 8d6795e

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Added
1111

12-
- New `auto_metadata_check` parameter in `zimscraperlib.zim.creator.Creator` initializer, allowing to disable metadata check at startup (assuming the user will validate them on its own) #119
12+
- New `disable_metadata_checks` parameter in `zimscraperlib.zim.creator.Creator` initializer, allowing to disable metadata check at startup (assuming the user will validate them on its own) #119
1313

1414
### Changed
1515

src/zimscraperlib/zim/creator.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ class Creator(libzim.writer.Creator):
100100
Use workaround_nocancel=False to disable the workaround.
101101
102102
By default, all metadata are validated for compliance with openZIM guidelines and
103-
conventions. Set auto_metadata_check=False to disable this validation (you can still
104-
do checks manually with the validation methods or your own logic).
103+
conventions. Set disable_metadata_checks=False to disable this validation (you can
104+
still do checks manually with the validation methods or your own logic).
105105
"""
106106

107107
def __init__(
@@ -111,7 +111,7 @@ def __init__(
111111
compression: Optional[str] = None,
112112
workaround_nocancel: Optional[bool] = True, # noqa: FBT002
113113
ignore_duplicates: Optional[bool] = False, # noqa: FBT002
114-
auto_metadata_check: bool = True, # noqa: FBT001, FBT002
114+
disable_metadata_checks: bool = True, # noqa: FBT001, FBT002
115115
):
116116
super().__init__(filename=filename)
117117
self._metadata = {}
@@ -129,7 +129,7 @@ def __init__(
129129

130130
self.workaround_nocancel = workaround_nocancel
131131
self.ignore_duplicates = ignore_duplicates
132-
self.auto_metadata_check = auto_metadata_check
132+
self.disable_metadata_checks = disable_metadata_checks
133133

134134
def config_indexing(
135135
self, indexing: bool, language: Optional[str] = None # noqa: FBT001
@@ -148,7 +148,7 @@ def start(self):
148148
if not all(self._metadata.get(key) for key in MANDATORY_ZIM_METADATA_KEYS):
149149
raise ValueError("Mandatory metadata are not all set.")
150150

151-
if self.auto_metadata_check:
151+
if self.disable_metadata_checks:
152152
for name, value in self._metadata.items():
153153
if value:
154154
self.validate_metadata(name, value)
@@ -195,7 +195,7 @@ def add_metadata(
195195
content: Union[str, bytes, datetime.date, datetime.datetime, Iterable[str]],
196196
mimetype: str = "text/plain;charset=UTF-8",
197197
):
198-
if self.auto_metadata_check:
198+
if self.disable_metadata_checks:
199199
self.validate_metadata(name, content)
200200
if name == "Date" and isinstance(content, (datetime.date, datetime.datetime)):
201201
content = content.strftime("%Y-%m-%d").encode("UTF-8")

tests/zim/test_zim_creator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ def test_check_metadata(tmp_path):
508508

509509

510510
def test_relax_metadata(tmp_path):
511-
Creator(tmp_path, "", auto_metadata_check=False).config_dev_metadata(
511+
Creator(tmp_path, "", disable_metadata_checks=False).config_dev_metadata(
512512
Description="T" * 90
513513
).start()
514514

0 commit comments

Comments
 (0)