From 2f4536d6b08b69168ebf3e718cbd8e3002b9af5a Mon Sep 17 00:00:00 2001 From: lonkaars Date: Sun, 28 Mar 2021 12:19:28 +0200 Subject: added comments --- api/dynamic_import.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'api/dynamic_import.py') 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) -- cgit v1.2.3