mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-10-13 02:00:30 +00:00
manifest: Load the metaschema only once
This commit is contained in:
parent
324a2fb7d4
commit
bcd1c7b536
1 changed files with 6 additions and 3 deletions
|
@ -27,6 +27,11 @@ class Manifest(object):
|
||||||
if path is None and data is None:
|
if path is None and data is None:
|
||||||
raise ManifestError('`path\' or `data\' must be provided')
|
raise ManifestError('`path\' or `data\' must be provided')
|
||||||
self.path = path
|
self.path = path
|
||||||
|
|
||||||
|
import os.path
|
||||||
|
self.metaschema = load_data(os.path.normpath(os.path.join(os.path.dirname(__file__),
|
||||||
|
'metaschema.json')))
|
||||||
|
|
||||||
self.load_data(data)
|
self.load_data(data)
|
||||||
self.load_modules()
|
self.load_modules()
|
||||||
self.validate()
|
self.validate()
|
||||||
|
@ -119,13 +124,11 @@ class Manifest(object):
|
||||||
:param str schema_path: Path to the json-schema to use for validation
|
:param str schema_path: Path to the json-schema to use for validation
|
||||||
"""
|
"""
|
||||||
import jsonschema
|
import jsonschema
|
||||||
import os.path
|
|
||||||
|
|
||||||
schema = load_data(schema_path)
|
schema = load_data(schema_path)
|
||||||
metaschema = load_data(os.path.normpath(os.path.join(os.path.dirname(__file__), 'metaschema.json')))
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
jsonschema.validate(schema, metaschema)
|
jsonschema.validate(schema, self.metaschema)
|
||||||
jsonschema.validate(data, schema)
|
jsonschema.validate(data, schema)
|
||||||
except jsonschema.ValidationError as e:
|
except jsonschema.ValidationError as e:
|
||||||
self.validation_error(e.message, e.path)
|
self.validation_error(e.message, e.path)
|
||||||
|
|
Loading…
Add table
Reference in a new issue