2024-01-28 21:17:16 +08:00
|
|
|
from functools import lru_cache
|
|
|
|
from typing import Any
|
|
|
|
|
2024-04-21 18:22:39 +08:00
|
|
|
from felicity.core.config import settings
|
2024-01-28 21:17:16 +08:00
|
|
|
from felicity.utils.loader import json_from_file
|
|
|
|
|
|
|
|
|
|
|
|
@lru_cache
|
|
|
|
def load_seed_files() -> dict[str, dict | list]:
|
|
|
|
data = dict()
|
2024-05-29 14:00:08 +08:00
|
|
|
for _f in ["analyses", "clients", "laboratory", "country", "inventory"]:
|
2024-04-21 18:22:39 +08:00
|
|
|
data[_f] = json_from_file(f"{settings.SEEDS_DIR}/{_f}")
|
2024-01-28 21:17:16 +08:00
|
|
|
return data
|
|
|
|
|
|
|
|
|
|
|
|
def get_seeds(name: str) -> dict[str, Any] | list:
|
|
|
|
return load_seed_files().get(name, None)
|