blob: 761efdf5db10899d17b926c88890777e0d02d1a7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
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))
|