Skip to content
Snippets Groups Projects

FIX: JSON schema now is more permissive, and fixed if-conditions.

Merged Daniel Hornung requested to merge f-extend-json-schema into dev
Files
12
@@ -84,23 +84,28 @@ def config_to_yaml(config):
@@ -84,23 +84,28 @@ def config_to_yaml(config):
def validate_yaml_schema(valobj):
def validate_yaml_schema(valobj):
# TODO: Re-enable warning once the schema has been extended to also cover
# SSS pycaosdb.inis and integration tests.
if optional_jsonschema_validate:
if optional_jsonschema_validate:
with open(os.path.join(os.path.dirname(__file__), "schema-pycaosdb-ini.yml")) as f:
with open(os.path.join(os.path.dirname(__file__), "schema-pycaosdb-ini.yml")) as f:
schema = yaml.load(f, Loader=yaml.SafeLoader)
schema = yaml.load(f, Loader=yaml.SafeLoader)
optional_jsonschema_validate(instance=valobj, schema=schema["schema-pycaosdb-ini"])
optional_jsonschema_validate(instance=valobj, schema=schema["schema-pycaosdb-ini"])
# else:
else:
# warnings.warn("""
warnings.warn("""
# Warning: The validation could not be performed because `jsonschema` is not installed.
Warning: The validation could not be performed because `jsonschema` is not installed.
# """)
""")
def _read_config_files():
def _read_config_files():
"""Function to read config files from different paths. Checks for path in $PYCAOSDBINI or home directory (.pycaosdb.ini) and in the current working directory (pycaosdb.ini).
"""Function to read config files from different paths.
 
 
Checks for path either in ``$PYCAOSDBINI`` or home directory (``.pycaosdb.ini``), and
 
additionally in the current working directory (``pycaosdb.ini``).
 
 
Returns
 
-------
 
 
ini files: list
 
The successfully parsed ini-files. Order: env_var or home directory, cwd. Used for testing the function.
Returns:
[list]: list with successfully parsed ini-files. Order: env_var or home directory, cwd. Used for testing the function.
"""
"""
return_var = []
return_var = []
if "PYCAOSDBINI" in environ:
if "PYCAOSDBINI" in environ:
Loading