From 7b137a7d3baf9b4cdcb2fa4aa240804344493722 Mon Sep 17 00:00:00 2001 From: bartool Date: Fri, 6 Mar 2026 19:19:52 +0100 Subject: [PATCH] feat: add config.py for persistent settings --- config.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 config.py diff --git a/config.py b/config.py new file mode 100644 index 0000000..ca78644 --- /dev/null +++ b/config.py @@ -0,0 +1,37 @@ +import json +import os + +CONFIG_FILE = "config.json" + +class Config: + def __init__(self): + self.data = { + "repository_path": "" + } + self.load() + + def load(self): + if os.path.exists(CONFIG_FILE): + try: + with open(CONFIG_FILE, "r") as f: + self.data = json.load(f) + except Exception as e: + print(f"Error loading config: {e}") + + def save(self): + try: + with open(CONFIG_FILE, "w") as f: + json.dump(self.data, f, indent=4) + except Exception as e: + print(f"Error saving config: {e}") + + @property + def repository_path(self): + return self.data.get("repository_path", "") + + @repository_path.setter + def repository_path(self, value): + self.data["repository_path"] = value + self.save() + +config = Config()