Replace deprecated code and add missing dependency

This commit is contained in:
cyp
2023-08-09 18:08:21 +02:00
parent 89bcde58aa
commit 99ac426e4b
2 changed files with 5 additions and 4 deletions
+4 -3
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.')