Improved module loading
This commit is contained in:
parent
0e21db41cb
commit
7b010266bd
|
@ -57,6 +57,8 @@ __all__ = [
|
||||||
|
|
||||||
import importlib
|
import importlib
|
||||||
import logging
|
import logging
|
||||||
|
import inspect
|
||||||
|
import sys
|
||||||
|
|
||||||
from . import (
|
from . import (
|
||||||
data,
|
data,
|
||||||
|
@ -67,9 +69,12 @@ from ._version import __version__
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
current_module = sys.modules[__name__]
|
||||||
|
|
||||||
def load_backend(name: str) -> object | None:
|
def load_backend(name: str) -> object | None:
|
||||||
try:
|
try:
|
||||||
return importlib.import_module(f'{__name__}.{name}')
|
imported_module = importlib.import_module(f'{__name__}.{name}')
|
||||||
|
current_module.setmember(name, imported_module)
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.exception(
|
logger.exception(
|
||||||
'Backend %s could not be imported? Are all module dependencies installed?',
|
'Backend %s could not be imported? Are all module dependencies installed?',
|
||||||
|
@ -79,7 +84,8 @@ def load_backend(name: str) -> object | None:
|
||||||
|
|
||||||
# Import modules
|
# Import modules
|
||||||
|
|
||||||
defi_kraken = load_backend('defi_kraken')
|
backend_modules = ['defi_kraken', 'defi_kucoin', 'investbank_nordnet', 'defi_partisia_blockchain']
|
||||||
defi_kucoin = load_backend('defi_kucoin')
|
for m in backend_modules:
|
||||||
investbank_nordnet = load_backend('investbank_nordnet')
|
load_backend(m)
|
||||||
defi_partisia_blockchain = load_backend('defi_partisia_blockchain')
|
del m
|
||||||
|
del backend_modules, current_module
|
||||||
|
|
Loading…
Reference in New Issue
Block a user