python-redlines 1.0.0__py3-none-any.whl → 3.0.0__py3-none-any.whl

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.
@@ -1,4 +1,4 @@
1
1
  # SPDX-FileCopyrightText: 2024-present U.N. Owen <void@some.where>
2
2
  #
3
3
  # SPDX-License-Identifier: MIT
4
- __version__ = "1.0.0"
4
+ __version__ = "3.0.0"
@@ -6,6 +6,7 @@ from .__about__ import __version__
6
6
  from .engines import (
7
7
  BaseEngine,
8
8
  DocxodusEngine,
9
+ EngineExecutionError,
9
10
  EngineNotInstalledError,
10
11
  XmlPowerToolsEngine,
11
12
  )
@@ -14,6 +15,7 @@ __all__ = [
14
15
  "BaseEngine",
15
16
  "XmlPowerToolsEngine",
16
17
  "DocxodusEngine",
18
+ "EngineExecutionError",
17
19
  "EngineNotInstalledError",
18
20
  "__version__",
19
21
  ]
@@ -22,6 +22,21 @@ class EngineNotInstalledError(ImportError):
22
22
  """Raised when an engine is used but its binary package is not installed."""
23
23
 
24
24
 
25
+ class EngineExecutionError(subprocess.CalledProcessError):
26
+ """An engine exited unsuccessfully; its diagnostics appear in the message.
27
+
28
+ Retains CalledProcessError's returncode, cmd, stdout/output and stderr so
29
+ existing subprocess.CalledProcessError handlers keep working.
30
+ """
31
+
32
+ def __str__(self):
33
+ message = super().__str__()
34
+ for label, output in (("stderr", self.stderr), ("stdout", self.stdout)):
35
+ if output and output.strip():
36
+ message += f"\n{label}:\n{output.rstrip()}"
37
+ return message
38
+
39
+
25
40
  def _detect_rid() -> str:
26
41
  """Return the .NET-style runtime identifier for the current platform."""
27
42
  os_name = platform.system().lower()
@@ -142,12 +157,16 @@ class BaseEngine(object):
142
157
  A path the caller supplies is never deleted; only scratch files this
143
158
  method creates are cleaned up.
144
159
 
160
+ A nonzero engine exit raises EngineExecutionError (a CalledProcessError
161
+ subclass) with captured stderr and stdout included in its message.
162
+
145
163
  Additional keyword arguments are passed to _build_command() for engine-specific
146
164
  options. DocxodusEngine supports: case_insensitive, detect_moves,
147
- move_similarity_threshold, move_minimum_word_count, detect_format_changes,
148
- conflate_spaces, date_time. It raises ValueError for unrecognised settings and
149
- for the WmlComparer-era settings removed in Docxodus v11.0.0 (engine,
150
- detail_threshold, simplify_move_markup). XmlPowerToolsEngine ignores kwargs.
165
+ move_similarity_threshold, move_minimum_word_count, minimum_anchor_word_count,
166
+ detect_format_changes, conflate_spaces, date_time. It raises ValueError for
167
+ unrecognised settings and for the WmlComparer-era settings removed in Docxodus
168
+ v11.0.0 (engine, detail_threshold, simplify_move_markup). XmlPowerToolsEngine
169
+ ignores kwargs.
151
170
  """
152
171
  scratch_files = []
153
172
  try:
@@ -163,7 +182,12 @@ class BaseEngine(object):
163
182
  command = self._build_command(author_tag, original_path, modified_path, target_path, **kwargs)
164
183
 
165
184
  # Capture stdout and stderr
166
- result = subprocess.run(command, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
185
+ try:
186
+ result = subprocess.run(command, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
187
+ except subprocess.CalledProcessError as exc:
188
+ raise EngineExecutionError(
189
+ exc.returncode, exc.cmd, output=exc.output, stderr=exc.stderr,
190
+ ) from exc
167
191
 
168
192
  stdout_output = result.stdout if isinstance(result.stdout, str) and len(result.stdout) > 0 else None
169
193
  stderr_output = result.stderr if isinstance(result.stderr, str) and len(result.stderr) > 0 else None
@@ -265,6 +289,7 @@ class DocxodusEngine(BaseEngine):
265
289
  _VALUE_FLAGS = [
266
290
  ('move_similarity_threshold', '--move-similarity-threshold'),
267
291
  ('move_minimum_word_count', '--move-minimum-word-count'),
292
+ ('minimum_anchor_word_count', '--minimum-anchor-word-count'),
268
293
  ('date_time', '--date-time'),
269
294
  ]
270
295
 
@@ -299,6 +324,12 @@ class DocxodusEngine(BaseEngine):
299
324
  if not isinstance(val, int) or val < 1:
300
325
  raise ValueError(f"move_minimum_word_count must be a positive integer, got {val!r}")
301
326
 
327
+ if 'minimum_anchor_word_count' in kwargs:
328
+ val = kwargs['minimum_anchor_word_count']
329
+ # bool is an int subclass, but would reach the CLI as "True".
330
+ if isinstance(val, bool) or not isinstance(val, int) or val < 0:
331
+ raise ValueError(f"minimum_anchor_word_count must be a non-negative integer, got {val!r}")
332
+
302
333
  def _build_command(self, author_tag, original_path, modified_path, target_path, **kwargs):
303
334
  self._validate_kwargs(kwargs)
304
335
 
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: python-redlines
3
- Version: 1.0.0
4
- Summary: Open-source DOCX comparison tool to generate native Word tracked changes (redlines) in Python without MS Word dependencies.
3
+ Version: 3.0.0
4
+ Summary: Open-source DOCX comparison tool, powered by the Docxodus engine, to generate native Word tracked changes (redlines) in Python without MS Word dependencies.
5
5
  Project-URL: Homepage, https://github.com/JSv4/Python-Redlines
6
6
  Project-URL: Documentation, https://jsv4.github.io/Python-Redlines/
7
7
  Project-URL: Demo, https://redlines.opensource.legal
@@ -13,20 +13,20 @@ Keywords: compare-word-documents,diff,docx,docx-comparison,docxodus,legal-tech,o
13
13
  Classifier: Development Status :: 5 - Production/Stable
14
14
  Classifier: License :: OSI Approved :: MIT License
15
15
  Classifier: Programming Language :: Python
16
- Classifier: Programming Language :: Python :: 3.9
17
- Classifier: Programming Language :: Python :: 3.10
18
16
  Classifier: Programming Language :: Python :: 3.11
19
17
  Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
20
20
  Classifier: Programming Language :: Python :: Implementation :: CPython
21
- Requires-Python: >=3.9
21
+ Requires-Python: >=3.11
22
22
  Requires-Dist: platformdirs>=3.0
23
23
  Provides-Extra: all
24
- Requires-Dist: python-redlines-docxodus; extra == 'all'
25
- Requires-Dist: python-redlines-ooxmlpowertools; extra == 'all'
24
+ Requires-Dist: python-redlines-docxodus==3.0.0; extra == 'all'
25
+ Requires-Dist: python-redlines-ooxmlpowertools==3.0.0; extra == 'all'
26
26
  Provides-Extra: docxodus
27
- Requires-Dist: python-redlines-docxodus; extra == 'docxodus'
27
+ Requires-Dist: python-redlines-docxodus==3.0.0; extra == 'docxodus'
28
28
  Provides-Extra: ooxmlpowertools
29
- Requires-Dist: python-redlines-ooxmlpowertools; extra == 'ooxmlpowertools'
29
+ Requires-Dist: python-redlines-ooxmlpowertools==3.0.0; extra == 'ooxmlpowertools'
30
30
  Description-Content-Type: text/markdown
31
31
 
32
32
  # python-redlines
@@ -59,8 +59,25 @@ redline_bytes, stdout, stderr = engine.run_redline(
59
59
  )
60
60
  ```
61
61
 
62
- `DocxodusEngine` accepts `engine="wmlcomparer"` (default) or `engine="docxdiff"` to select the
63
- comparison algorithm. See the [project README](https://github.com/JSv4/Python-Redlines#choosing-an-engine).
62
+ `DocxodusEngine` runs DocxDiff. The `engine` selector was removed in 1.0.0 along
63
+ with WmlComparer. See the [project README](https://github.com/JSv4/Python-Redlines#comparison-settings-docxodusengine-only)
64
+ for supported settings.
65
+
66
+ From 2.0.0 onward, each extra pins its companion package to the same release
67
+ version as the wrapper. For older releases, pin both packages explicitly (for
68
+ example, `python-redlines[docxodus]==0.3.0` and
69
+ `python-redlines-docxodus==0.3.0`). Existing published metadata is unchanged.
70
+
71
+ 3.0.0 bundles Docxodus v17.0.0 and adds one setting, `minimum_anchor_word_count`.
72
+ Existing call signatures and settings are unchanged from 2.0.0, but comparison markup
73
+ and revision counts can differ, and some very deeply nested documents are now refused.
74
+ It requires Python 3.11 or newer; 2.0.0 was the last release to support 3.9 and 3.10.
75
+ Review representative redlines when upgrading; see the
76
+ [3.0.0 migration guide](https://github.com/JSv4/Python-Redlines#upgrading-to-300).
77
+
78
+ An unsuccessful engine exit raises `EngineExecutionError`, a subclass of
79
+ `subprocess.CalledProcessError`. Its message includes the captured stderr and
80
+ stdout; `returncode`, `cmd`, `stdout`/`output`, and `stderr` remain available.
64
81
 
65
82
  If an engine's companion package is not installed, instantiating the engine
66
83
  raises `EngineNotInstalledError` with the `pip install` command to fix it.
@@ -0,0 +1,6 @@
1
+ python_redlines/__about__.py,sha256=nWgO22hDJiotkPTVgp8C5cCKXyVKkq5krBNsu3cqGAg,122
2
+ python_redlines/__init__.py,sha256=0OBU8DqF4mTPMIOlQlbY4r7l-xo5nlHRGOly11Ugq2A,437
3
+ python_redlines/engines.py,sha256=BL0UZHibnK0FL3ruvpaPXbOIJya2FfvBrMuAX439IWA,14280
4
+ python_redlines-3.0.0.dist-info/METADATA,sha256=HctSO5vnLLjs5kA_SxIrjNSVse8CpPALJi04oYCknNI,4015
5
+ python_redlines-3.0.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
6
+ python_redlines-3.0.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.32.0
2
+ Generator: hatchling 1.33.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,6 +0,0 @@
1
- python_redlines/__about__.py,sha256=A5KBX5oBVx3aNVltn89q0cUDp6x20GTq9U79V0WpbRs,122
2
- python_redlines/__init__.py,sha256=E3FScwuaU1ybyZHfrdultE52DXFwHxm9I6zpMqeiCdc,383
3
- python_redlines/engines.py,sha256=ZHQixiLH0U0qSNLYelN_uuxLhtDf2XiCOi9PQck4MgA,12865
4
- python_redlines-1.0.0.dist-info/METADATA,sha256=iBW_i4_SLiBqr1D1FlFKyE3xPHOQF-Ezsn3ilgV_BRA,2933
5
- python_redlines-1.0.0.dist-info/WHEEL,sha256=zOwg4jB6zX2kU910N-cMawjivD6tO8NEWvE12je1bVk,87
6
- python_redlines-1.0.0.dist-info/RECORD,,