docxcompose3 1.4.2.dev0__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.
@@ -0,0 +1,296 @@
1
+ Changelog
2
+ =========
3
+
4
+ 1.4.1.post0+emmv
5
+ ------------------
6
+
7
+ - Migrated build system to PEP 517/621.
8
+ - Added pyproject.toml with modern metadata.
9
+ - Declared dynamic readme using setuptools to combine README.rst and HISTORY.txt.
10
+ - Removed legacy setup.py-based build path to avoid deprecation warnings.
11
+
12
+
13
+ 1.4.1 (unreleased)
14
+ ------------------
15
+
16
+ - Nothing changed yet.
17
+
18
+
19
+ 1.4.0 (2022-12-14)
20
+ ------------------
21
+
22
+ - Add support for updating multiline plain text Content Controls. [lgraf]
23
+
24
+
25
+ 1.3.7 (2022-11-18)
26
+ ------------------
27
+
28
+ - Respect document language when updating datefields. [njohner]
29
+
30
+
31
+ 1.3.6 (2022-10-05)
32
+ ------------------
33
+
34
+ - vt2value(): Convert empty <vt:lpwstr/> nodes to empty string instead of None. [lgraf]
35
+
36
+
37
+ 1.3.5 (2022-07-08)
38
+ ------------------
39
+
40
+ - Support missing style elements. [BryceStevenWilley]
41
+ - Correctly handle headers and footers when merging documents with sections. [njohner]
42
+
43
+
44
+ 1.3.4 (2021-12-20)
45
+ ------------------
46
+
47
+ - Avoid IndexError when processing documents that have custom styled numbering definitions. [lonetwin]
48
+
49
+
50
+ 1.3.3 (2021-08-12)
51
+ ------------------
52
+
53
+ - Add support for Smart Art (fixes #23)
54
+ - Correctly handle mapped styles in restart_first_numbering. [njohner]
55
+
56
+
57
+ 1.3.2 (2021-04-27)
58
+ ------------------
59
+
60
+ - Make Doc Properties case-insensitive. [buchi]
61
+
62
+
63
+ 1.3.1 (2021-01-13)
64
+ ------------------
65
+
66
+ - Add support for complex fields with fieldname split into several runs. [njohner]
67
+ - Add support for date format switches. [njohner]
68
+
69
+
70
+ 1.3.0 (2020-10-06)
71
+ ------------------
72
+
73
+ - Support updating complex properties with no existing value. [deiferni]
74
+
75
+
76
+ 1.2.0 (2020-07-13)
77
+ ------------------
78
+
79
+ - Add method to nullify a docproperty. [deiferni]
80
+
81
+
82
+ 1.1.2 (2020-06-11)
83
+ ------------------
84
+
85
+ - Handle embedded images that also have an external reference.
86
+ [buchi]
87
+ - Fix renumbering of non-visual image and drawing properties.
88
+ [buchi]
89
+
90
+
91
+ 1.1.1 (2020-05-04)
92
+ ------------------
93
+
94
+ - Fix an issue with non-ascii binary_type docproperties. [deiferni]
95
+
96
+
97
+ 1.1.0 (2020-04-07)
98
+ ------------------
99
+
100
+ - Add support for updating docproperties in header and footer of documents. [deiferni]
101
+
102
+
103
+ 1.0.2 (2019-09-09)
104
+ ------------------
105
+
106
+ - Do not fail when complex field does not have a separate node. [njohner]
107
+
108
+
109
+ 1.0.1 (2019-07-25)
110
+ ------------------
111
+
112
+ - Correctly treat two complex fields in the same paragraph. [njohner]
113
+ - Correctly handle the case when a docproperty appears multiple time in a document. [njohner]
114
+ - Handle docproperties with extra space before or no quotes around the property name. [njohner]
115
+
116
+ 1.0.0 (2019-06-13)
117
+ ------------------
118
+
119
+ - Change license from GPL to MIT.
120
+ [buchi]
121
+
122
+ - Add support for adding, setting and deleting of doc properties.
123
+ [buchi]
124
+
125
+
126
+ 1.0.0a17 (2019-04-25)
127
+ ---------------------
128
+
129
+ - Add functionality to get and set content of plain text content controls
130
+ (structured document tags).
131
+ [buchi]
132
+
133
+
134
+ 1.0.0a16 (2019-01-15)
135
+ ---------------------
136
+
137
+ - Prevent artifacts of previously cached doc property values during update. [deiferni]
138
+
139
+
140
+ 1.0.0a15 (2018-12-12)
141
+ ---------------------
142
+
143
+ - Fix updating doc-properties with non-ascii names. [deiferni]
144
+ - Don't handle hyperlink references twice. [deiferni]
145
+
146
+
147
+ 1.0.0a14 (2018-12-04)
148
+ ---------------------
149
+
150
+ - Implement generic handling of referenced parts. Among other, this adds
151
+ support for embedded Excel charts.
152
+ [buchi]
153
+
154
+ - Handle embedded SVGs.
155
+ [buchi]
156
+
157
+ - Add styles from other parts, e.g. footnotes.
158
+ [buchi]
159
+
160
+
161
+ 1.0.0a13 (2018-11-05)
162
+ ---------------------
163
+
164
+ - Fix list-styles being set incorrectly when restarting numberings.
165
+ [deiferni]
166
+
167
+
168
+ 1.0.0a12 (2018-10-30)
169
+ ---------------------
170
+
171
+ - Fix setting section type for appended documents with only one section.
172
+ [deiferni]
173
+
174
+
175
+ 1.0.0a11 (2018-07-30)
176
+ ---------------------
177
+
178
+ - Fix handling of section type.
179
+ [buchi]
180
+
181
+ - Fix an issue where the listing style of the first element was different.
182
+ [deiferni]
183
+
184
+ - Fix issue when restarting intermittent numbering.
185
+ [deiferni]
186
+
187
+
188
+ 1.0.0a10 (2018-07-18)
189
+ ---------------------
190
+
191
+ - Add console script command to compose two or more word files.
192
+ [deiferni]
193
+
194
+
195
+ 1.0.0a9 (2018-05-01)
196
+ --------------------
197
+
198
+ - Fix error in mapping of num_ids introduced in 1.0.0.a7.
199
+ [buchi]
200
+
201
+ - Do not fail when numbering zero is referenced.
202
+ [deiferni]
203
+
204
+
205
+ 1.0.0a8 (2018-04-26)
206
+ --------------------
207
+
208
+ - Only attempt to set the nsid when it is available.
209
+ [deiferni]
210
+
211
+
212
+ 1.0.0a7 (2018-04-20)
213
+ --------------------
214
+
215
+ - Fix handling of images in WordprocessingGroups (<wpg:wpg>).
216
+ [buchi]
217
+
218
+ - Fix handling of shapes in shape groups (<v:group>).
219
+ [buchi]
220
+
221
+ - Fix handling of numberings, avoid inserting multiple numbering properties.
222
+ [buchi]
223
+
224
+ - Fix renumbering of bookmarks.
225
+ [buchi]
226
+
227
+ - Renumber ids of drawing object properties (<wp:docPr>).
228
+ [buchi]
229
+
230
+
231
+ 1.0.0a6 (2018-02-20)
232
+ --------------------
233
+
234
+ - Do not restart numbering of bullets.
235
+ [buchi]
236
+
237
+
238
+ 1.0.0a5 (2018-01-11)
239
+ --------------------
240
+
241
+ - Renumber bookmarks to avoid duplicate ids.
242
+ [buchi]
243
+
244
+ - Add support for shapes.
245
+ [buchi]
246
+
247
+
248
+ 1.0.0a4 (2017-12-27)
249
+ --------------------
250
+
251
+ - Fix handling of styles when composing documents with different languages.
252
+ [buchi]
253
+
254
+ - Also add numberings referenced in styles.
255
+ [buchi]
256
+
257
+ - Avoid having multiple <w:abstractNum> elements for the same style.
258
+ [buchi]
259
+
260
+ - Restart first numbering of inserted documents
261
+ [buchi]
262
+
263
+ - Add support for anchored images.
264
+ [buchi]
265
+
266
+ - Handle referenced style ids that are not defined in styles.xml
267
+ [buchi]
268
+
269
+ - Remove header and footer references in paragraph properties.
270
+ [buchi]
271
+
272
+
273
+ 1.0.0a3 (2017-11-22)
274
+ --------------------
275
+
276
+ - Make removal of property fields optional.
277
+ [buchi]
278
+
279
+
280
+ 1.0.0a2 (2017-11-06)
281
+ --------------------
282
+
283
+ - Fix handling of footnotes containing hyperlinks.
284
+ [buchi]
285
+
286
+ - Add functionality to deal with custom document properties. Properties can be
287
+ updated and fields containing properties can be removed. When appending or
288
+ inserting documents their custom document properties get removed automatically.
289
+ [buchi]
290
+
291
+
292
+ 1.0.0a1 (2017-09-13)
293
+ --------------------
294
+
295
+ - Initial release
296
+ [buchi]
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 4teamwork AG
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
9
+ of the Software, and to permit persons to whom the Software is furnished to do
10
+ 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,6 @@
1
+ graft docxcompose
2
+ prune tests
3
+ include *.rst
4
+ include *.txt
5
+ exclude .gitignore
6
+ global-exclude *.pyc
@@ -0,0 +1,30 @@
1
+ Metadata-Version: 2.4
2
+ Name: docxcompose3
3
+ Version: 1.4.2.dev0
4
+ Summary: Compose .docx documents
5
+ Author-email: Thomas Buchberger <t.buchberger@4teamwork.ch>
6
+ Maintainer: Emmanuel Viennet, Matthew Huisman
7
+ License: MIT License
8
+ Project-URL: Homepage, https://github.com/matthuisman/docxcompose3
9
+ Project-URL: Repository, https://github.com/matthuisman/docxcompose3
10
+ Keywords: Python,DOCX,Word,OOXML
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Programming Language :: Python
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3 :: Only
16
+ Classifier: Programming Language :: Python :: 3.8
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Requires-Python: >=3.8
23
+ License-File: LICENSE
24
+ Requires-Dist: lxml
25
+ Requires-Dist: python-docx>=0.8.8
26
+ Requires-Dist: six
27
+ Requires-Dist: Babel
28
+ Provides-Extra: test
29
+ Requires-Dist: pytest; extra == "test"
30
+ Dynamic: license-file
@@ -0,0 +1,80 @@
1
+
2
+ *docxcompose* is a Python library for concatenating/appending Microsoft
3
+ Word (.docx) files.
4
+
5
+ This fork adds the PR 112, Fixed DeprecationWarning on pkg_import, by
6
+ @numshub
7
+ and modernizes the build system for Python >= 3.8.
8
+
9
+
10
+ Example usage
11
+ -------------
12
+
13
+ Append a document to another document:
14
+
15
+ .. code::
16
+
17
+ from docxcompose.composer import Composer
18
+ from docx import Document
19
+ master = Document("master.docx")
20
+ composer = Composer(master)
21
+ doc1 = Document("doc1.docx")
22
+ composer.append(doc1)
23
+ composer.save("combined.docx")
24
+
25
+
26
+ The docxcompose console script
27
+ ------------------------------
28
+
29
+
30
+ The ``docxcompose`` console script allows to compose docx files from the command
31
+ line, e.g.:
32
+
33
+ .. code:: sh
34
+
35
+ $ docxcompose files/master.docx files/content.docx -o files/composed.docx
36
+
37
+
38
+ Installation for development
39
+ ----------------------------
40
+
41
+ To install docxcompose for development, clone the repository and using a python with setuptools (for example a fresh virtualenv), install it using pip:
42
+
43
+ .. code:: sh
44
+
45
+ $ pip install -e .[tests]
46
+
47
+ Tests can then be run with ``pytest``.
48
+
49
+
50
+ A note about testing
51
+ --------------------
52
+
53
+ The tests provide helpers for blackbox testing that can compare whole word
54
+ files. To do so the following files should be provided:
55
+
56
+ - a file for the expected output that should be added to the folder
57
+ `docs/composed_fixture`
58
+ - multiple files that can be composed into the file above should be added
59
+ to the folder `docs`.
60
+
61
+ The expected output can now be tested as follows:
62
+
63
+
64
+ .. code:: python
65
+
66
+ def test_example():
67
+ fixture = FixtureDocument("expected.docx")
68
+ composed = ComposedDocument("master.docx", "slave1.docx", "slave2.docx")
69
+ assert fixture == composed
70
+
71
+
72
+ Should the assertion fail the output file will be stored in the folder
73
+ `docs/composed_debug` with the filename of the fixture file, `expected.docx`
74
+ in case of this example.
75
+
76
+
77
+ Headers and footers
78
+ -------------------
79
+
80
+ The first document is considered as the main template and headers and footers from the other documents are ignored, so that the header and footer of the first document is used throughout the merged file.
File without changes
@@ -0,0 +1,55 @@
1
+ from argparse import ArgumentParser
2
+ from docx import Document
3
+ from docxcompose.composer import Composer
4
+ import os.path
5
+ import sys
6
+
7
+
8
+ def setup_parser():
9
+ parser = ArgumentParser(
10
+ description='compose multiple docx files into one file.')
11
+ parser.add_argument('master',
12
+ help='path to master template that defines styles, '
13
+ 'headings and so on')
14
+ parser.add_argument('files', nargs='+',
15
+ help='path to one or more word-files to be appended '
16
+ 'to the master template',
17
+ metavar='file')
18
+ parser.add_argument('-o', '--output-document', dest='ouput_document',
19
+ default='composed.docx',
20
+ help='path to the output file', metavar='file')
21
+ return parser
22
+
23
+
24
+ def require_valid_file(parser, path):
25
+ if not os.path.isfile(path):
26
+ parser.error(message='file not found {}'.format(path))
27
+
28
+
29
+ def parse_args(parser, args):
30
+ parsed_args = parser.parse_args(args=args)
31
+
32
+ require_valid_file(parser, parsed_args.master)
33
+ for file_path in parsed_args.files:
34
+ require_valid_file(parser, file_path)
35
+
36
+ return parsed_args
37
+
38
+
39
+ def compose_files(parser, parsed_args):
40
+ composer = Composer(Document(parsed_args.master))
41
+ for slave_path in parsed_args.files:
42
+ composer.append(Document(slave_path))
43
+
44
+ composer.save(parsed_args.ouput_document)
45
+ parser.exit(message='successfully composed file at {}\n'.format(
46
+ parsed_args.ouput_document))
47
+
48
+
49
+ def main(args=None):
50
+ if args is None:
51
+ args = sys.argv[1:]
52
+
53
+ parser = setup_parser()
54
+ parsed_args = parse_args(parser, args)
55
+ compose_files(parser, parsed_args)