diff options
| author | Michael Williamson <mike@zwobble.org> | 2018-01-23 21:32:52 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2018-01-23 21:32:52 +0000 |
| commit | f9e169de5b83a487263c8970872f222401d66765 (patch) | |
| tree | 78bda240f025f9038a988cd1b5706589356867b9 | |
| parent | 41000ecae3f59c8e766b83b4dfc2e67467eef00f (diff) | |
Use word/document.xml as fallback
| -rw-r--r-- | mammoth/docx/__init__.py | 7 | ||||
| -rw-r--r-- | tests/docx/docx_tests.py | 2 |
2 files changed, 5 insertions, 4 deletions
diff --git a/mammoth/docx/__init__.py b/mammoth/docx/__init__.py index c4c6877..326c85b 100644 --- a/mammoth/docx/__init__.py +++ b/mammoth/docx/__init__.py @@ -70,10 +70,11 @@ def _read_document(zip_file, body_readers, notes, comments): def _find_document_filename(zip_file, relationships): - targets = ["word/document.xml"] + [ + office_document_type = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" + targets = [ target.lstrip("/") - for target in relationships.find_targets_by_type("http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument") - ] + for target in relationships.find_targets_by_type(office_document_type) + ] + ["word/document.xml"] valid_targets = list(filter(lambda target: zip_file.exists(target), targets)) if len(valid_targets) == 0: return None diff --git a/tests/docx/docx_tests.py b/tests/docx/docx_tests.py index 9f2af01..8bd5b36 100644 --- a/tests/docx/docx_tests.py +++ b/tests/docx/docx_tests.py @@ -30,7 +30,7 @@ _relationship_namespaces = { @istest -def when_document_xml_is_not_present_then_document_is_found_using_file_relationships(): +def main_document_is_found_using_package_relationships(): fileobj = _create_zip({ "word/document2.xml": textwrap.dedent("""\ <?xml version="1.0" encoding="utf-8" ?> |
