From 3f8fad07fd95f0172e37642ff732685f147fd2d4 Mon Sep 17 00:00:00 2001 From: Faraphel Date: Mon, 17 Jan 2022 09:46:12 +0100 Subject: [PATCH] using load_from_json return self --- source/CT_Config.py | 8 ++++++-- source/Cup.py | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/source/CT_Config.py b/source/CT_Config.py index 0744d91..de48e5c 100644 --- a/source/CT_Config.py +++ b/source/CT_Config.py @@ -136,7 +136,7 @@ class CT_Config: return ct_icon - def load_ctconfig_file(self, ctconfig_file: str = "./ct_config.json") -> None: + def load_ctconfig_file(self, ctconfig_file: str = "./ct_config.json"): """ load a ctconfig from a json file :param ctconfig_file: path to the ctconfig file @@ -145,7 +145,9 @@ class CT_Config: ctconfig_json = json.load(f) self.load_ctconfig_json(ctconfig_json) - def load_ctconfig_json(self, ctconfig_json: dict) -> None: + return self + + def load_ctconfig_json(self, ctconfig_json: dict): """ load ctconfig from a dictionnary :param ctconfig_json: json of the ctconfig to load @@ -184,6 +186,8 @@ class CT_Config: for param in ["region", "cheat_region", "tags_color", "prefix_list", "suffix_list", "tag_retro"]: setattr(self, param, ctconfig_json.get(param)) + return self + def search_tracks(self, values_list=False, not_value=False, only_unordered_track=False, **kwargs) -> list: """ :param only_unordered_track: only search in unordered track diff --git a/source/Cup.py b/source/Cup.py index 67b65a0..1419d30 100644 --- a/source/Cup.py +++ b/source/Cup.py @@ -43,7 +43,7 @@ class Cup: ctfile_cup += track.get_ctfile(*args, **kwargs) return ctfile_cup - def load_from_json(self, cup: dict) -> None: + def load_from_json(self, cup: dict): """ load the cup from a dictionnary :param cup: dictionnary cup @@ -54,3 +54,5 @@ class Cup: self.tracks[int(i)].load_from_json(track_json) else: setattr(self, key, value) + + return self