wolfdocx 0.1.0__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 (86) hide show
  1. wolfdocx-0.1.0/.gitignore +21 -0
  2. wolfdocx-0.1.0/CHANGELOG.md +21 -0
  3. wolfdocx-0.1.0/LICENSE +21 -0
  4. wolfdocx-0.1.0/PKG-INFO +127 -0
  5. wolfdocx-0.1.0/PROVENANCE.md +8 -0
  6. wolfdocx-0.1.0/README.md +93 -0
  7. wolfdocx-0.1.0/SECURITY.md +20 -0
  8. wolfdocx-0.1.0/pyproject.toml +83 -0
  9. wolfdocx-0.1.0/src/wolfdocx/__init__.py +25 -0
  10. wolfdocx-0.1.0/src/wolfdocx/_cache_root.py +24 -0
  11. wolfdocx-0.1.0/src/wolfdocx/_comment_threads.py +278 -0
  12. wolfdocx-0.1.0/src/wolfdocx/_inspection_cache.py +374 -0
  13. wolfdocx-0.1.0/src/wolfdocx/_version.py +3 -0
  14. wolfdocx-0.1.0/src/wolfdocx/admission.py +163 -0
  15. wolfdocx-0.1.0/src/wolfdocx/assembly.py +463 -0
  16. wolfdocx-0.1.0/src/wolfdocx/authoring.py +2773 -0
  17. wolfdocx-0.1.0/src/wolfdocx/canonical.py +267 -0
  18. wolfdocx-0.1.0/src/wolfdocx/content.py +963 -0
  19. wolfdocx-0.1.0/src/wolfdocx/document.py +215 -0
  20. wolfdocx-0.1.0/src/wolfdocx/errors.py +169 -0
  21. wolfdocx-0.1.0/src/wolfdocx/find_replace.py +1210 -0
  22. wolfdocx-0.1.0/src/wolfdocx/formatting.py +3160 -0
  23. wolfdocx-0.1.0/src/wolfdocx/inspect.py +3999 -0
  24. wolfdocx-0.1.0/src/wolfdocx/model.py +1038 -0
  25. wolfdocx-0.1.0/src/wolfdocx/numbering_authoring.py +1422 -0
  26. wolfdocx-0.1.0/src/wolfdocx/output.py +13 -0
  27. wolfdocx-0.1.0/src/wolfdocx/package.py +2313 -0
  28. wolfdocx-0.1.0/src/wolfdocx/package_profile.py +128 -0
  29. wolfdocx-0.1.0/src/wolfdocx/page_setup.py +2483 -0
  30. wolfdocx-0.1.0/src/wolfdocx/paragraph_authoring.py +1842 -0
  31. wolfdocx-0.1.0/src/wolfdocx/properties.py +2728 -0
  32. wolfdocx-0.1.0/src/wolfdocx/protection.py +1909 -0
  33. wolfdocx-0.1.0/src/wolfdocx/regions.py +1993 -0
  34. wolfdocx-0.1.0/src/wolfdocx/render_warnings.py +106 -0
  35. wolfdocx-0.1.0/src/wolfdocx/reporting.py +943 -0
  36. wolfdocx-0.1.0/src/wolfdocx/review.py +2862 -0
  37. wolfdocx-0.1.0/src/wolfdocx/run_text.py +117 -0
  38. wolfdocx-0.1.0/src/wolfdocx/section_break.py +1810 -0
  39. wolfdocx-0.1.0/src/wolfdocx/session_ops/__init__.py +45 -0
  40. wolfdocx-0.1.0/src/wolfdocx/session_ops/_bridge.py +151 -0
  41. wolfdocx-0.1.0/src/wolfdocx/session_ops/lists.py +104 -0
  42. wolfdocx-0.1.0/src/wolfdocx/session_ops/paragraphs.py +39 -0
  43. wolfdocx-0.1.0/src/wolfdocx/session_ops/rich_objects.py +2598 -0
  44. wolfdocx-0.1.0/src/wolfdocx/session_ops/run_edits.py +70 -0
  45. wolfdocx-0.1.0/src/wolfdocx/session_ops/runs.py +313 -0
  46. wolfdocx-0.1.0/src/wolfdocx/session_ops/sections.py +109 -0
  47. wolfdocx-0.1.0/src/wolfdocx/session_ops/styling.py +99 -0
  48. wolfdocx-0.1.0/src/wolfdocx/session_ops/tables.py +247 -0
  49. wolfdocx-0.1.0/src/wolfdocx/styles_authoring.py +2822 -0
  50. wolfdocx-0.1.0/src/wolfdocx/table_cell_properties.py +1458 -0
  51. wolfdocx-0.1.0/src/wolfdocx/table_column.py +1501 -0
  52. wolfdocx-0.1.0/src/wolfdocx/table_delete.py +942 -0
  53. wolfdocx-0.1.0/src/wolfdocx/table_insert.py +1114 -0
  54. wolfdocx-0.1.0/src/wolfdocx/table_merge.py +1863 -0
  55. wolfdocx-0.1.0/src/wolfdocx/table_properties.py +2429 -0
  56. wolfdocx-0.1.0/src/wolfdocx/table_row_properties.py +1095 -0
  57. wolfdocx-0.1.0/src/wolfdocx/table_structure.py +1044 -0
  58. wolfdocx-0.1.0/src/wolfdocx/text_effects.py +1438 -0
  59. wolfdocx-0.1.0/tests/__init__.py +0 -0
  60. wolfdocx-0.1.0/tests/conftest.py +9 -0
  61. wolfdocx-0.1.0/tests/docx_fixtures.py +590 -0
  62. wolfdocx-0.1.0/tests/test_authoring_cells.py +396 -0
  63. wolfdocx-0.1.0/tests/test_authoring_page_setup.py +1302 -0
  64. wolfdocx-0.1.0/tests/test_authoring_regions.py +1541 -0
  65. wolfdocx-0.1.0/tests/test_authoring_section_break.py +2296 -0
  66. wolfdocx-0.1.0/tests/test_authoring_spans.py +380 -0
  67. wolfdocx-0.1.0/tests/test_authoring_table_cell_properties.py +1314 -0
  68. wolfdocx-0.1.0/tests/test_authoring_table_insert.py +639 -0
  69. wolfdocx-0.1.0/tests/test_authoring_table_merge.py +1203 -0
  70. wolfdocx-0.1.0/tests/test_authoring_table_properties.py +1858 -0
  71. wolfdocx-0.1.0/tests/test_authoring_table_row_properties.py +865 -0
  72. wolfdocx-0.1.0/tests/test_authoring_table_structure.py +1149 -0
  73. wolfdocx-0.1.0/tests/test_document_session.py +303 -0
  74. wolfdocx-0.1.0/tests/test_document_session_paragraphs.py +462 -0
  75. wolfdocx-0.1.0/tests/test_find_replace.py +684 -0
  76. wolfdocx-0.1.0/tests/test_find_replace_no_match.py +238 -0
  77. wolfdocx-0.1.0/tests/test_find_replace_portfolio_edits.py +234 -0
  78. wolfdocx-0.1.0/tests/test_inspect.py +472 -0
  79. wolfdocx-0.1.0/tests/test_node_visitor.py +346 -0
  80. wolfdocx-0.1.0/tests/test_package_graph.py +515 -0
  81. wolfdocx-0.1.0/tests/test_package_open_tolerance.py +295 -0
  82. wolfdocx-0.1.0/tests/test_package_profile.py +117 -0
  83. wolfdocx-0.1.0/tests/test_paragraph_authoring.py +2827 -0
  84. wolfdocx-0.1.0/tests/test_run_text_edit.py +269 -0
  85. wolfdocx-0.1.0/tests/test_table_column.py +856 -0
  86. wolfdocx-0.1.0/tests/test_table_delete.py +848 -0
@@ -0,0 +1,21 @@
1
+ # Virtual environments
2
+ .venv*/
3
+ venv/
4
+ env/
5
+
6
+ # Build output
7
+ build/
8
+ dist/
9
+ *.egg-info/
10
+
11
+ # Python caches
12
+ __pycache__/
13
+ *.py[cod]
14
+ .pytest_cache/
15
+ .ruff_cache/
16
+ .mypy_cache/
17
+ .coverage
18
+ htmlcov/
19
+
20
+ # OS files
21
+ .DS_Store
@@ -0,0 +1,21 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented in this file. The format is
4
+ based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project
5
+ follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [0.1.0] - 2026-10-29
8
+
9
+ ### Added
10
+
11
+ - First public release under the MIT license.
12
+ - `Document` session for opening an existing `.docx`, with in-memory edits
13
+ published only by `save`.
14
+ - Node navigation through `Document.node` for reading stories, paragraphs, runs,
15
+ and tables.
16
+ - Edits: `set_run_text`, `find_replace`, `append_paragraph`, and related session
17
+ operations.
18
+ - Verified, no-clobber saves that copy every untouched package part byte-for-byte
19
+ and report changed and raw-copied parts.
20
+
21
+ [0.1.0]: https://github.com/wolfiesch/wolfdocx-oss/releases/tag/v0.1.0
wolfdocx-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Wolfgang Schoenberger
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,127 @@
1
+ Metadata-Version: 2.5
2
+ Name: wolfdocx
3
+ Version: 0.1.0
4
+ Summary: Read, write, and edit Word .docx files in Python. A python-docx alternative that edits documents in place and keeps every untouched part byte-for-byte identical. Pure Python, MIT licensed.
5
+ Project-URL: Homepage, https://wolfdocx.com
6
+ Project-URL: Repository, https://github.com/wolfiesch/wolfdocx-oss
7
+ Project-URL: Issues, https://github.com/wolfiesch/wolfdocx-oss/issues
8
+ Project-URL: Changelog, https://github.com/wolfiesch/wolfdocx-oss/blob/main/CHANGELOG.md
9
+ Author: Wolfgang Schoenberger
10
+ License-Expression: MIT
11
+ License-File: LICENSE
12
+ Keywords: create-docx,document,docx,edit-docx,office,office-automation,openxml,python-docx,python-docx-alternative,reporting,word
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3 :: Only
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Programming Language :: Python :: 3.14
23
+ Classifier: Topic :: Office/Business :: Office Suites
24
+ Classifier: Topic :: Software Development :: Libraries
25
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
26
+ Classifier: Topic :: Text Processing
27
+ Requires-Python: >=3.11
28
+ Provides-Extra: dev
29
+ Requires-Dist: build>=1.2; extra == 'dev'
30
+ Requires-Dist: pytest>=8.3; extra == 'dev'
31
+ Requires-Dist: ruff>=0.12; extra == 'dev'
32
+ Requires-Dist: twine>=6.1; extra == 'dev'
33
+ Description-Content-Type: text/markdown
34
+
35
+ # wolfdocx
36
+
37
+ Edit .docx files in Python. wolfdocx is a python-docx alternative that opens an
38
+ existing Word document, applies your edits in place, and saves a new package where
39
+ every part you did not touch is copied byte-for-byte from the original.
40
+
41
+ - Pure Python, no runtime dependencies.
42
+ - Python 3.11 or newer.
43
+ - MIT licensed.
44
+
45
+ ## Install
46
+
47
+ ```bash
48
+ pip install wolfdocx
49
+ ```
50
+
51
+ ## Quickstart
52
+
53
+ Open an existing `.docx`, read its paragraphs and tables, make a few edits, and save
54
+ the result to a new file.
55
+
56
+ ```python
57
+ from wolfdocx import Document
58
+
59
+ with Document("contract.docx") as doc:
60
+ # The first story under doc.node is the main document body.
61
+ body = doc.node.children[0]
62
+
63
+ for paragraph in body.paragraphs:
64
+ print(paragraph.to_string("txt").rstrip("\n"))
65
+
66
+ for table in body.tables:
67
+ print(table.to_string("txt"))
68
+
69
+ # Replace the text of one run. Paragraph and run indices are zero-based and
70
+ # count the direct paragraphs of the body and the direct runs of that paragraph.
71
+ first_run = body.paragraphs[0].runs[0]
72
+ doc.set_run_text(0, 0, "Master Services Agreement", expected_old_text=first_run.text)
73
+
74
+ # Regular-expression find and replace across runs.
75
+ replaced = doc.find_replace(r"ACME Corp\.?", "Acme Corporation")
76
+ print(replaced.status, replaced.replacement_count)
77
+
78
+ # Add a plain paragraph after the last body paragraph.
79
+ added = doc.append_paragraph("Signed electronically.")
80
+ print(added.status)
81
+
82
+ report = doc.save("contract-edited.docx")
83
+ print(report.status, report.changed_parts, report.raw_copied_parts)
84
+ ```
85
+
86
+ Edits are held in memory until `save(path)` writes a new file, and `doc.node` is a
87
+ snapshot: read it again after an edit to see the updated tree.
88
+
89
+ ## When to use WolfDocx instead of python-docx
90
+
91
+ Use WolfDocx when you need targeted edits to an existing document and want every
92
+ untouched package part to remain byte-for-byte identical.
93
+
94
+ - **In-place edits.** Each edit rewrites only the XML part it targets. Run
95
+ properties, attributes, and neighboring markup stay where they were.
96
+ - **Byte-for-byte preservation.** On save, every package part you did not change is
97
+ copied from the source archive unchanged. `report.changed_parts` lists the parts
98
+ that were rewritten and `report.raw_copied_parts` counts the parts copied as-is.
99
+ - **Verified, no-clobber saves.** The output is staged and checked before it is
100
+ published. `save` refuses to replace an existing file and reports
101
+ `status == "refused"` with a `code` explaining why.
102
+ - **Explicit refusals.** An edit that cannot be applied safely, such as a
103
+ `find_replace` pattern with no match, returns a report with `status == "refused"`
104
+ and leaves the document unchanged. `set_run_text` raises `RunTextEditError` for
105
+ bad indices or an `expected_old_text` mismatch.
106
+
107
+ wolfdocx works on `.docx` packages. It does not render pages, convert to PDF, or
108
+ read legacy binary `.doc` files.
109
+
110
+ ## Commercial capabilities
111
+
112
+ Commercial capabilities are available at https://wolfdocx.com.
113
+
114
+ ## Contributing
115
+
116
+ ```bash
117
+ python -m pip install -e ".[dev]"
118
+ ruff check .
119
+ python -m pytest
120
+ ```
121
+
122
+ Report bugs at https://github.com/wolfiesch/wolfdocx-oss/issues. For security
123
+ issues, see [SECURITY.md](SECURITY.md).
124
+
125
+ ## License
126
+
127
+ MIT. See [LICENSE](LICENSE).
@@ -0,0 +1,8 @@
1
+ # Provenance
2
+
3
+ wolfdocx 0.1.0 was extracted from the author's private source repository at commit
4
+ `91c631ac`. The `src/wolfdocx` package and its `tests` were taken from that commit
5
+ and reduced to the pure-Python, MIT-licensed subset published here.
6
+
7
+ All code in this repository is released under the MIT license. See
8
+ [LICENSE](LICENSE).
@@ -0,0 +1,93 @@
1
+ # wolfdocx
2
+
3
+ Edit .docx files in Python. wolfdocx is a python-docx alternative that opens an
4
+ existing Word document, applies your edits in place, and saves a new package where
5
+ every part you did not touch is copied byte-for-byte from the original.
6
+
7
+ - Pure Python, no runtime dependencies.
8
+ - Python 3.11 or newer.
9
+ - MIT licensed.
10
+
11
+ ## Install
12
+
13
+ ```bash
14
+ pip install wolfdocx
15
+ ```
16
+
17
+ ## Quickstart
18
+
19
+ Open an existing `.docx`, read its paragraphs and tables, make a few edits, and save
20
+ the result to a new file.
21
+
22
+ ```python
23
+ from wolfdocx import Document
24
+
25
+ with Document("contract.docx") as doc:
26
+ # The first story under doc.node is the main document body.
27
+ body = doc.node.children[0]
28
+
29
+ for paragraph in body.paragraphs:
30
+ print(paragraph.to_string("txt").rstrip("\n"))
31
+
32
+ for table in body.tables:
33
+ print(table.to_string("txt"))
34
+
35
+ # Replace the text of one run. Paragraph and run indices are zero-based and
36
+ # count the direct paragraphs of the body and the direct runs of that paragraph.
37
+ first_run = body.paragraphs[0].runs[0]
38
+ doc.set_run_text(0, 0, "Master Services Agreement", expected_old_text=first_run.text)
39
+
40
+ # Regular-expression find and replace across runs.
41
+ replaced = doc.find_replace(r"ACME Corp\.?", "Acme Corporation")
42
+ print(replaced.status, replaced.replacement_count)
43
+
44
+ # Add a plain paragraph after the last body paragraph.
45
+ added = doc.append_paragraph("Signed electronically.")
46
+ print(added.status)
47
+
48
+ report = doc.save("contract-edited.docx")
49
+ print(report.status, report.changed_parts, report.raw_copied_parts)
50
+ ```
51
+
52
+ Edits are held in memory until `save(path)` writes a new file, and `doc.node` is a
53
+ snapshot: read it again after an edit to see the updated tree.
54
+
55
+ ## When to use WolfDocx instead of python-docx
56
+
57
+ Use WolfDocx when you need targeted edits to an existing document and want every
58
+ untouched package part to remain byte-for-byte identical.
59
+
60
+ - **In-place edits.** Each edit rewrites only the XML part it targets. Run
61
+ properties, attributes, and neighboring markup stay where they were.
62
+ - **Byte-for-byte preservation.** On save, every package part you did not change is
63
+ copied from the source archive unchanged. `report.changed_parts` lists the parts
64
+ that were rewritten and `report.raw_copied_parts` counts the parts copied as-is.
65
+ - **Verified, no-clobber saves.** The output is staged and checked before it is
66
+ published. `save` refuses to replace an existing file and reports
67
+ `status == "refused"` with a `code` explaining why.
68
+ - **Explicit refusals.** An edit that cannot be applied safely, such as a
69
+ `find_replace` pattern with no match, returns a report with `status == "refused"`
70
+ and leaves the document unchanged. `set_run_text` raises `RunTextEditError` for
71
+ bad indices or an `expected_old_text` mismatch.
72
+
73
+ wolfdocx works on `.docx` packages. It does not render pages, convert to PDF, or
74
+ read legacy binary `.doc` files.
75
+
76
+ ## Commercial capabilities
77
+
78
+ Commercial capabilities are available at https://wolfdocx.com.
79
+
80
+ ## Contributing
81
+
82
+ ```bash
83
+ python -m pip install -e ".[dev]"
84
+ ruff check .
85
+ python -m pytest
86
+ ```
87
+
88
+ Report bugs at https://github.com/wolfiesch/wolfdocx-oss/issues. For security
89
+ issues, see [SECURITY.md](SECURITY.md).
90
+
91
+ ## License
92
+
93
+ MIT. See [LICENSE](LICENSE).
@@ -0,0 +1,20 @@
1
+ # Security Policy
2
+
3
+ ## Supported versions
4
+
5
+ | Version | Supported |
6
+ | ------- | --------- |
7
+ | 0.1.x | Yes |
8
+
9
+ ## Reporting a vulnerability
10
+
11
+ Please report vulnerabilities privately through GitHub Security Advisories:
12
+ https://github.com/wolfiesch/wolfdocx-oss/security/advisories/new
13
+
14
+ Do not open a public issue for a suspected vulnerability. Include the wolfdocx
15
+ version, the Python version, a description of the impact, and a minimal `.docx` or
16
+ script that reproduces the problem when you can share one safely.
17
+
18
+ You can expect an acknowledgement within a few business days. Fixes are released as
19
+ patch versions and disclosed through a published advisory once a fixed release is
20
+ available.
@@ -0,0 +1,83 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.27"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "wolfdocx"
7
+ version = "0.1.0"
8
+ description = "Read, write, and edit Word .docx files in Python. A python-docx alternative that edits documents in place and keeps every untouched part byte-for-byte identical. Pure Python, MIT licensed."
9
+ readme = "README.md"
10
+ requires-python = ">=3.11"
11
+ license = "MIT"
12
+ license-files = ["LICENSE"]
13
+ authors = [{ name = "Wolfgang Schoenberger" }]
14
+ dependencies = []
15
+ keywords = [
16
+ "word",
17
+ "docx",
18
+ "python-docx",
19
+ "python-docx-alternative",
20
+ "edit-docx",
21
+ "create-docx",
22
+ "openxml",
23
+ "office",
24
+ "office-automation",
25
+ "reporting",
26
+ "document",
27
+ ]
28
+ classifiers = [
29
+ "Development Status :: 4 - Beta",
30
+ "Intended Audience :: Developers",
31
+ "License :: OSI Approved :: MIT License",
32
+ "Operating System :: OS Independent",
33
+ "Programming Language :: Python :: 3",
34
+ "Programming Language :: Python :: 3 :: Only",
35
+ "Programming Language :: Python :: 3.11",
36
+ "Programming Language :: Python :: 3.12",
37
+ "Programming Language :: Python :: 3.13",
38
+ "Programming Language :: Python :: 3.14",
39
+ "Topic :: Office/Business :: Office Suites",
40
+ "Topic :: Text Processing",
41
+ "Topic :: Software Development :: Libraries",
42
+ "Topic :: Software Development :: Libraries :: Python Modules",
43
+ ]
44
+
45
+ [project.optional-dependencies]
46
+ dev = [
47
+ "build>=1.2",
48
+ "pytest>=8.3",
49
+ "ruff>=0.12",
50
+ "twine>=6.1",
51
+ ]
52
+
53
+ [project.urls]
54
+ Homepage = "https://wolfdocx.com"
55
+ Repository = "https://github.com/wolfiesch/wolfdocx-oss"
56
+ Issues = "https://github.com/wolfiesch/wolfdocx-oss/issues"
57
+ Changelog = "https://github.com/wolfiesch/wolfdocx-oss/blob/main/CHANGELOG.md"
58
+
59
+ [tool.hatch.build.targets.wheel]
60
+ packages = ["src/wolfdocx"]
61
+
62
+ [tool.hatch.build.targets.sdist]
63
+ include = [
64
+ "/src",
65
+ "/tests",
66
+ "/CHANGELOG.md",
67
+ "/LICENSE",
68
+ "/PROVENANCE.md",
69
+ "/README.md",
70
+ "/SECURITY.md",
71
+ ]
72
+
73
+ [tool.pytest.ini_options]
74
+ testpaths = ["tests"]
75
+
76
+ [tool.ruff]
77
+ line-length = 100
78
+ target-version = "py311"
79
+
80
+ [tool.ruff.lint]
81
+ # Pyflakes plus the pycodestyle error groups that flag real defects. Line length is
82
+ # left to formatting, matching the configuration this code was written against.
83
+ select = ["E4", "E7", "E9", "F"]
@@ -0,0 +1,25 @@
1
+ """Read, write, and edit DOCX packages with the Python standard library."""
2
+
3
+ from .document import Document
4
+ from .model import DocumentVisitor, Node, NodeEditError, NodeType, StoryType, VisitorAction
5
+ from .package import PackageError, PackageGraph, PackageLimits
6
+ from .session_ops import SessionEditReport
7
+ from .session_ops.rich_objects import SessionSaveReport
8
+
9
+ __version__ = "0.1.0"
10
+
11
+ __all__ = [
12
+ "Document",
13
+ "DocumentVisitor",
14
+ "Node",
15
+ "NodeEditError",
16
+ "NodeType",
17
+ "StoryType",
18
+ "VisitorAction",
19
+ "PackageError",
20
+ "PackageGraph",
21
+ "PackageLimits",
22
+ "SessionEditReport",
23
+ "SessionSaveReport",
24
+ "__version__",
25
+ ]
@@ -0,0 +1,24 @@
1
+ """The WolfDocx user cache directory shared by every on-disk cache."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import os
6
+ import sys
7
+ from pathlib import Path
8
+
9
+
10
+ def default_cache_root() -> Path:
11
+ """Return ``WOLFDOCX_CACHE_DIR`` when set, else the platform user cache directory."""
12
+ configured = os.environ.get("WOLFDOCX_CACHE_DIR")
13
+ if configured:
14
+ return Path(configured).expanduser()
15
+ if sys.platform == "darwin":
16
+ return Path.home() / "Library" / "Caches" / "wolfdocx"
17
+ if os.name == "nt":
18
+ local_app_data = os.environ.get("LOCALAPPDATA")
19
+ if local_app_data:
20
+ return Path(local_app_data) / "wolfdocx" / "Cache"
21
+ xdg_cache = os.environ.get("XDG_CACHE_HOME")
22
+ if xdg_cache:
23
+ return Path(xdg_cache).expanduser() / "wolfdocx"
24
+ return Path.home() / ".cache" / "wolfdocx"