Show More
@@ -23,6 +23,7 b' from __future__ import print_function, absolute_import' | |||||
23 | # Stdlib imports |
|
23 | # Stdlib imports | |
24 | import io |
|
24 | import io | |
25 | import os |
|
25 | import os | |
|
26 | import inspect | |||
26 |
|
27 | |||
27 | # IPython imports |
|
28 | # IPython imports | |
28 | from IPython.config.configurable import Configurable |
|
29 | from IPython.config.configurable import Configurable | |
@@ -151,20 +152,26 b' class Exporter(Configurable):' | |||||
151 |
|
152 | |||
152 |
|
153 | |||
153 | def register_transformer(self, transformer): |
|
154 | def register_transformer(self, transformer): | |
154 |
if i |
|
155 | if inspect.isfunction(transformer): | |
|
156 | self.preprocessors.append(transformer) | |||
|
157 | return transformer | |||
|
158 | elif isinstance(transformer, MetaHasTraits): | |||
155 | transformer_instance = transformer(config=self.config) |
|
159 | transformer_instance = transformer(config=self.config) | |
156 | self.preprocessors.append(transformer_instance) |
|
160 | self.preprocessors.append(transformer_instance) | |
157 | return transformer_instance |
|
161 | return transformer_instance | |
158 | else: |
|
162 | else: | |
159 | self.preprocessors.append(transformer) |
|
163 | transformer_instance = transformer() | |
160 |
|
|
164 | self.preprocessors.append(transformer_instance) | |
|
165 | return transformer_instance | |||
161 |
|
166 | |||
162 |
|
167 | |||
163 | def register_filter(self, name, filter): |
|
168 | def register_filter(self, name, filter): | |
164 |
if i |
|
169 | if inspect.isfunction(filter): | |
|
170 | self.environment.filters[name] = filter | |||
|
171 | elif isinstance(filter, MetaHasTraits): | |||
165 | self.environment.filters[name] = filter(config=self.config) |
|
172 | self.environment.filters[name] = filter(config=self.config) | |
166 | else: |
|
173 | else: | |
167 | self.environment.filters[name] = filter |
|
174 | self.environment.filters[name] = filter() | |
168 | return self.environment.filters[name] |
|
175 | return self.environment.filters[name] | |
169 |
|
176 | |||
170 |
|
177 |
@@ -19,16 +19,7 b' GlobalConfigurable.display_data_priority' | |||||
19 | class DataTypeFilter(object): |
|
19 | class DataTypeFilter(object): | |
20 | """ Returns the preferred display format """ |
|
20 | """ Returns the preferred display format """ | |
21 |
|
21 | |||
22 | display_data_priority = None |
|
22 | display_data_priority = ['html', 'pdf', 'svg', 'latex', 'png', 'jpg', 'jpeg' , 'text'] | |
23 |
|
||||
24 | def __init__(self, display_data_priority): |
|
|||
25 |
|
||||
26 | #Make sure that the display data priority variably is not None. |
|
|||
27 | if display_data_priority is None: |
|
|||
28 | raise TypeError |
|
|||
29 | else: |
|
|||
30 | self.display_data_priority = display_data_priority |
|
|||
31 |
|
||||
32 |
|
23 | |||
33 | def __call__(self, output): |
|
24 | def __call__(self, output): | |
34 | """ Return the first available format in the priority """ |
|
25 | """ Return the first available format in the priority """ |
General Comments 0
You need to be logged in to leave comments.
Login now