From 158e1fc7964653420aca61dddc967ec8fc4569ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=BCnther?= Date: Mon, 13 Jan 2025 19:13:37 +0100 Subject: [PATCH] Replace deprecated importlib.find_loader by importlib.util.find_spec MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Thomas Günther --- pycgmes/utils/reader.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pycgmes/utils/reader.py b/pycgmes/utils/reader.py index cd19967..f6921d0 100644 --- a/pycgmes/utils/reader.py +++ b/pycgmes/utils/reader.py @@ -1,5 +1,6 @@ -import importlib import logging +from importlib import import_module +from importlib.util import find_spec from typing import Literal from lxml import etree @@ -112,7 +113,7 @@ def _process_element(self, class_name: str, uuid: str, elem): try: # Import the module for the CGMES object. module_name = self._get_path_to_module(class_name) - module = importlib.import_module(module_name) + module = import_module(module_name) klass = getattr(module, class_name) if uuid not in topology: @@ -170,7 +171,7 @@ def _get_rdf_namespace(self) -> str: return namespace def _get_path_to_module(self, class_name: str) -> str: - if self.custom_folder and importlib.find_loader(self.custom_folder + "." + class_name): # type: ignore + if self.custom_folder and find_spec(self.custom_folder + "." + class_name): path_to_module = self.custom_folder + "." + class_name else: path_to_module = self.cgmes_version_path + "." + class_name