From 982c078b58f3f9c740d465132f9a8abdd8181dae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D1=81=D0=B0=D1=87=D1=82=D0=B8=D0=BA?= <51020966+ca4tuk@users.noreply.github.com> Date: Thu, 25 Jan 2024 19:12:36 +0200 Subject: [PATCH] =?UTF-8?q?=D1=88=D1=82=D1=83=D0=BA=D0=B8=20=D0=B1=D0=B5?= =?UTF-8?q?=D0=B7=20=D1=80=D0=B5=D1=86=D0=B5=D0=BF=D1=82=D0=BE=D0=B2=20?= =?UTF-8?q?=D0=B2=D0=BD=D0=BE=D0=B2=D1=8C=20=D0=B2=20=D0=91=D0=94.=20?= =?UTF-8?q?=D0=B7=D0=B0=D1=87=D0=B5=D0=BC=3F=20=D0=BD=D0=B0=D0=B4=D0=BE.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- update_db.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/update_db.py b/update_db.py index a35a9a8..46ef9d4 100644 --- a/update_db.py +++ b/update_db.py @@ -69,6 +69,8 @@ class Reagent: @property def recipe(self): result = [] + if not self.__recipe: + return result for item in self.__recipe: # Приводим к НОРМАЛЬНОМУ виду # "Бикаридин": [ [0, "Углерод", 1], [1, "Инапровалин"] ] @@ -129,7 +131,7 @@ for item in yaml.load(requests.get(RECIPES_URL).content.decode("utf-8"), Loader= item["reactants"]} content[item["id"]]["products"] = item["products"] -reagents = [Reagent(init_data=content[item]) for item in content if "reactants" in content[item]] +reagents = [Reagent(init_data=content[item]) for item in content] # if "reactants" in content[item]] db = {x.name: x.recipe for x in reagents} with open("db.json", mode="w", encoding="utf-8") as db_file: