diff options
author | lonkaars <l.leblansch@gmail.com> | 2021-03-28 12:19:28 +0200 |
---|---|---|
committer | lonkaars <l.leblansch@gmail.com> | 2021-03-28 12:19:28 +0200 |
commit | 2f4536d6b08b69168ebf3e718cbd8e3002b9af5a (patch) | |
tree | 5307692fb341d7f924ee9b73f3751e7e56cfb192 /api/dynamic_import.py | |
parent | 1f897d3f5ad11178cf4776ae4070c9d3e832f5f3 (diff) |
added comments
Diffstat (limited to 'api/dynamic_import.py')
-rw-r--r-- | api/dynamic_import.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/api/dynamic_import.py b/api/dynamic_import.py index 76281c2..159950c 100644 --- a/api/dynamic_import.py +++ b/api/dynamic_import.py @@ -5,6 +5,7 @@ import os import log import glob +# get all python files in api/ directory and convert them to python import names files = glob.glob(os.path.dirname(__file__) + "/**/*.py", recursive=True) files.remove(__file__) files = [str(filename) @@ -20,8 +21,10 @@ def route(dynamic_route): for file in files: mod = importlib.import_module(file) + # check if module has `dynamic_route` defined (single route) if hasattr(mod, "dynamic_route"): route(mod.dynamic_route) + # check if module has `dynamic_routes` defined (multiple routes as list) elif hasattr(mod, "dynamic_routes"): for dynamic_route in mod.dynamic_routes: route(dynamic_route) |