Show More
@@ -1,4 +1,5 b'' | |||
|
1 | 1 | # coding: utf-8 |
|
2 | import base64 | |
|
2 | 3 | import io |
|
3 | 4 | import json |
|
4 | 5 | import os |
@@ -37,6 +38,10 b' class NbconvertAPI(object):' | |||
|
37 | 38 | def list_formats(self): |
|
38 | 39 | return self._req('GET', '') |
|
39 | 40 | |
|
41 | png_green_pixel = base64.encodestring(b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00' | |
|
42 | b'\x00\x00\x01\x00\x00x00\x01\x08\x02\x00\x00\x00\x90wS\xde\x00\x00\x00\x0cIDAT' | |
|
43 | b'\x08\xd7c\x90\xfb\xcf\x00\x00\x02\\\x01\x1e.~d\x87\x00\x00\x00\x00IEND\xaeB`\x82') | |
|
44 | ||
|
40 | 45 | class APITest(NotebookTestBase): |
|
41 | 46 | def setUp(self): |
|
42 | 47 | nbdir = self.notebook_dir.name |
@@ -51,6 +56,7 b' class APITest(NotebookTestBase):' | |||
|
51 | 56 | ws.cells.append(new_heading_cell(u'Created by test ³')) |
|
52 | 57 | cc1 = new_code_cell(input=u'print(2*6)') |
|
53 | 58 | cc1.outputs.append(new_output(output_text=u'12')) |
|
59 | cc1.outputs.append(new_output(output_png=png_green_pixel, output_type='pyout')) | |
|
54 | 60 | ws.cells.append(cc1) |
|
55 | 61 | |
|
56 | 62 | with io.open(pjoin(nbdir, 'foo', 'testnb.ipynb'), 'w', |
@@ -17,7 +17,7 b' import base64' | |||
|
17 | 17 | import sys |
|
18 | 18 | import os |
|
19 | 19 | |
|
20 | from IPython.utils.traitlets import Unicode | |
|
20 | from IPython.utils.traitlets import Unicode, Set | |
|
21 | 21 | from .base import Preprocessor |
|
22 | 22 | from IPython.utils import py3compat |
|
23 | 23 | |
@@ -34,6 +34,7 b' class ExtractOutputPreprocessor(Preprocessor):' | |||
|
34 | 34 | output_filename_template = Unicode( |
|
35 | 35 | "{unique_key}_{cell_index}_{index}.{extension}", config=True) |
|
36 | 36 | |
|
37 | extract_output_types = Set({'png', 'jpg', 'svg', 'pdf'}, config=True) | |
|
37 | 38 | |
|
38 | 39 | def preprocess_cell(self, cell, resources, cell_index): |
|
39 | 40 | """ |
@@ -63,8 +64,8 b' class ExtractOutputPreprocessor(Preprocessor):' | |||
|
63 | 64 | #Loop through all of the outputs in the cell |
|
64 | 65 | for index, out in enumerate(cell.get('outputs', [])): |
|
65 | 66 | |
|
66 |
#Get the output in data formats that the template |
|
|
67 |
for out_type in self. |
|
|
67 | #Get the output in data formats that the template needs extracted | |
|
68 | for out_type in self.extract_output_types: | |
|
68 | 69 | if out.hasattr(out_type): |
|
69 | 70 | data = out[out_type] |
|
70 | 71 |
General Comments 0
You need to be logged in to leave comments.
Login now