Show More
@@ -23,7 +23,6 b'' | |||||
23 | }, |
|
23 | }, | |
24 | "outputs": [ |
|
24 | "outputs": [ | |
25 | { |
|
25 | { | |
26 | "metadata": {}, |
|
|||
27 | "name": "stdout", |
|
26 | "name": "stdout", | |
28 | "output_type": "stream", |
|
27 | "output_type": "stream", | |
29 | "text": [ |
|
28 | "text": [ |
@@ -19,7 +19,6 b'' | |||||
19 | }, |
|
19 | }, | |
20 | "outputs": [ |
|
20 | "outputs": [ | |
21 | { |
|
21 | { | |
22 | "metadata": {}, |
|
|||
23 | "name": "stdout", |
|
22 | "name": "stdout", | |
24 | "output_type": "stream", |
|
23 | "output_type": "stream", | |
25 | "text": [ |
|
24 | "text": [ |
@@ -19,7 +19,6 b'' | |||||
19 | }, |
|
19 | }, | |
20 | "outputs": [ |
|
20 | "outputs": [ | |
21 | { |
|
21 | { | |
22 | "metadata": {}, |
|
|||
23 | "name": "stdout", |
|
22 | "name": "stdout", | |
24 | "output_type": "stream", |
|
23 | "output_type": "stream", | |
25 | "text": [ |
|
24 | "text": [ |
@@ -8,7 +8,6 b'' | |||||
8 | }, |
|
8 | }, | |
9 | "outputs": [ |
|
9 | "outputs": [ | |
10 | { |
|
10 | { | |
11 | "metadata": {}, |
|
|||
12 | "name": "stdout", |
|
11 | "name": "stdout", | |
13 | "output_type": "stream", |
|
12 | "output_type": "stream", | |
14 | "text": [ |
|
13 | "text": [ |
@@ -10,7 +10,6 b'' | |||||
10 | { |
|
10 | { | |
11 | "ename": "Exception", |
|
11 | "ename": "Exception", | |
12 | "evalue": "message", |
|
12 | "evalue": "message", | |
13 | "metadata": {}, |
|
|||
14 | "output_type": "error", |
|
13 | "output_type": "error", | |
15 | "traceback": [ |
|
14 | "traceback": [ | |
16 | "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", |
|
15 | "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", | |
@@ -32,7 +31,6 b'' | |||||
32 | }, |
|
31 | }, | |
33 | "outputs": [ |
|
32 | "outputs": [ | |
34 | { |
|
33 | { | |
35 | "metadata": {}, |
|
|||
36 | "name": "stdout", |
|
34 | "name": "stdout", | |
37 | "output_type": "stream", |
|
35 | "output_type": "stream", | |
38 | "text": [ |
|
36 | "text": [ |
@@ -8,7 +8,6 b'' | |||||
8 | }, |
|
8 | }, | |
9 | "outputs": [ |
|
9 | "outputs": [ | |
10 | { |
|
10 | { | |
11 | "metadata": {}, |
|
|||
12 | "name": "stdout", |
|
11 | "name": "stdout", | |
13 | "output_type": "stream", |
|
12 | "output_type": "stream", | |
14 | "text": [ |
|
13 | "text": [ |
@@ -23,7 +23,6 b'' | |||||
23 | }, |
|
23 | }, | |
24 | "outputs": [ |
|
24 | "outputs": [ | |
25 | { |
|
25 | { | |
26 | "metadata": {}, |
|
|||
27 | "name": "stdout", |
|
26 | "name": "stdout", | |
28 | "output_type": "stream", |
|
27 | "output_type": "stream", | |
29 | "text": [ |
|
28 | "text": [ |
@@ -36,7 +36,6 b'' | |||||
36 | "print(\"hello\")" |
|
36 | "print(\"hello\")" | |
37 | ], |
|
37 | ], | |
38 | "language": "python", |
|
38 | "language": "python", | |
39 | "metadata": {}, |
|
|||
40 | "outputs": [ |
|
39 | "outputs": [ | |
41 | { |
|
40 | { | |
42 | "output_type": "stream", |
|
41 | "output_type": "stream", |
@@ -31,7 +31,6 b'' | |||||
31 | }, |
|
31 | }, | |
32 | "outputs": [ |
|
32 | "outputs": [ | |
33 | { |
|
33 | { | |
34 | "metadata": {}, |
|
|||
35 | "name": "stdout", |
|
34 | "name": "stdout", | |
36 | "output_type": "stream", |
|
35 | "output_type": "stream", | |
37 | "text": [ |
|
36 | "text": [ |
@@ -54,6 +54,10 b' def new_output(output_type, output_text=None, output_png=None,' | |||||
54 | if not isinstance(metadata, dict): |
|
54 | if not isinstance(metadata, dict): | |
55 | raise TypeError("metadata must be dict") |
|
55 | raise TypeError("metadata must be dict") | |
56 |
|
56 | |||
|
57 | ||||
|
58 | if output_type in {u'pyout', 'display_data'}: | |||
|
59 | output.metadata = metadata | |||
|
60 | ||||
57 | if output_type != 'pyerr': |
|
61 | if output_type != 'pyerr': | |
58 | if output_text is not None: |
|
62 | if output_text is not None: | |
59 | output.text = cast_unicode(output_text) |
|
63 | output.text = cast_unicode(output_text) | |
@@ -86,8 +90,6 b' def new_output(output_type, output_text=None, output_png=None,' | |||||
86 |
|
90 | |||
87 | if output_type == u'stream': |
|
91 | if output_type == u'stream': | |
88 | output.stream = 'stdout' if stream is None else cast_unicode(stream) |
|
92 | output.stream = 'stdout' if stream is None else cast_unicode(stream) | |
89 | else: |
|
|||
90 | output.metadata = metadata |
|
|||
91 |
|
93 | |||
92 | return output |
|
94 | return output | |
93 |
|
95 |
@@ -295,7 +295,6 b'' | |||||
295 | "description": "Type of cell output.", |
|
295 | "description": "Type of cell output.", | |
296 | "enum": ["pyerr"] |
|
296 | "enum": ["pyerr"] | |
297 | }, |
|
297 | }, | |
298 | "metadata": {"$ref": "#/definitions/misc/output_metadata"}, |
|
|||
299 | "ename": { |
|
298 | "ename": { | |
300 | "description": "The name of the error.", |
|
299 | "description": "The name of the error.", | |
301 | "type": "string" |
|
300 | "type": "string" |
@@ -141,8 +141,8 b' def upgrade_output(output):' | |||||
141 | - mime-type keys |
|
141 | - mime-type keys | |
142 | - stream.stream -> stream.name |
|
142 | - stream.stream -> stream.name | |
143 | """ |
|
143 | """ | |
144 | output.setdefault('metadata', NotebookNode()) |
|
|||
145 | if output['output_type'] in {'pyout', 'display_data'}: |
|
144 | if output['output_type'] in {'pyout', 'display_data'}: | |
|
145 | output.setdefault('metadata', NotebookNode()) | |||
146 | if output['output_type'] == 'pyout': |
|
146 | if output['output_type'] == 'pyout': | |
147 | output['output_type'] = 'execute_result' |
|
147 | output['output_type'] = 'execute_result' | |
148 | output['execution_count'] = output.pop('prompt_number', None) |
|
148 | output['execution_count'] = output.pop('prompt_number', None) | |
@@ -193,7 +193,6 b' def downgrade_output(output):' | |||||
193 | output['output_type'] = 'pyerr' |
|
193 | output['output_type'] = 'pyerr' | |
194 | elif output['output_type'] == 'stream': |
|
194 | elif output['output_type'] == 'stream': | |
195 | output['stream'] = output.pop('name') |
|
195 | output['stream'] = output.pop('name') | |
196 | output.pop('metadata') |
|
|||
197 | return output |
|
196 | return output | |
198 |
|
197 | |||
199 | def upgrade_outputs(outputs): |
|
198 | def upgrade_outputs(outputs): |
@@ -46,11 +46,11 b' def new_output(output_type, data=None, **kwargs):' | |||||
46 | output.data = from_dict(data) |
|
46 | output.data = from_dict(data) | |
47 |
|
47 | |||
48 | # populate defaults: |
|
48 | # populate defaults: | |
49 | output.setdefault('metadata', NotebookNode()) |
|
|||
50 | if output_type == 'stream': |
|
49 | if output_type == 'stream': | |
51 | output.setdefault('name', 'stdout') |
|
50 | output.setdefault('name', 'stdout') | |
52 | output.setdefault('text', '') |
|
51 | output.setdefault('text', '') | |
53 | elif output_type in {'execute_result', 'display_data'}: |
|
52 | elif output_type in {'execute_result', 'display_data'}: | |
|
53 | output.setdefault('metadata', NotebookNode()) | |||
54 | output.setdefault('data', NotebookNode()) |
|
54 | output.setdefault('data', NotebookNode()) | |
55 | validate(output, output_type) |
|
55 | validate(output, output_type) | |
56 | return output |
|
56 | return output |
@@ -235,13 +235,12 b'' | |||||
235 | "description": "Stream output from a code cell.", |
|
235 | "description": "Stream output from a code cell.", | |
236 | "type": "object", |
|
236 | "type": "object", | |
237 | "additionalProperties": false, |
|
237 | "additionalProperties": false, | |
238 |
"required": ["output_type", |
|
238 | "required": ["output_type", "name", "text"], | |
239 | "properties": { |
|
239 | "properties": { | |
240 | "output_type": { |
|
240 | "output_type": { | |
241 | "description": "Type of cell output.", |
|
241 | "description": "Type of cell output.", | |
242 | "enum": ["stream"] |
|
242 | "enum": ["stream"] | |
243 | }, |
|
243 | }, | |
244 | "metadata": {"$ref": "#/definitions/misc/output_metadata"}, |
|
|||
245 | "name": { |
|
244 | "name": { | |
246 | "description": "The name of the stream (stdout, stderr).", |
|
245 | "description": "The name of the stream (stdout, stderr).", | |
247 | "type": "string" |
|
246 | "type": "string" | |
@@ -257,13 +256,12 b'' | |||||
257 | "description": "Output of an error that occurred during code cell execution.", |
|
256 | "description": "Output of an error that occurred during code cell execution.", | |
258 | "type": "object", |
|
257 | "type": "object", | |
259 | "additionalProperties": false, |
|
258 | "additionalProperties": false, | |
260 |
"required": ["output_type" |
|
259 | "required": ["output_type", "ename", "evalue", "traceback"], | |
261 | "properties": { |
|
260 | "properties": { | |
262 | "output_type": { |
|
261 | "output_type": { | |
263 | "description": "Type of cell output.", |
|
262 | "description": "Type of cell output.", | |
264 | "enum": ["error"] |
|
263 | "enum": ["error"] | |
265 | }, |
|
264 | }, | |
266 | "metadata": {"$ref": "#/definitions/misc/output_metadata"}, |
|
|||
267 | "ename": { |
|
265 | "ename": { | |
268 | "description": "The name of the error.", |
|
266 | "description": "The name of the error.", | |
269 | "type": "string" |
|
267 | "type": "string" |
General Comments 0
You need to be logged in to leave comments.
Login now