From 603f8b83c0389be91ca90a3cb7690d7f237699d8 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Wed, 10 Sep 2025 16:08:20 +0100 Subject: Create files once --- mammoth/docx/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'mammoth/docx/__init__.py') diff --git a/mammoth/docx/__init__.py b/mammoth/docx/__init__.py index fcb5da5..3848736 100644 --- a/mammoth/docx/__init__.py +++ b/mammoth/docx/__init__.py @@ -156,6 +156,8 @@ def _part_with_body_reader(document_path, zip_file, part_paths): default=Numbering.EMPTY, ) + files = Files(None if document_path is None else os.path.dirname(document_path)) + def read_part(name, reader, default=_undefined): relationships = _read_relationships(zip_file, _find_relationships_path_for(name)) @@ -165,7 +167,7 @@ def _part_with_body_reader(document_path, zip_file, part_paths): relationships=relationships, styles=styles, docx_file=zip_file, - files=Files(None if document_path is None else os.path.dirname(document_path)), + files=files, ) if default is _undefined: -- cgit v1.2.3