Show More
@@ -49,15 +49,31 b' class ConvertFiguresTransformer(ConfigurableTransformer):' | |||||
49 | #Loop through all of the datatypes of the outputs in the cell. |
|
49 | #Loop through all of the datatypes of the outputs in the cell. | |
50 | for index, cell_out in enumerate(cell.get('outputs', [])): |
|
50 | for index, cell_out in enumerate(cell.get('outputs', [])): | |
51 | for data_type, data in cell_out.items(): |
|
51 | for data_type, data in cell_out.items(): | |
52 | self._convert_figure(cell_out, data_type, data) |
|
52 | ||
|
53 | #Get the name of the file exported by the extract figure | |||
|
54 | #transformer. Do not try to convert the figure if the extract | |||
|
55 | #fig transformer hasn't touched it | |||
|
56 | filename = cell_out.get(data_type + '_filename', None) | |||
|
57 | if filename: | |||
|
58 | figure_name = filename[:filename.rfind('.')] | |||
|
59 | self._convert_figure(cell_out, figure_name, resources, data_type, data) | |||
53 | return cell, resources |
|
60 | return cell, resources | |
54 |
|
61 | |||
55 |
|
62 | |||
56 | def _convert_figure(self, cell_out, data_type, data): |
|
63 | def _convert_figure(self, cell_out, resources, figure_name, data_type, data): | |
57 | """ |
|
64 | """ | |
58 | Convert a figure and output the results to the cell output |
|
65 | Convert a figure and output the results to the cell output | |
59 | """ |
|
66 | """ | |
60 |
|
67 | |||
61 |
if not self. |
|
68 | if not self.to_format in cell_out: | |
62 |
if data_type |
|
69 | if data_type == self.from_format: | |
63 | cell_out[self._to_format] = self.convert_figure(data_type, data) |
|
70 | filename = figure_name + '.' + self.to_format | |
|
71 | if filename not in resources['figures']: | |||
|
72 | ||||
|
73 | #On the cell, make the figure available via | |||
|
74 | # cell.outputs[i].pdf_filename ... etc (PDF in example) | |||
|
75 | cell_out[self.to_format + '_filename'] = filename | |||
|
76 | ||||
|
77 | #In the resources, make the figure available via | |||
|
78 | # resources['figures']['filename'] = data | |||
|
79 | resources['figures'][filename] = self.convert_figure(data_type, data) |
General Comments 0
You need to be logged in to leave comments.
Login now