MCPcopy Index your code
hub / github.com/plotly/plotly.py / __getattr__

Function __getattr__

_plotly_utils/importers.py:23–43  ·  view source on GitHub ↗
(import_name)

Source from the content-addressed store, hash-verified

21 class_names = {rel_path.split(".")[-1]: rel_path for rel_path in rel_classes}
22
23 def __getattr__(import_name):
24 # In Python 3.7+, lazy import submodules
25
26 # Check for submodule
27 if import_name in module_names:
28 rel_import = module_names[import_name]
29 return importlib.import_module(rel_import, parent_name)
30
31 # Check for submodule class
32 if import_name in class_names:
33 rel_path_parts = class_names[import_name].split(".")
34 rel_module = ".".join(rel_path_parts[:-1])
35 class_name = import_name
36 class_module = importlib.import_module(rel_module, parent_name)
37 return getattr(class_module, class_name)
38
39 raise AttributeError(
40 "module {__name__!r} has no attribute {name!r}".format(
41 name=import_name, __name__=parent_name
42 )
43 )
44
45 __all__ = list(module_names) + list(class_names)
46

Callers

nothing calls this directly

Calls 2

splitMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected