blob: b4547de01ecb4723ce2fbf81418ca19eba9fa975 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
from pathlib import Path
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)
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))
def __getitem__(self, key):
return self.config[key]
|