Skip to content

Commit 768ac37

Browse files
author
Jeff Panasuik
authored
Create sys_import_modules.py
1 parent 53edfe5 commit 768ac37

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

etc/sys_import_modules.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# import_modules.py
2+
import os
3+
4+
def dynamic_import_modules():
5+
app_dir = os.path.join(os.path.dirname(__file__), 'app')
6+
import_modules_path = os.path.join(os.path.dirname(__file__), 'dynamic_import_modules.py')
7+
8+
try:
9+
with open(import_modules_path, 'w') as f:
10+
f.write("# This file is auto-generated by dynamic_import_modules.py\n")
11+
f.write("import sys\n")
12+
f.write("sys.path.append(os.path.join(os.path.dirname(__file__), 'app'))\n\n")
13+
14+
for root, dirs, files in os.walk(app_dir):
15+
for file in files:
16+
if file.startswith('sys_') and file.endswith('.py'):
17+
module_name = file[:-3] # Remove .py extension
18+
f.write(f"from {module_name} import *\n")
19+
20+
print(f"Generated imports in {import_modules_path}")
21+
except Exception as e:
22+
print(f"An error occurred while generating imports: {e}")
23+
24+
if __name__ == "__main__":
25+
dynamic_import_modules()
26+

0 commit comments

Comments
 (0)