-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathloader.py
More file actions
26 lines (22 loc) · 778 Bytes
/
loader.py
File metadata and controls
26 lines (22 loc) · 778 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import os
from importlib import import_module
from logging import getLogger
LOG = getLogger(__name__)
def load_modules(path):
for root, __, files in os.walk(path):
files_count = 0
for f in files:
if f.startswith("__") or not f.endswith(".py"):
continue
try:
module_path = (
os.path.join(root, f)[:-3].replace("\\", ".").replace("/", ".")
)
import_module(module_path)
except Exception as er:
print(er)
files_count += 1
if files_count:
name = root.replace('/', '.').replace("\\", ".")
print(f"Loaded {files_count} files from {name}")
LOG.info("Completed loading modules.")