-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathmanage.py
More file actions
27 lines (18 loc) · 700 Bytes
/
Copy pathmanage.py
File metadata and controls
27 lines (18 loc) · 700 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 importlib
import os
from flask_migrate import Migrate
from src.models.basemodel import db
from main import create_app
app = create_app()
MODELS_DIRECTORY = "models"
EXCLUDE_FILES = ["__init__.py"]
def scan_models():
for dir_path, dir_names, file_names in os.walk(MODELS_DIRECTORY):
for file_name in file_names:
if file_name.endswith("py") and file_name not in EXCLUDE_FILES:
file_path_wo_ext, _ = os.path.splitext((os.path.join(dir_path, file_name)))
module_name = file_path_wo_ext.replace(os.sep, ".")
importlib.import_module(module_name)
migrate = Migrate(app, db)
if __name__ == "__main__":
scan_models()