diff --git a/config.py b/config.py index fecf674e..b290797b 100644 --- a/config.py +++ b/config.py @@ -1,44 +1,45 @@ -__filename__="config.py" -__author__="Bob Mottram" -__license__="AGPL3+" -__version__="1.1.0" -__maintainer__="Bob Mottram" -__email__="bob@freedombone.net" -__status__="Production" +__filename__ = "config.py" +__author__ = "Bob Mottram" +__license__ = "AGPL3+" +__version__ = "1.1.0" +__maintainer__ = "Bob Mottram" +__email__ = "bob@freedombone.net" +__status__ = "Production" import os -import time -import json from utils import loadJson from utils import saveJson + def createConfig(baseDir: str) -> None: """Creates a configuration file """ - configFilename=baseDir+'/config.json' + configFilename = baseDir + '/config.json' if os.path.isfile(configFilename): return - configJson={ + configJson = { } - saveJson(configJson,configFilename) + saveJson(configJson, configFilename) + def setConfigParam(baseDir: str, variableName: str, variableValue) -> None: """Sets a configuration value """ createConfig(baseDir) - configFilename=baseDir+'/config.json' - configJson={} + configFilename = baseDir + '/config.json' + configJson = {} if os.path.isfile(configFilename): - configJson=loadJson(configFilename) - configJson[variableName]=variableValue - saveJson(configJson,configFilename) + configJson = loadJson(configFilename) + configJson[variableName] = variableValue + saveJson(configJson, configFilename) + def getConfigParam(baseDir: str, variableName: str): """Gets a configuration value """ createConfig(baseDir) - configFilename=baseDir+'/config.json' - configJson=loadJson(configFilename) + configFilename = baseDir + '/config.json' + configJson = loadJson(configFilename) if configJson: if configJson.get(variableName): return configJson[variableName]