From 5499748cb026fa5009659d812f4f4251195614e0 Mon Sep 17 00:00:00 2001 From: Pierpaolo Da Fieno Date: Wed, 9 Jul 2025 16:30:28 +0200 Subject: [PATCH 1/2] Fixed DeprecationWarning on pkg_import. --- docxcompose/properties.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/docxcompose/properties.py b/docxcompose/properties.py index aa8cd2d..bd7b439 100644 --- a/docxcompose/properties.py +++ b/docxcompose/properties.py @@ -15,7 +15,8 @@ from lxml.etree import QName from six import binary_type from six import text_type -import pkg_resources +#import pkg_resources +import importlib_resources import re @@ -108,8 +109,10 @@ def __init__(self, doc): self._element = parse_xml(part.blob) def _part_template(self): - return pkg_resources.resource_string( - 'docxcompose', 'templates/custom.xml') + # return pkg_resources.resource_string( + # 'docxcompose', 'templates/custom.xml') + ref = importlib_resources.files('docxcompose').joinpath('templates/custom.xml') + return ref.read_bytes() def _update_part(self): if self.part is None: From 8bdf3f1df72c9f566c39a16be650c78c9df00b34 Mon Sep 17 00:00:00 2001 From: Pierpaolo Da Fieno Date: Thu, 24 Jul 2025 18:28:14 +0200 Subject: [PATCH 2/2] Update properties.py Removed old lines of code Changed import of importlib.resources --- docxcompose/properties.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/docxcompose/properties.py b/docxcompose/properties.py index bd7b439..51f2ac0 100644 --- a/docxcompose/properties.py +++ b/docxcompose/properties.py @@ -15,8 +15,7 @@ from lxml.etree import QName from six import binary_type from six import text_type -#import pkg_resources -import importlib_resources +import importlib.resources as importlib_resources import re @@ -109,8 +108,6 @@ def __init__(self, doc): self._element = parse_xml(part.blob) def _part_template(self): - # return pkg_resources.resource_string( - # 'docxcompose', 'templates/custom.xml') ref = importlib_resources.files('docxcompose').joinpath('templates/custom.xml') return ref.read_bytes()