Enforce loading of fetchers
This commit is contained in:
parent
b71c765e34
commit
f7ea7c90b5
|
@ -21,11 +21,16 @@ def get_modules(backend_dir: Path) -> Iterator[str]:
|
|||
if name != '__init__':
|
||||
yield name
|
||||
|
||||
FETCHER_MODULES_LOADED = False
|
||||
|
||||
|
||||
def load_fetcher_modules() -> None:
|
||||
backend_dir = Path(__name__.replace(r'.', '/'))
|
||||
for module in get_modules(backend_dir):
|
||||
load_backend(module)
|
||||
global FETCHER_MODULES_LOADED
|
||||
if not FETCHER_MODULES_LOADED:
|
||||
backend_dir = Path(__name__.replace(r'.', '/'))
|
||||
for module in get_modules(backend_dir):
|
||||
load_backend(module)
|
||||
FETCHER_MODULES_LOADED = True
|
||||
|
||||
|
||||
load_fetcher_modules()
|
||||
|
|
|
@ -7,7 +7,7 @@ from pathlib import Path
|
|||
import requests
|
||||
import requests_cache
|
||||
|
||||
from . import data, notification, util
|
||||
from . import data, notification, util, fetchers
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -73,6 +73,7 @@ def get_session(
|
|||
|
||||
|
||||
def available_scrapers() -> list[type[data.Scraper]]:
|
||||
fetchers.load_fetcher_modules()
|
||||
subclasses = []
|
||||
class_queue = [data.Scraper]
|
||||
while class_queue:
|
||||
|
|
3
test/test_init.py
Normal file
3
test/test_init.py
Normal file
|
@ -0,0 +1,3 @@
|
|||
def test_init():
|
||||
import personal_data
|
||||
assert personal_data.__version__ is not None
|
Loading…
Reference in New Issue
Block a user