|
|
@ -2,11 +2,10 @@ from requests import get
|
|
|
|
from yaml import load, SafeLoader
|
|
|
|
from yaml import load, SafeLoader
|
|
|
|
from reag__ import reag__
|
|
|
|
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)
|
|
|
|
|
|
|
|
return yml
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def parse_ftl(url = 'https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/Resources/Locale/ru-RU/reagents/meta/medicine.ftl'):
|
|
|
|
def parse_ftl(el, prefix = 'https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/Resources/Locale/ru-RU/reagents/meta'):
|
|
|
|
|
|
|
|
url = f'{prefix}/{el}.ftl'
|
|
|
|
raw = get(url).content.decode('utf-8')
|
|
|
|
raw = get(url).content.decode('utf-8')
|
|
|
|
locales = {}
|
|
|
|
locales = {}
|
|
|
|
for i in raw.splitlines():
|
|
|
|
for i in raw.splitlines():
|
|
|
@ -17,20 +16,36 @@ def parse_ftl(url = 'https://raw.githubusercontent.com/SerbiaStrong-220/space-st
|
|
|
|
locales[name] = locale
|
|
|
|
locales[name] = locale
|
|
|
|
return locales
|
|
|
|
return locales
|
|
|
|
|
|
|
|
|
|
|
|
def load_recipes(url = 'https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/Resources/Prototypes/Recipes/Reactions/medicine.yml', category = '-'):
|
|
|
|
def load_locales(locales_url):
|
|
|
|
yml = parse_yml(url)
|
|
|
|
locales = {}
|
|
|
|
recipes = {}
|
|
|
|
for el in locales_url:
|
|
|
|
for element in yml:
|
|
|
|
locales = locales | parse_ftl(el)
|
|
|
|
product = element["id"]
|
|
|
|
return locales
|
|
|
|
comps = {}
|
|
|
|
|
|
|
|
for elem in element["reactants"]:
|
|
|
|
#### Рецепты ####
|
|
|
|
comps[elem] = element["reactants"][elem]["amount"]
|
|
|
|
|
|
|
|
for id, value in element["products"].items():
|
|
|
|
def parse_yml(el, prefix = 'https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/Resources/Prototypes/Recipes/Reactions'):
|
|
|
|
out = value
|
|
|
|
url = f'{prefix}/{el}.yml'
|
|
|
|
recipes[product] = reag__(category=category, comps=comps, out=out)
|
|
|
|
yml = load(get(url).content.decode('utf-8'), Loader=SafeLoader)
|
|
|
|
|
|
|
|
return yml
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def load_recipes(recipes_url, prefix = 'https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/Resources/Prototypes/Recipes/Reactions'):
|
|
|
|
|
|
|
|
for el in recipes_url:
|
|
|
|
|
|
|
|
yml = parse_yml(el, prefix)
|
|
|
|
|
|
|
|
recipes = {}
|
|
|
|
|
|
|
|
for element in yml:
|
|
|
|
|
|
|
|
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=el, comps=comps, out=out)
|
|
|
|
return recipes
|
|
|
|
return recipes
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#### Локализируем ####
|
|
|
|
|
|
|
|
|
|
|
|
def localize(recipes, locale):
|
|
|
|
def localize(recipes, locale):
|
|
|
|
loc_recipes = {}
|
|
|
|
loc_recipes = {}
|
|
|
|
# Итерируем элементы
|
|
|
|
# Итерируем элементы
|
|
|
|