diff --git a/reworked/parse.py b/reworked/parse.py index 30b84d9..f940c28 100644 --- a/reworked/parse.py +++ b/reworked/parse.py @@ -1,5 +1,6 @@ from requests import get from yaml import load, SafeLoader +from reag__ import reag__ def parse_yml(url = 'https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/Resources/Prototypes/Recipes/Reactions/medicine.yml'): yml = load(get(url).content.decode('utf-8'), Loader=SafeLoader) @@ -15,3 +16,16 @@ def parse_ftl(url = 'https://raw.githubusercontent.com/SerbiaStrong-220/space-st locale = splitted[2] locales[name] = locale return locales + +def load_recipe(yml = parse_yml()): + recipes = {} + for element in yml: + category = "medicine" + product = element["id"] + comps = {} + for elem in element["reactants"]: + comps[elem] = element["reactants"][elem]["amount"] + for id, value in element["products"].items(): + out = value + recipes[product] = reag__(category=category, comps=comps, out=out) + return recipes \ No newline at end of file diff --git a/reworked/reag__.py b/reworked/reag__.py index ea74601..9e74950 100644 --- a/reworked/reag__.py +++ b/reworked/reag__.py @@ -1,8 +1,10 @@ class reag__: - def __init__(category = '-', comps, out): + def __init__(self, category: str = '-', comps = {}, out: int = 0): # medicine self.category = category # {'инапровалин': 1, 'углерод': 1} self.comps = comps # 2 self.out = out + def get_all(self): + return [self.category, self.comps, self.out]