Commit a08d8f44 authored by Wout De Nolf's avatar Wout De Nolf
Browse files

esrftaskgraph: proper qualname for builtins

parent b12489b5
import importlib
def qualname(_type):
mod_name = _type.__module__
if not mod_name or mod_name == str.__module__:
return _type.__name__ # Avoid reporting builtins
return mod_name + "." + _type.__name__
def qualname(obj):
return obj.__module__ + "." + obj.__name__
def import_qualname(qualname):
if not isinstance(qualname, str):
raise TypeError(qualname, type(qualname))
module_name, dot, name = qualname.rpartition(".")
module_name, dot, obj_name = qualname.rpartition(".")
if not module_name:
raise ImportError(f"cannot import {qualname}")
module = importlib.import_module(module_name)
return getattr(module, name)
return getattr(module, obj_name)
except AttributeError:
raise ImportError(f"cannot import {name} from {module_name}")
raise ImportError(f"cannot import {obj_name} from {module_name}")
def import_method(qualname):
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment