##// END OF EJS Templates
Removed todo
Jonathan Frederic -
Show More
@@ -1,77 +1,75 b''
1 1 """Module containing a transformer that converts outputs in the notebook from
2 2 one format to another.
3 3 """
4 4 #-----------------------------------------------------------------------------
5 5 # Copyright (c) 2013, the IPython Development Team.
6 6 #
7 7 # Distributed under the terms of the Modified BSD License.
8 8 #
9 9 # The full license is in the file COPYING.txt, distributed with this software.
10 10 #-----------------------------------------------------------------------------
11 11
12 #TODO: Come after extract
13
14 12 #-----------------------------------------------------------------------------
15 13 # Imports
16 14 #-----------------------------------------------------------------------------
17 15
18 16 from .base import ConfigurableTransformer
19 17
20 18 #-----------------------------------------------------------------------------
21 19 # Classes
22 20 #-----------------------------------------------------------------------------
23 21
24 22 class ConvertFiguresTransformer(ConfigurableTransformer):
25 23 """
26 24 Converts all of the outputs in a notebook from one format to another.
27 25 """
28 26
29 27
30 28 def __init__(self, from_formats, to_format, **kw):
31 29 """
32 30 Public constructor
33 31
34 32 Parameters
35 33 ----------
36 34 from_formats : list [of string]
37 35 Formats that the converter can convert from
38 36 to_format : string
39 37 Format that the converter converts to
40 38 config : Config
41 39 Configuration file structure
42 40 **kw : misc
43 41 Additional arguments
44 42 """
45 43 super(ConvertFiguresTransformer, self).__init__(**kw)
46 44
47 45 #TODO: Configurable, singular
48 46 self._from_formats = from_formats
49 47 self._to_format = to_format
50 48
51 49
52 50 def convert_figure(self, data_format, data):
53 51 raise NotImplementedError()
54 52
55 53
56 54 def transform_cell(self, cell, resources, cell_index):
57 55 """
58 56 Apply a transformation on each cell,
59 57
60 58 See base.py
61 59 """
62 60
63 61 #Loop through all of the datatypes of the outputs in the cell.
64 62 for index, cell_out in enumerate(cell.get('outputs', [])):
65 63 for data_type, data in cell_out.items():
66 64 self._convert_figure(cell_out, data_type, data)
67 65 return cell, resources
68 66
69 67
70 68 def _convert_figure(self, cell_out, data_type, data):
71 69 """
72 70 Convert a figure and output the results to the cell output
73 71 """
74 72
75 73 if not self._to_format in cell_out:
76 74 if data_type in self._from_formats:
77 75 cell_out[self._to_format] = self.convert_figure(data_type, data)
General Comments 0
You need to be logged in to leave comments. Login now