aboutsummaryrefslogtreecommitdiffstats
path: root/app/utils.py
blob: 824d3700f676b2372731cbc5fcd4ee1af1c24ed9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from app.Item import Item
from dataclasses import asdict


def get_param(key: str, params: dict[str, str]) -> str:
    if key not in params:
        raise Exception(f"no {key} field in config entry: " + str(params))

    return params[key]


def item_to_dict(item: Item) -> dict[str, str]:
    return asdict(item)


def dict_to_item(d: dict[str, str]) -> Item:
    return Item(**d)