bindery-cli 0.57.0__tar.gz → 0.57.1__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 (56) hide show
  1. {bindery_cli-0.57.0 → bindery_cli-0.57.1}/PKG-INFO +1 -1
  2. {bindery_cli-0.57.0 → bindery_cli-0.57.1}/patchnotes.md +25 -0
  3. {bindery_cli-0.57.0 → bindery_cli-0.57.1}/pyproject.toml +1 -1
  4. {bindery_cli-0.57.0 → bindery_cli-0.57.1}/roadmap.md +1 -1
  5. {bindery_cli-0.57.0 → bindery_cli-0.57.1}/spec.md +6 -1
  6. {bindery_cli-0.57.0 → bindery_cli-0.57.1}/src/bindery/__init__.py +1 -1
  7. {bindery_cli-0.57.0 → bindery_cli-0.57.1}/src/bindery/epub.py +6 -2
  8. {bindery_cli-0.57.0 → bindery_cli-0.57.1}/tests/test_epub.py +66 -2
  9. {bindery_cli-0.57.0 → bindery_cli-0.57.1}/uv.lock +1 -1
  10. {bindery_cli-0.57.0 → bindery_cli-0.57.1}/.github/FUNDING.yml +0 -0
  11. {bindery_cli-0.57.0 → bindery_cli-0.57.1}/.github/workflows/ci.yml +0 -0
  12. {bindery_cli-0.57.0 → bindery_cli-0.57.1}/.github/workflows/publish.yml +0 -0
  13. {bindery_cli-0.57.0 → bindery_cli-0.57.1}/.gitignore +0 -0
  14. {bindery_cli-0.57.0 → bindery_cli-0.57.1}/AGENTS.md +0 -0
  15. {bindery_cli-0.57.0 → bindery_cli-0.57.1}/LICENSE +0 -0
  16. {bindery_cli-0.57.0 → bindery_cli-0.57.1}/OBSERVE-RESEARCH.md +0 -0
  17. {bindery_cli-0.57.0 → bindery_cli-0.57.1}/README.md +0 -0
  18. {bindery_cli-0.57.0 → bindery_cli-0.57.1}/docs/screenshots/library-sweep.png +0 -0
  19. {bindery_cli-0.57.0 → bindery_cli-0.57.1}/logo.svg +0 -0
  20. {bindery_cli-0.57.0 → bindery_cli-0.57.1}/plugin/__init__.py +0 -0
  21. {bindery_cli-0.57.0 → bindery_cli-0.57.1}/project.done +0 -0
  22. {bindery_cli-0.57.0 → bindery_cli-0.57.1}/run_tests.sh +0 -0
  23. {bindery_cli-0.57.0 → bindery_cli-0.57.1}/scripts/FastSweep.java +0 -0
  24. {bindery_cli-0.57.0 → bindery_cli-0.57.1}/scripts/build_plugin.py +0 -0
  25. {bindery_cli-0.57.0 → bindery_cli-0.57.1}/scripts/fast_sweep.py +0 -0
  26. {bindery_cli-0.57.0 → bindery_cli-0.57.1}/src/bindery/__main__.py +0 -0
  27. {bindery_cli-0.57.0 → bindery_cli-0.57.1}/src/bindery/audit.py +0 -0
  28. {bindery_cli-0.57.0 → bindery_cli-0.57.1}/src/bindery/cli.py +0 -0
  29. {bindery_cli-0.57.0 → bindery_cli-0.57.1}/src/bindery/library.py +0 -0
  30. {bindery_cli-0.57.0 → bindery_cli-0.57.1}/src/bindery/observe.py +0 -0
  31. {bindery_cli-0.57.0 → bindery_cli-0.57.1}/src/bindery/pagination.py +0 -0
  32. {bindery_cli-0.57.0 → bindery_cli-0.57.1}/src/bindery/reserialize.py +0 -0
  33. {bindery_cli-0.57.0 → bindery_cli-0.57.1}/src/bindery/transforms.py +0 -0
  34. {bindery_cli-0.57.0 → bindery_cli-0.57.1}/src/bindery/validate.py +0 -0
  35. {bindery_cli-0.57.0 → bindery_cli-0.57.1}/src/bindery/watermark.py +0 -0
  36. {bindery_cli-0.57.0 → bindery_cli-0.57.1}/tests/test_audit.py +0 -0
  37. {bindery_cli-0.57.0 → bindery_cli-0.57.1}/tests/test_cli.py +0 -0
  38. {bindery_cli-0.57.0 → bindery_cli-0.57.1}/tests/test_comment_hyphens.py +0 -0
  39. {bindery_cli-0.57.0 → bindery_cli-0.57.1}/tests/test_contamination.py +0 -0
  40. {bindery_cli-0.57.0 → bindery_cli-0.57.1}/tests/test_cover_tocdrift.py +0 -0
  41. {bindery_cli-0.57.0 → bindery_cli-0.57.1}/tests/test_flags_real_core.py +0 -0
  42. {bindery_cli-0.57.0 → bindery_cli-0.57.1}/tests/test_flags_wiring.py +0 -0
  43. {bindery_cli-0.57.0 → bindery_cli-0.57.1}/tests/test_help.py +0 -0
  44. {bindery_cli-0.57.0 → bindery_cli-0.57.1}/tests/test_library.py +0 -0
  45. {bindery_cli-0.57.0 → bindery_cli-0.57.1}/tests/test_matcher_hardening.py +0 -0
  46. {bindery_cli-0.57.0 → bindery_cli-0.57.1}/tests/test_observe.py +0 -0
  47. {bindery_cli-0.57.0 → bindery_cli-0.57.1}/tests/test_pagination.py +0 -0
  48. {bindery_cli-0.57.0 → bindery_cli-0.57.1}/tests/test_plugin.py +0 -0
  49. {bindery_cli-0.57.0 → bindery_cli-0.57.1}/tests/test_reserialize.py +0 -0
  50. {bindery_cli-0.57.0 → bindery_cli-0.57.1}/tests/test_space_renames.py +0 -0
  51. {bindery_cli-0.57.0 → bindery_cli-0.57.1}/tests/test_spine_guard.py +0 -0
  52. {bindery_cli-0.57.0 → bindery_cli-0.57.1}/tests/test_transforms.py +0 -0
  53. {bindery_cli-0.57.0 → bindery_cli-0.57.1}/tests/test_validate.py +0 -0
  54. {bindery_cli-0.57.0 → bindery_cli-0.57.1}/tests/test_version.py +0 -0
  55. {bindery_cli-0.57.0 → bindery_cli-0.57.1}/tests/test_watermark.py +0 -0
  56. {bindery_cli-0.57.0 → bindery_cli-0.57.1}/tests/test_xml_hardening.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: bindery-cli
3
- Version: 0.57.0
3
+ Version: 0.57.1
4
4
  Summary: Audit EPUB body text and repair broken EPUBs with deterministic, epubcheck-gated fixes; atomic in-place replacement in a Calibre library.
5
5
  Project-URL: Homepage, https://github.com/VirInvictus/bindery-cli
6
6
  Project-URL: Repository, https://github.com/VirInvictus/bindery-cli
@@ -1,5 +1,30 @@
1
1
  # bindery-cli Patch Notes
2
2
 
3
+ ## v0.57.1 (2026-10-25)
4
+
5
+ ### The prefixed dtb:uid sync: the issue #22 specimen's last finding
6
+
7
+ Same night as v0.57.0, on the follow-up call: the Hackers specimen
8
+ repaired to `0f/1e` because its residual error was NCX-001, not embed
9
+ damage. That book's 2010-era NCX spells every element with the `ncx:`
10
+ prefix (`<ncx:meta name="dtb:uid" .../>`), and the always-on sync's
11
+ matchers anchored on a literal `<meta`, so a prefixed dtb:uid carrier
12
+ was invisible: the sync skipped, and the drift survived an otherwise
13
+ clean repair. Both matchers (`_DTB_UID_RE` and the reversed
14
+ content-before-name form) now accept an optional namespace prefix on the
15
+ meta element; the group layout is unchanged (the prefix lives inside the
16
+ reconstruct group), so the quote-agnostic replacement logic is
17
+ untouched, and a prefixed element whose local name merely starts with
18
+ "meta" (the `<p:metadata>` shape) still matches nothing. The `--only
19
+ ncx` sweep selector reads the same matchers, so prefixed-NCX books with
20
+ drifted uids are now candidates too. Live gate on the specimen chain:
21
+ the scarred Hackers book now goes `1f/1e/0w -> 0f/0e/0w` in one run
22
+ (`unbound_prefixes_bound:2, ncx_uid_synced`), the exact end state the
23
+ hand repair had reached.
24
+
25
+ Suite: 793 tests.
26
+
27
+
3
28
  ## v0.57.0 (2026-10-25)
4
29
 
5
30
  ### Issue #22: the embed scar's element half, and the end of the silent equal
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "bindery-cli"
7
- version = "0.57.0"
7
+ version = "0.57.1"
8
8
  description = "Audit EPUB body text and repair broken EPUBs with deterministic, epubcheck-gated fixes; atomic in-place replacement in a Calibre library."
9
9
  readme = "README.md"
10
10
  classifiers = [
@@ -50,7 +50,7 @@ The plugin vendors the core and never gates (the epubcheck latency ruling).
50
50
  | 0.54 | The surgery fixes: `fix_ncx_playorder` is contract-gated (epubcheck's playOrder contract: same-target sharing, distinct-target distinctness, contiguous 1..K across navTarget/pageTarget; the old unconditional 1..N renumbering rewrote valid TOCs into violations, 211 of 579 firings gate-rejected vs 17 real fixes) and `_PROTECTED_RE` protects the Calibre `/*<![CDATA[*/ ... /*]]>*/` wrapper as one unit (the bare CDATA span exposed the trailing `*/` to strip_prolog_junk's amputation, 111 phantom-fix rejections); verified by the 2026-10-24 error-code surgery (OBSERVE-RESEARCH.md) | v0.54.0 |
51
51
  | 0.55 | The issue-batch release (issues #11-#16, the 2026-10-24 surgery's follow-ups): `--strip-epub3-attrs` extended with `role` + `aria-hidden` (the census killed the DOCTYPE-gate concern: epubcheck is profile-driven; #11), `--fix-duplicate-ids` for content docs (#14), `--declare-missing-items` for RSC-008 (#16, with the prune's RSC-001 boundary documented), the size-scaled epubcheck timeout with one retry and the distinct `OracleTimeout` (#15), observe schema v2 (`codes.messages` rename, true `codes.occurrences`, the `counting` block, v1 `--against` accepted; #13), the #12 content-model ruling (measured, not repaired: the wrap changes layout), and the #17 census lanes (RSC-012/OPF-029 dispositions on existing flags; OPF-030/CSS-007/RSC-004 recorded leave-measured with recipes) | v0.55.0 |
52
52
  | 0.56 | The boxed recipes, built same-day on the follow-up call: `--fix-unique-identifier` (the OPF-030 recipe: wire the package's named id onto the first dc:identifier, refuses every ambiguous shape, and predicts the post-wiring uid so the NCX sync the broken wiring was masking fires in the same run -- eagle 2e -> 1e accept) and the CSS-007 font half inside `--fix-media-types` (font/* blessed on both package versions, magic confirmed, .eot never touched; accepted under no_worse because the gain sits on the INFO axis -- Brave New World 8 fonts normalized, CSS-007 cleared) | v0.56.0 |
53
- | 0.57 | The embed scar's element half and the end of the silent equal (issue #22): `--fix-unbound-prefix` now binds an unbound ELEMENT prefix inline (the 9.7.0 writer self-declares xmlns:dc on every dc: element but one; rule 2 for a literal dc: element resolves to the DC namespace itself; Hackers 1f/1e -> 0f/1e with both binds in one run, and the half-repaired intermediate that read equal now repairs), and the masked-axis reclassification generalizes from the v0.51.0 NCX sync to every fired fix: a gate noop on a book that started and stayed fatal reads partial (the manual list) instead of a silent equal; the ncx:-prefixed dtb:uid sync gap found on the specimen is recorded, not repaired | v0.57.0 |
53
+ | 0.57 | The embed scar's element half and the end of the silent equal (issue #22): `--fix-unbound-prefix` now binds an unbound ELEMENT prefix inline (the 9.7.0 writer self-declares xmlns:dc on every dc: element but one; rule 2 for a literal dc: element resolves to the DC namespace itself; Hackers 1f/1e -> 0f/1e with both binds in one run, and the half-repaired intermediate that read equal now repairs), and the masked-axis reclassification generalizes from the v0.51.0 NCX sync to every fired fix: a gate noop on a book that started and stayed fatal reads partial (the manual list) instead of a silent equal; the specimen's residual ncx:-prefixed dtb:uid gap shipped as the v0.57.1 patch (both matchers read a prefixed `<ncx:meta>` carrier; Hackers fully clean 0f/0e/0w) | v0.57.0-v0.57.1 |
54
54
 
55
55
  ## Open work
56
56
 
@@ -70,7 +70,12 @@ Applied to content documents (`.xhtml`, `.html`, `.htm`, `.xml`), in order:
70
70
 
71
71
  Applied to the NCX sidecar (`.ncx`): strip_prolog_junk, escape_bare_amp,
72
72
  fix_named_entities, plus **dtb:uid sync** (rewriting the NCX's `dtb:uid`
73
- meta to match the OPF's unique identifier when they drift, NCX-001) and
73
+ meta to match the OPF's unique identifier when they drift, NCX-001; the
74
+ matcher reads the meta under a namespace prefix too since v0.57.1 --
75
+ 2010-era producers spell every element `<ncx:meta>`, and a prefixed
76
+ `dtb:uid` carrier used to survive an otherwise-clean repair as the
77
+ book's last finding -- and the `--only ncx` selector reads the same
78
+ matchers) and
74
79
  **fix_ncx_playorder** (resequencing `playOrder` values so the NCX
75
80
  satisfies epubcheck's playOrder contract: elements whose `<content src>`
76
81
  point at the same target share one value, distinct targets carry distinct
@@ -11,7 +11,7 @@ Calibre plugin built from this core.
11
11
  Single source of truth for the version. pyproject.toml must match VERSION below.
12
12
  """
13
13
 
14
- VERSION = "0.57.0"
14
+ VERSION = "0.57.1"
15
15
  __version__ = VERSION
16
16
 
17
17
  from .epub import RepairReport, repair_epub # noqa: E402
@@ -233,12 +233,16 @@ def fix_ncx_ids(ncx_text: str) -> tuple[str, int]:
233
233
 
234
234
  # Both accept single or double quotes; group 3 is the uid value and group(1)+group(4)
235
235
  # reconstruct everything around it, so the replacement logic is quote-agnostic too.
236
+ # The element may carry a namespace prefix: the 2010-era O'Reilly NCX spellings
237
+ # every element as <ncx:meta> (v0.57.1, the issue #22 specimen's residual
238
+ # NCX-001). The prefix group needs its trailing colon, so it cannot swallow
239
+ # into the [^>]* runs, and a failing split re-parts only within the tag name.
236
240
  _DTB_UID_RE = re.compile(
237
- r"(<meta\b[^>]*\bname=[\"']dtb:uid[\"'][^>]*\bcontent=([\"']))((?:(?!\2).)*)(\2)",
241
+ r"(<(?:[A-Za-z_][\w.:-]*:)?meta\b[^>]*\bname=[\"']dtb:uid[\"'][^>]*\bcontent=([\"']))((?:(?!\2).)*)(\2)",
238
242
  re.IGNORECASE,
239
243
  )
240
244
  _DTB_UID_RE_REV = re.compile(
241
- r"(<meta\b[^>]*\bcontent=([\"']))((?:(?!\2).)*)"
245
+ r"(<(?:[A-Za-z_][\w.:-]*:)?meta\b[^>]*\bcontent=([\"']))((?:(?!\2).)*)"
242
246
  r"(\2[^>]*\bname=[\"']dtb:uid[\"'][^>]*>)",
243
247
  re.IGNORECASE,
244
248
  )
@@ -41,6 +41,15 @@ NCX_BAD = (
41
41
  '<meta name="dtb:uid" content="urn:uuid:THE-WRONG-ID"/>'
42
42
  "</head></ncx>"
43
43
  )
44
+ # The Hackers spelling (issue #22's residual NCX-001): every element
45
+ # carries the ncx: prefix, including the dtb:uid meta.
46
+ NCX_BAD_PREFIXED = (
47
+ '<?xml version="1.0"?>'
48
+ '<ncx:ncx xmlns:ncx="http://www.daisy.org/z3986/2005/ncx/" version="2005-1">'
49
+ "<ncx:head>"
50
+ '<ncx:meta name="dtb:uid" content="urn:uuid:THE-WRONG-ID"/>'
51
+ "</ncx:head></ncx:ncx>"
52
+ )
44
53
  CONTENT = (
45
54
  '<?xml version="1.0"?>'
46
55
  '<html xmlns="http://www.w3.org/1999/xhtml"><head>'
@@ -78,6 +87,58 @@ class TestParts(unittest.TestCase):
78
87
  self.assertTrue(changed)
79
88
  self.assertIn(f'content="{uid}"', out)
80
89
 
90
+ def test_sync_ncx_uid_prefixed_meta(self):
91
+ # v0.57.1 (issue #22 follow-up): the 2010-era NCX spellings every
92
+ # element as <ncx:meta>; the sync reads and rewrites the dtb:uid
93
+ # there exactly as on the unprefixed shape.
94
+ out, changed = sync_ncx_uid(NCX_BAD_PREFIXED, "urn:uuid:THE-RIGHT-ID")
95
+ self.assertTrue(changed)
96
+ self.assertIn('content="urn:uuid:THE-RIGHT-ID"', out)
97
+ _, changed2 = sync_ncx_uid(out, "urn:uuid:THE-RIGHT-ID")
98
+ self.assertFalse(changed2)
99
+
100
+ def test_prefixed_meta_rev_order(self):
101
+ # content before name, under the prefix: the reversed-order matcher
102
+ # carries the same prefix extension.
103
+ ncx = (
104
+ '<ncx:ncx xmlns:ncx="http://www.daisy.org/z3986/2005/ncx/"><ncx:head>'
105
+ '<ncx:meta content="urn:uuid:THE-WRONG-ID" name="dtb:uid"/>'
106
+ "</ncx:head></ncx:ncx>"
107
+ )
108
+ out, changed = sync_ncx_uid(ncx, "urn:uuid:THE-RIGHT-ID")
109
+ self.assertTrue(changed)
110
+ self.assertIn('content="urn:uuid:THE-RIGHT-ID"', out)
111
+ ET.fromstring(out)
112
+
113
+ def test_prefixed_meta_no_false_positives(self):
114
+ # A prefixed element whose local name merely starts with "meta"
115
+ # (metadata) is not a dtb:uid carrier, prefix or not.
116
+ ncx = (
117
+ '<p:package xmlns:p="urn:x"><p:head>'
118
+ '<p:metadata name="dtb:uid" content="urn:uuid:THE-WRONG-ID"/>'
119
+ "</p:head></p:package>"
120
+ )
121
+ self.assertEqual(sync_ncx_uid(ncx, "urn:uuid:OTHER"), (ncx, False))
122
+
123
+ def test_ncx_uid_mismatch_prefixed(self):
124
+ # The --only ncx selector reads the same matchers: a prefixed-NCX
125
+ # book with a drifted uid is a candidate, an in-sync one is not.
126
+ with tempfile.TemporaryDirectory() as td:
127
+ src = Path(td) / "in.epub"
128
+ with zipfile.ZipFile(src, "w") as z:
129
+ z.writestr("OEBPS/c1.xhtml", CONTENT)
130
+ z.writestr("OEBPS/toc.ncx", NCX_BAD_PREFIXED)
131
+ z.writestr("OEBPS/content.opf", OPF)
132
+ self.assertTrue(ncx_uid_mismatch(src))
133
+ out, changed = sync_ncx_uid(NCX_BAD_PREFIXED, "urn:uuid:THE-RIGHT-ID")
134
+ self.assertTrue(changed)
135
+ src2 = Path(td) / "synced.epub"
136
+ with zipfile.ZipFile(src2, "w") as z:
137
+ z.writestr("OEBPS/c1.xhtml", CONTENT)
138
+ z.writestr("OEBPS/toc.ncx", out)
139
+ z.writestr("OEBPS/content.opf", OPF)
140
+ self.assertFalse(ncx_uid_mismatch(src2))
141
+
81
142
 
82
143
  class TestManifestIds(unittest.TestCase):
83
144
  def test_digit_led_ids_renamed_with_refs(self):
@@ -2394,18 +2455,21 @@ class TestUnboundPrefix(unittest.TestCase):
2394
2455
  with zipfile.ZipFile(src, "w") as z:
2395
2456
  z.writestr("mimetype", "application/epub+zip")
2396
2457
  z.writestr("OEBPS/c1.xhtml", CONTENT)
2397
- z.writestr("OEBPS/toc.ncx", NCX_BAD)
2458
+ # the real specimen's NCX is prefixed throughout (v0.57.1)
2459
+ z.writestr("OEBPS/toc.ncx", NCX_BAD_PREFIXED)
2398
2460
  z.writestr("OEBPS/content.opf", EMBED_SCARRED_OPF)
2399
2461
  return src, dst
2400
2462
 
2401
2463
  def test_embed_scar_element_and_attribute_bound(self):
2402
2464
  # Issue #22: one run binds both halves of the 9.7.0 scar. On the
2403
2465
  # specimen each fix alone left the other masked behind a still-fatal
2404
- # package (1f/1e -> 1f/0e); together they parse it clean.
2466
+ # package (1f/1e -> 1f/0e); together they parse it clean. The NCX
2467
+ # sync fires on the specimen's prefixed meta spelling (v0.57.1).
2405
2468
  with tempfile.TemporaryDirectory() as td:
2406
2469
  src, dst = self._build_embed_scar(td)
2407
2470
  report = repair_epub(src, dst, RepairFlags(unbound_prefix=True))
2408
2471
  self.assertEqual(report.fixes.get("unbound_prefixes_bound"), 2)
2472
+ self.assertTrue(report.ncx_uid_synced)
2409
2473
  with zipfile.ZipFile(dst) as z:
2410
2474
  opf = z.read("OEBPS/content.opf").decode()
2411
2475
  self.assertIn(
@@ -8,7 +8,7 @@ resolution-markers = [
8
8
 
9
9
  [[package]]
10
10
  name = "bindery-cli"
11
- version = "0.57.0"
11
+ version = "0.57.1"
12
12
  source = { editable = "." }
13
13
  dependencies = [
14
14
  { name = "cquarry", marker = "python_full_version >= '3.14'" },
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes