diff --git a/settings.py b/settings.py index 428395c..70817cf 100644 --- a/settings.py +++ b/settings.py @@ -5,27 +5,30 @@ class Settings: self.path = path if path is None: - self.settings = {"abc" : "abftdc"} + self.settings = {} else: self.load_from_file(path) + def load_from_file(self, path): file = open(path, "r") self.settings = eval(file.read()) file.close() - def save_settings(self): - file = open(self.path, "w") + def save(self, path): + file = open(path, "w") + file.write(str(self)) + file.close() + def __str__(self): new_settings_str = "{\n" - for key in self.settings.keys: + for key in self.settings: new_settings_str += "\t" + repr(key) + ": " + repr(self.settings[key]) + ",\n" new_settings_str = new_settings_str[:-2] + "\n}" - file.write(new_settings_str) - file.close() + return new_settings_str def __repr__(self): return repr(self.settings)