Replace deprecated code and add missing dependency

This commit is contained in:
Cyprian Laskowski 2023-08-09 18:08:21 +02:00
parent 89bcde58aa
commit 99ac426e4b
2 changed files with 5 additions and 4 deletions

View File

@ -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.')

View File

@ -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)