diff --git a/data_file.py b/data_file.py index 8280726..e3eb0ff 100644 --- a/data_file.py +++ b/data_file.py @@ -11,7 +11,7 @@ class DictFile: def __init__(self, path: str=None): self.path = path - if path is None: + if path is None: # create empty settings dict if path is none else load settings from file self.settings = {} else: @@ -30,7 +30,7 @@ class DictFile: file.write(str(self)) file.close() - def __str__(self): + def __str__(self): # make the dict not be just one line new_settings_str = "{\n" for key in self.settings: new_settings_str += "\t" + repr(key) + ": " + repr(self.settings[key]) + ",\n" @@ -64,7 +64,7 @@ class DataclassJSONFile: self.dataclass = dataclass self.class_instance = class_instance - if class_instance is None: + if class_instance is None: # load the class instance from the file if it is None self.load_from_file(file_path) def load_from_file(self, file_path): @@ -100,6 +100,7 @@ class DataclassJSONFile: return len(self.class_instance.__dict__) +# these 2 functions do the exact same thing as in the class above def load_dataclass_json(dataclass, file_path: str): file = open(file_path, "r") class_dict = json.load(file)