Repository navigation
fix(document-extractor): read document.xml when OPC relationships fail - #347
Open
leilei3167 wants to merge 1 commit into
Open
leilei3167 wants to merge 1 commit into
leilei3167 wants to merge 1 commit into
Conversation
python-docx rejects Strict Open XML packages and packages that omit package relationships. Read word/document.xml after that failure so paragraph and table text still comes back.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Important
Related Issue
Closes #346
Summary
Document Extractor fails on Strict Open XML saves and on docx packages that omit
_rels/.rels. python-docx raisesKeyErrorbecause the package relationship is not the transitionalofficeDocumenttype. Rewriting ZIP entry paths does not repair that, andword/document.xmlis still present.When opening the package fails, read
word/document.xmldirectly and return the same paragraph and markdown-table text a normal docx already produces. Packages python-docx can open are unchanged. A zip with noword/document.xmlstill raisesTextExtractionError.Before the change,
test_extract_text_from_docx_reads_package_when_opc_relationships_failfailed for a strict relationship type, a strict wordprocessingml document, and a package without_rels/.rels. Each failure wasTextExtractionErrorwrappingKeyErrorfor the missingofficeDocumentrelationship. After the change, that test and the rest oftests/nodes/document_extractorpass (54).ruff,ty, and the import-layer check pass.Checklist
!