Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix zipfile.py 'UserWarning: Duplicate name: docProps/core.xml' #1436

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
cip91sk wants to merge 3 commits into python-openxml:master
base: master
Choose a base branch
Loading
from cip91sk:fix_duplicate_docprops_corexml

Conversation

@cip91sk
Copy link

@cip91sk cip91sk commented Oct 1, 2024

Some documents in _rels/.rels, for the relation the targets "docProps/core.xml", have the relationship type
http://schemas.openxmlformats.org/officedocument/2006/relationships/metadata/core-properties
instead of
http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties

In these cases, python-docx doesn't see that the core-properties are already set, it creates new ones and append a duplicate docProps/core.xml file in the zip

arkanoid87 and winged reacted with thumbs up emoji
try:
office_document_part = self.part_related_by(RT.CORE_PROPERTIES_OFFICEDOCUMENT)
rel = self.relate_to(office_document_part, RT.CORE_PROPERTIES_OFFICEDOCUMENT)
self.rels[rel].set_reltype(RT.CORE_PROPERTIES)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First see below how to create a setter. Then change this line to

self.rels[rel].reltype = RT.CORE_PROPERTIES

Comment on lines 137 to 138
def set_reltype(self, reltype:str) -> None:
self._reltype = reltype
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a setter

 @reltype.setter
 def reltype(self, value: str):
 self._reltype = value

Copy link

rafguns commented May 21, 2025

Hi @cip91sk , anything I can do to help this PR along? I would add the requested changes myself but I can't (at least not in this PR) since I'm not a maintainer.

Copy link
Author

cip91sk commented May 24, 2025

Sorry for the delay, I missed the previous messages.

I corrected with a proper setter, let me know if it's all good now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer

@keestux keestux keestux left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /