From 99ac426e4b0eed12b789eeeac9bb5e6cf7961372 Mon Sep 17 00:00:00 2001 From: Cyprian Laskowski Date: Wed, 9 Aug 2023 18:08:21 +0200 Subject: [PATCH] Replace deprecated code and add missing dependency --- conversion_utils/jos_msds_and_properties.py | 7 ++++--- setup.py | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/conversion_utils/jos_msds_and_properties.py b/conversion_utils/jos_msds_and_properties.py index 9badc0a..949b023 100644 --- a/conversion_utils/jos_msds_and_properties.py +++ b/conversion_utils/jos_msds_and_properties.py @@ -1,7 +1,7 @@ import lxml.etree as lxml import re import pickle -import importlib_resources as pkg_resources +from importlib_resources import files from conversion_utils.utils import xpath_find, get_xml_id @@ -241,9 +241,10 @@ class Converter: def __init__(self, xml_file_name=None): if (xml_file_name is None): - if (pkg_resources.is_resource('conversion_utils.resources', JOS_SPECIFICATIONS_PICKLE_RESOURCE)): + resource = files('conversion_utils.resources').joinpath(JOS_SPECIFICATIONS_PICKLE_RESOURCE) + if (resource.is_file()): try: - with pkg_resources.open_binary('conversion_utils.resources', JOS_SPECIFICATIONS_PICKLE_RESOURCE) as pickle_file: + with resource.open('rb') as pickle_file: self.specifications = pickle.load(pickle_file) except: exit('Could not parse specifications pickle file installed.') diff --git a/setup.py b/setup.py index dec83d2..d94c296 100644 --- a/setup.py +++ b/setup.py @@ -7,6 +7,6 @@ setup(name='conversion_utils', author='Cyprian Laskowski', author_email='cyp@cjvt.si', packages=['conversion_utils', 'conversion_utils.resources', 'conversion_utils.tests'], - install_requires=['importlib_resources'], + install_requires=['lxml', 'importlib_resources'], include_package_data=True, zip_safe=True)