mirror of https://gitlab.com/bashrc2/epicyon
flake8 style
parent
161cef7fff
commit
a70793b616
39
config.py
39
config.py
|
@ -1,44 +1,45 @@
|
||||||
__filename__="config.py"
|
__filename__ = "config.py"
|
||||||
__author__="Bob Mottram"
|
__author__ = "Bob Mottram"
|
||||||
__license__="AGPL3+"
|
__license__ = "AGPL3+"
|
||||||
__version__="1.1.0"
|
__version__ = "1.1.0"
|
||||||
__maintainer__="Bob Mottram"
|
__maintainer__ = "Bob Mottram"
|
||||||
__email__="bob@freedombone.net"
|
__email__ = "bob@freedombone.net"
|
||||||
__status__="Production"
|
__status__ = "Production"
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import time
|
|
||||||
import json
|
|
||||||
from utils import loadJson
|
from utils import loadJson
|
||||||
from utils import saveJson
|
from utils import saveJson
|
||||||
|
|
||||||
|
|
||||||
def createConfig(baseDir: str) -> None:
|
def createConfig(baseDir: str) -> None:
|
||||||
"""Creates a configuration file
|
"""Creates a configuration file
|
||||||
"""
|
"""
|
||||||
configFilename=baseDir+'/config.json'
|
configFilename = baseDir + '/config.json'
|
||||||
if os.path.isfile(configFilename):
|
if os.path.isfile(configFilename):
|
||||||
return
|
return
|
||||||
configJson={
|
configJson = {
|
||||||
}
|
}
|
||||||
saveJson(configJson,configFilename)
|
saveJson(configJson, configFilename)
|
||||||
|
|
||||||
|
|
||||||
def setConfigParam(baseDir: str, variableName: str, variableValue) -> None:
|
def setConfigParam(baseDir: str, variableName: str, variableValue) -> None:
|
||||||
"""Sets a configuration value
|
"""Sets a configuration value
|
||||||
"""
|
"""
|
||||||
createConfig(baseDir)
|
createConfig(baseDir)
|
||||||
configFilename=baseDir+'/config.json'
|
configFilename = baseDir + '/config.json'
|
||||||
configJson={}
|
configJson = {}
|
||||||
if os.path.isfile(configFilename):
|
if os.path.isfile(configFilename):
|
||||||
configJson=loadJson(configFilename)
|
configJson = loadJson(configFilename)
|
||||||
configJson[variableName]=variableValue
|
configJson[variableName] = variableValue
|
||||||
saveJson(configJson,configFilename)
|
saveJson(configJson, configFilename)
|
||||||
|
|
||||||
|
|
||||||
def getConfigParam(baseDir: str, variableName: str):
|
def getConfigParam(baseDir: str, variableName: str):
|
||||||
"""Gets a configuration value
|
"""Gets a configuration value
|
||||||
"""
|
"""
|
||||||
createConfig(baseDir)
|
createConfig(baseDir)
|
||||||
configFilename=baseDir+'/config.json'
|
configFilename = baseDir + '/config.json'
|
||||||
configJson=loadJson(configFilename)
|
configJson = loadJson(configFilename)
|
||||||
if configJson:
|
if configJson:
|
||||||
if configJson.get(variableName):
|
if configJson.get(variableName):
|
||||||
return configJson[variableName]
|
return configJson[variableName]
|
||||||
|
|
Loading…
Reference in New Issue