From fb2df017876aad9b4cb009ce8471db0fb29ecbd0 Mon Sep 17 00:00:00 2001 From: RGBCube <78925721+RGBCube@users.noreply.github.com> Date: Fri, 21 Jan 2022 15:44:54 +0300 Subject: [PATCH] redux --- db.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/db.py b/db.py index 8e8a03e..676669e 100644 --- a/db.py +++ b/db.py @@ -19,15 +19,10 @@ class Utils: @staticmethod def set(main_dict: dict, path: str, *, key: str, value): def magic(alt_dict: dict, key: str): - if key in alt_dict.keys(): - if isinstance(alt_dict[key], dict): - return alt_dict - else: - alt_dict[key] = {} - return alt_dict - else: - alt_dict[key] = {} + if key in alt_dict.keys() and isinstance(alt_dict[key], dict): return alt_dict + alt_dict[key] = {} + return alt_dict main_dict_ref, i = main_dict, 0 for dict_name in path.split("+"): i += 1