felicity-lims/felicity/lims/seeds/data/__init__.py

18 lines
482 B
Python
Raw Normal View History

2024-01-28 21:17:16 +08:00
from functools import lru_cache
from typing import Any
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"]:
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)