1
0

Compare commits

...

2 Commits

Author SHA1 Message Date
919f949d17
Ruff
Some checks failed
Test Python / Test (push) Failing after 27s
2024-08-08 17:56:14 +02:00
7b010266bd
Improved module loading 2024-08-08 17:54:50 +02:00
2 changed files with 25 additions and 13 deletions

View File

@ -57,6 +57,8 @@ __all__ = [
import importlib
import logging
import inspect
import sys
from . import (
data,
@ -66,20 +68,30 @@ from ._version import __version__
logger = logging.getLogger(__name__)
CURRENT_MODULE = sys.modules[__name__]
def load_backend(name: str) -> object | None:
try:
return importlib.import_module(f'{__name__}.{name}')
imported_module = importlib.import_module(f'{__name__}.{name}')
CURRENT_MODULE.setmember(name, imported_module)
except 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?',
name,
)
return None
# Import modules
defi_kraken = load_backend('defi_kraken')
defi_kucoin = load_backend('defi_kucoin')
investbank_nordnet = load_backend('investbank_nordnet')
defi_partisia_blockchain = load_backend('defi_partisia_blockchain')
backend_modules = [
'defi_kraken',
'defi_kucoin',
'investbank_nordnet',
'defi_partisia_blockchain',
]
for m in backend_modules:
load_backend(m)
del m
del backend_modules, CURRENT_MODULE