Skip to content
Snippets Groups Projects
Commit 3a5ec117 authored by Alexander Schlemmer's avatar Alexander Schlemmer
Browse files

validation functions added

parent 72133fef
No related branches found
No related tags found
2 merge requests!33MAINT: change arguments of create_user,!21ENH: add json schema validation for config files
......@@ -21,6 +21,10 @@
#
# ** end header
#
import os
import yaml
try:
# python2
from ConfigParser import ConfigParser
......@@ -46,6 +50,22 @@ def configure(inifile):
_reset_config()
return _pycaosdbconf.read(inifile)
def get_config():
return _pycaosdbconf
def config_to_yaml(config):
valobj = {}
for s in config.sections():
valobj[s] = {}
for key, value in config[s].items():
valobj[s][key] = value
return valobj
def validate(valobj):
print(__file__)
with open(os.path.join(os.path.dirname(__file__), "schema-pycaosdb-ini.yml")) as f:
schema = yaml.load(f, Loader=yaml.SafeLoader)
validate(instance=valobj, schema=schema)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment