From 6b07024cd93742dacfaf9d151e888f058615486f Mon Sep 17 00:00:00 2001 From: Loic Guegan Date: Wed, 25 Oct 2023 16:08:42 +0200 Subject: [PATCH] Minor changes --- clusterman/config.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/clusterman/config.py b/clusterman/config.py index 04cac10..761efdf 100644 --- a/clusterman/config.py +++ b/clusterman/config.py @@ -3,7 +3,20 @@ import os, json class Config: CONF_DIR=os.path.join(os.environ['HOME'],".clusterman/") + CONF_FILE=os.path.join(CONF_DIR,"clusterman.json") def __init__(self): Path(self.CONF_DIR).mkdir(parents=True, exist_ok=True) - print(self.CONF_DIR) + self.load() + + def load(self): + self.config={"example":None} + if os.path.exists(self.CONF_FILE): + with open(self.CONF_FILE) as f: + self.config=json.load(f) + else: + self.save() + + def save(self): + with open(self.CONF_FILE, "w") as f: + f.write(json.dumps(self.config))