1
0

Enforce loading of fetchers
All checks were successful
Run Python tests (through Pytest) / Test (push) Successful in 35s
Verify Python project can be installed, loaded and have version checked / Test (push) Successful in 30s

This commit is contained in:
Jon Michael Aanes 2024-11-17 11:30:37 +01:00
parent b71c765e34
commit f7ea7c90b5
Signed by: Jmaa
SSH Key Fingerprint: SHA256:Ab0GfHGCblESJx7JRE4fj4bFy/KRpeLhi41y4pF3sNA
3 changed files with 13 additions and 4 deletions

View File

@ -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()

View File

@ -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
View File

@ -0,0 +1,3 @@
def test_init():
import personal_data
assert personal_data.__version__ is not None