Skip to content

Commit

Permalink
Replace deprecated importlib.find_loader by importlib.util.find_spec
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Günther <[email protected]>
  • Loading branch information
tom-hg57 committed Jan 13, 2025
1 parent cfc19c2 commit 158e1fc
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pycgmes/utils/reader.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 158e1fc

Please sign in to comment.