MCPcopy
hub / github.com/agent0ai/agent-zero / import_module

Function import_module

helpers/modules.py:12–24  ·  view source on GitHub ↗
(file_path: str)

Source from the content-addressed store, hash-verified

10
11
12def import_module(file_path: str) -> ModuleType:
13 # Handle file paths with periods in the name using importlib.util
14 abs_path = get_abs_path(file_path)
15 module_name = os.path.basename(abs_path).replace(".py", "")
16
17 # Create the module spec and load the module
18 spec = importlib.util.spec_from_file_location(module_name, abs_path)
19 if spec is None or spec.loader is None:
20 raise ImportError(f"Could not load module from {abs_path}")
21
22 module = importlib.util.module_from_spec(spec)
23 spec.loader.exec_module(module)
24 return module
25
26
27def load_classes_from_folder(

Callers 2

load_classes_from_folderFunction · 0.85
load_classes_from_fileFunction · 0.85

Calls 2

get_abs_pathFunction · 0.90
replaceMethod · 0.80

Tested by

no test coverage detected