flake8 style

main
Bob Mottram 2020-04-02 09:05:40 +00:00
parent 161cef7fff
commit a70793b616
1 changed files with 20 additions and 19 deletions

View File

@ -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]