Show More
@@ -31,6 +31,11 b' def get_validator(version=None):' | |||||
31 |
|
31 | |||
32 | if version not in validators: |
|
32 | if version not in validators: | |
33 | v = import_item("IPython.nbformat.v%s" % version) |
|
33 | v = import_item("IPython.nbformat.v%s" % version) | |
|
34 | try: | |||
|
35 | v.nbformat_schema | |||
|
36 | except AttributeError: | |||
|
37 | # no validator | |||
|
38 | return None | |||
34 | schema_path = os.path.join(os.path.dirname(v.__file__), v.nbformat_schema) |
|
39 | schema_path = os.path.join(os.path.dirname(v.__file__), v.nbformat_schema) | |
35 | with open(schema_path) as f: |
|
40 | with open(schema_path) as f: | |
36 | schema_json = json.load(f) |
|
41 | schema_json = json.load(f) | |
@@ -98,6 +103,10 b' def validate(nbjson, ref=None, version=None):' | |||||
98 |
|
103 | |||
99 | validator = get_validator(version) |
|
104 | validator = get_validator(version) | |
100 |
|
105 | |||
|
106 | if validator is None: | |||
|
107 | # no validator | |||
|
108 | return | |||
|
109 | ||||
101 | try: |
|
110 | try: | |
102 | if ref: |
|
111 | if ref: | |
103 | return validator.validate(nbjson, {'$ref' : '#/definitions/%s' % ref}) |
|
112 | return validator.validate(nbjson, {'$ref' : '#/definitions/%s' % ref}) |
General Comments 0
You need to be logged in to leave comments.
Login now