mirror of
https://github.com/Justuser3310/ss14_chemistry_site.git
synced 2025-01-18 16:58:48 +00:00
Добавление функции load_recipe() в parse.py
Добавление функции get_all() для класса reag__
This commit is contained in:
parent
9f09fd67f4
commit
e5c7c65816
@ -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
|
@ -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]
|
||||
|
Loading…
Reference in New Issue
Block a user