-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfig.py
40 lines (34 loc) · 1011 Bytes
/
config.py
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
36
37
38
39
40
import os
import json
defconfig = {
}
configfile = __file__.replace(".py",".json")
def readConfig():
fileconfig = None
if os.path.isfile(configfile):
with open(configfile,'r') as f:
fileconfig = json.load(f)
return fileconfig
def writeConfig(currentconfig):
with open(configfile,'w') as f:
json.dump(currentconfig,f,indent=4)
def initConfig():
initconfig = defconfig.copy()
fileconfig = readConfig()
if fileconfig is not None:
fullconfig = initconfig
fullconfig.update(fileconfig)
else:
fullconfig = initconfig
writeConfig(fullconfig)
fullconfig = customConfig(fullconfig)
return fullconfig
def customConfig(incnf):
customconfig = {
"ADVANTEDGEDIR":os.path.join(incnf["PROJECTHOME"],"AdvantEDGE"),
"INFLUXSCENDB":"{}_{}".format(incnf['SANDBOX'],incnf['SCENARIO']).lower().replace("-","_"),
"QSFILES":"files"
}
incnf.update(customconfig)
return incnf
# initConfig()