Show More
@@ -306,6 +306,41 b'' | |||||
306 | "from IPython.display import Image\n", |
|
306 | "from IPython.display import Image\n", | |
307 | "Image(\"http://ipython.org/_static/IPy_header.png\")" |
|
307 | "Image(\"http://ipython.org/_static/IPy_header.png\")" | |
308 | ] |
|
308 | ] | |
|
309 | }, | |||
|
310 | { | |||
|
311 | "cell_type": "future cell", | |||
|
312 | "metadata": {}, | |||
|
313 | "key": "value" | |||
|
314 | }, | |||
|
315 | { | |||
|
316 | "cell_type": "code", | |||
|
317 | "execution_count": 99, | |||
|
318 | "metadata": {}, | |||
|
319 | "outputs": [ | |||
|
320 | { | |||
|
321 | "name": "stdout", | |||
|
322 | "output_type": "stream", | |||
|
323 | "text": [ | |||
|
324 | "hello\n" | |||
|
325 | ] | |||
|
326 | }, | |||
|
327 | { | |||
|
328 | "output_type": "future output", | |||
|
329 | "some key": [ | |||
|
330 | "some data" | |||
|
331 | ] | |||
|
332 | }, | |||
|
333 | { | |||
|
334 | "name": "stdout", | |||
|
335 | "output_type": "stream", | |||
|
336 | "text": [ | |||
|
337 | "hello again\n" | |||
|
338 | ] | |||
|
339 | } | |||
|
340 | ], | |||
|
341 | "source": [ | |||
|
342 | "future_output()" | |||
|
343 | ] | |||
309 | } |
|
344 | } | |
310 | ], |
|
345 | ], | |
311 | "metadata": {}, |
|
346 | "metadata": {}, |
@@ -54,18 +54,19 b'' | |||||
54 | "cells": { |
|
54 | "cells": { | |
55 | "description": "Array of cells of the current notebook.", |
|
55 | "description": "Array of cells of the current notebook.", | |
56 | "type": "array", |
|
56 | "type": "array", | |
57 | "items": { |
|
57 | "items": {"$ref": "#/definitions/cell"} | |
58 | "type": "object", |
|
|||
59 | "oneOf": [ |
|
|||
60 | {"$ref": "#/definitions/raw_cell"}, |
|
|||
61 | {"$ref": "#/definitions/markdown_cell"}, |
|
|||
62 | {"$ref": "#/definitions/code_cell"} |
|
|||
63 | ] |
|
|||
64 | } |
|
|||
65 | } |
|
58 | } | |
66 | }, |
|
59 | }, | |
67 |
|
60 | |||
68 | "definitions": { |
|
61 | "definitions": { | |
|
62 | "cell": { | |||
|
63 | "type": "object", | |||
|
64 | "oneOf": [ | |||
|
65 | {"$ref": "#/definitions/raw_cell"}, | |||
|
66 | {"$ref": "#/definitions/markdown_cell"}, | |||
|
67 | {"$ref": "#/definitions/code_cell"} | |||
|
68 | ] | |||
|
69 | }, | |||
69 |
|
70 | |||
70 | "raw_cell": { |
|
71 | "raw_cell": { | |
71 | "description": "Notebook raw nbconvert cell.", |
|
72 | "description": "Notebook raw nbconvert cell.", | |
@@ -157,6 +158,31 b'' | |||||
157 | } |
|
158 | } | |
158 | } |
|
159 | } | |
159 | }, |
|
160 | }, | |
|
161 | ||||
|
162 | "unrecognized_cell": { | |||
|
163 | "description": "Unrecognized cell from a future minor-revision to the notebook format.", | |||
|
164 | "type": "object", | |||
|
165 | "additionalProperties": true, | |||
|
166 | "required": ["cell_type", "metadata"], | |||
|
167 | "properties": { | |||
|
168 | "cell_type": { | |||
|
169 | "description": "String identifying the type of cell.", | |||
|
170 | "not" : { | |||
|
171 | "enum": ["markdown", "code", "raw"] | |||
|
172 | } | |||
|
173 | }, | |||
|
174 | "metadata": { | |||
|
175 | "description": "Cell-level metadata.", | |||
|
176 | "type": "object", | |||
|
177 | "properties": { | |||
|
178 | "name": {"$ref": "#/definitions/misc/metadata_name"}, | |||
|
179 | "tags": {"$ref": "#/definitions/misc/metadata_tags"} | |||
|
180 | }, | |||
|
181 | "additionalProperties": true | |||
|
182 | } | |||
|
183 | } | |||
|
184 | }, | |||
|
185 | ||||
160 | "output": { |
|
186 | "output": { | |
161 | "type": "object", |
|
187 | "type": "object", | |
162 | "oneOf": [ |
|
188 | "oneOf": [ | |
@@ -249,6 +275,21 b'' | |||||
249 | } |
|
275 | } | |
250 | }, |
|
276 | }, | |
251 |
|
277 | |||
|
278 | "unrecognized_output": { | |||
|
279 | "description": "Unrecognized output from a future minor-revision to the notebook format.", | |||
|
280 | "type": "object", | |||
|
281 | "additionalProperties": true, | |||
|
282 | "required": ["output_type"], | |||
|
283 | "properties": { | |||
|
284 | "output_type": { | |||
|
285 | "description": "Type of cell output.", | |||
|
286 | "not": { | |||
|
287 | "enum": ["execute_result", "display_data", "stream", "error"] | |||
|
288 | } | |||
|
289 | } | |||
|
290 | } | |||
|
291 | }, | |||
|
292 | ||||
252 | "misc": { |
|
293 | "misc": { | |
253 | "metadata_name": { |
|
294 | "metadata_name": { | |
254 | "description": "The cell's name. If present, must be a non-empty string.", |
|
295 | "description": "The cell's name. If present, must be a non-empty string.", |
@@ -30,7 +30,6 b' def _relax_additional_properties(obj):' | |||||
30 | if isinstance(obj, dict): |
|
30 | if isinstance(obj, dict): | |
31 | for key, value in obj.items(): |
|
31 | for key, value in obj.items(): | |
32 | if key == 'additionalProperties': |
|
32 | if key == 'additionalProperties': | |
33 | print(obj) |
|
|||
34 | value = True |
|
33 | value = True | |
35 | else: |
|
34 | else: | |
36 | value = _relax_additional_properties(value) |
|
35 | value = _relax_additional_properties(value) | |
@@ -40,6 +39,15 b' def _relax_additional_properties(obj):' | |||||
40 | obj[i] = _relax_additional_properties(value) |
|
39 | obj[i] = _relax_additional_properties(value) | |
41 | return obj |
|
40 | return obj | |
42 |
|
41 | |||
|
42 | def _allow_undefined(schema): | |||
|
43 | schema['definitions']['cell']['oneOf'].append( | |||
|
44 | {"$ref": "#/definitions/unrecognized_cell"} | |||
|
45 | ) | |||
|
46 | schema['definitions']['output']['oneOf'].append( | |||
|
47 | {"$ref": "#/definitions/unrecognized_output"} | |||
|
48 | ) | |||
|
49 | return schema | |||
|
50 | ||||
43 | def get_validator(version=None, version_minor=None): |
|
51 | def get_validator(version=None, version_minor=None): | |
44 | """Load the JSON schema into a Validator""" |
|
52 | """Load the JSON schema into a Validator""" | |
45 | if version is None: |
|
53 | if version is None: | |
@@ -66,6 +74,8 b' def get_validator(version=None, version_minor=None):' | |||||
66 | if current_minor < version_minor: |
|
74 | if current_minor < version_minor: | |
67 | # notebook from the future, relax all `additionalProperties: False` requirements |
|
75 | # notebook from the future, relax all `additionalProperties: False` requirements | |
68 | schema_json = _relax_additional_properties(schema_json) |
|
76 | schema_json = _relax_additional_properties(schema_json) | |
|
77 | # and allow undefined cell types and outputs | |||
|
78 | schema_json = _allow_undefined(schema_json) | |||
69 |
|
79 | |||
70 | validators[version_tuple] = Validator(schema_json) |
|
80 | validators[version_tuple] = Validator(schema_json) | |
71 | return validators[version_tuple] |
|
81 | return validators[version_tuple] |
General Comments 0
You need to be logged in to leave comments.
Login now