aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar decorator-factory <[email protected]>2020-12-15 09:27:23 +0300
committerGravatar GitHub <[email protected]>2020-12-15 09:27:23 +0300
commit4ad8494d02ccf6202788b41b8e4ab36b32bd4a16 (patch)
treef1bd99af68151db37cfc4d037fffeced71c2750c
parentremove stray print (diff)
parentUpdate route levels parsing to work in all platforms (diff)
Merge branch 'ks123/routes-parsing' into testing-strategies
-rw-r--r--backend/route_manager.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/backend/route_manager.py b/backend/route_manager.py
index d9e5700..c48ea8e 100644
--- a/backend/route_manager.py
+++ b/backend/route_manager.py
@@ -36,7 +36,7 @@ def route_classes() -> t.Iterator[tuple[Path, type[Route]]]:
routes_directory = Path("backend") / "routes"
for module_path in routes_directory.rglob("*.py"):
- import_name = f"{str(module_path.parent).replace('/', '.')}.{module_path.stem}"
+ import_name = f"{'.'.join(file.parent.parts)}.{file.stem}"
route_module = importlib.import_module(import_name)
for _member_name, member in inspect.getmembers(route_module):
if is_route_class(member):
@@ -50,7 +50,7 @@ def create_route_map() -> list[BaseRoute]:
for module_path, member in route_classes():
# module_path == Path("backend/routes/foo/bar/baz/bin.py")
# => levels == ["foo", "bar", "baz"]
- levels = str(module_path.parent).split("/")[2:]
+ levels = file.parent.parts[2:]
current_level = None
for level in levels:
if current_level is None: