python-redlines 1.0.0__py3-none-any.whl → 2.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__ = "2.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,6 +157,9 @@ 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
165
  move_similarity_threshold, move_minimum_word_count, detect_format_changes,
@@ -163,7 +181,12 @@ class BaseEngine(object):
163
181
  command = self._build_command(author_tag, original_path, modified_path, target_path, **kwargs)
164
182
 
165
183
  # Capture stdout and stderr
166
- result = subprocess.run(command, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
184
+ try:
185
+ result = subprocess.run(command, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
186
+ except subprocess.CalledProcessError as exc:
187
+ raise EngineExecutionError(
188
+ exc.returncode, exc.cmd, output=exc.output, stderr=exc.stderr,
189
+ ) from exc
167
190
 
168
191
  stdout_output = result.stdout if isinstance(result.stdout, str) and len(result.stdout) > 0 else None
169
192
  stderr_output = result.stderr if isinstance(result.stderr, str) and len(result.stderr) > 0 else None
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: python-redlines
3
- Version: 1.0.0
3
+ Version: 2.0.0
4
4
  Summary: Open-source DOCX comparison tool 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/
@@ -21,12 +21,12 @@ Classifier: Programming Language :: Python :: Implementation :: CPython
21
21
  Requires-Python: >=3.9
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==2.0.0; extra == 'all'
25
+ Requires-Dist: python-redlines-ooxmlpowertools==2.0.0; extra == 'all'
26
26
  Provides-Extra: docxodus
27
- Requires-Dist: python-redlines-docxodus; extra == 'docxodus'
27
+ Requires-Dist: python-redlines-docxodus==2.0.0; extra == 'docxodus'
28
28
  Provides-Extra: ooxmlpowertools
29
- Requires-Dist: python-redlines-ooxmlpowertools; extra == 'ooxmlpowertools'
29
+ Requires-Dist: python-redlines-ooxmlpowertools==2.0.0; extra == 'ooxmlpowertools'
30
30
  Description-Content-Type: text/markdown
31
31
 
32
32
  # python-redlines
@@ -59,8 +59,23 @@ 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
+ 2.0.0 bundles Docxodus v14.1.0. Python call signatures and supported settings
72
+ are unchanged from 1.0.0, but comparison markup and revision granularity can differ.
73
+ Review representative redlines when upgrading; see the
74
+ [2.0.0 migration guide](https://github.com/JSv4/Python-Redlines#upgrading-to-200).
75
+
76
+ An unsuccessful engine exit raises `EngineExecutionError`, a subclass of
77
+ `subprocess.CalledProcessError`. Its message includes the captured stderr and
78
+ stdout; `returncode`, `cmd`, `stdout`/`output`, and `stderr` remain available.
64
79
 
65
80
  If an engine's companion package is not installed, instantiating the engine
66
81
  raises `EngineNotInstalledError` with the `pip install` command to fix it.
@@ -0,0 +1,6 @@
1
+ python_redlines/__about__.py,sha256=Fh5eqpAhiIOZkpbNkE8nqgWqIbmudP5vwr4gPo94lF8,122
2
+ python_redlines/__init__.py,sha256=0OBU8DqF4mTPMIOlQlbY4r7l-xo5nlHRGOly11Ugq2A,437
3
+ python_redlines/engines.py,sha256=JxfaxcWmbDhFYrorM7KaS1kAzTkovd2dAvUsg-JlmEE,13812
4
+ python_redlines-2.0.0.dist-info/METADATA,sha256=EYUDsskazYG0f_16adhxMrm9eLMdBCyvbxz2f_wLjSQ,3802
5
+ python_redlines-2.0.0.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
6
+ python_redlines-2.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.32.4
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,,