-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfigReader.py
More file actions
35 lines (29 loc) · 944 Bytes
/
configReader.py
File metadata and controls
35 lines (29 loc) · 944 Bytes
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
26
27
28
29
30
31
32
33
34
35
import json
import os
import os.path as path
class ConfigReader:
def __init__(self):
self.config_path = path.expanduser("~/.kst-git/config.json")
self.config = None
if os.path.exists(self.config_path):
with open(self.config_path, "r") as f:
self.config = json.load(f)
else:
self.config = {
"username": "",
"password": "",
"server": "",
"firstConfig": False
}
with open(self.config_path, "w") as f:
json.dump(self.config, f)
self.configVersion = "1.0.0"
def getConfig(self):
return self.config
def getConfigVersion(self):
return self.configVersion
def saveConfig(self):
with open(self.config_path, "w") as f:
json.dump(self.config, f)
def updateConfig(self, config):
self.config = config