chore: clean-up

This commit is contained in:
Vlad Stan 2022-11-29 18:14:53 +02:00
parent 6c41ac841b
commit 3fbac927e9

View File

@ -155,14 +155,7 @@ def register_new_ext_routes(app: FastAPI) -> Callable:
def register_ext_routes(app: FastAPI, ext: Extension) -> None:
"""Register FastAPI routes for extension."""
ext_module = importlib.import_module(f"lnbits.extensions.{ext.code}")
if ext.version != "":
if f"lnbits.extensions.{ext.code}" in sys.modules:
del sys.modules[f"lnbits.extensions.{ext.code}"]
del ext_module
ext_module = importlib.import_module(f"lnbits.upgrades.{ext.version}.{ext.code}-{ext.version}")
# else:
# ext_module = importlib.import_module(f"lnbits.extensions.{ext.code}")
ext_module = importlib.import_module(ext.module_name)
ext_route = getattr(ext_module, f"{ext.code}_ext")
@ -176,11 +169,9 @@ def register_ext_routes(app: FastAPI, ext: Extension) -> None:
app.mount(s["path"], s["app"], s["name"])
logger.trace(f"adding route for extension {ext_module}")
if ext.version != "":
# ext_route.prefix = "/sss"
app.include_router(router=ext_route, prefix="/sss")
else:
app.include_router(router=ext_route)
prefix = f"/upgrades/{ext.version}" if ext.version != "" else ""
app.include_router(router=ext_route, prefix=prefix)
def register_startup(app: FastAPI):