Show More
@@ -1,30 +1,31 b'' | |||||
1 | """Filter used to select the first preferred output format available. |
|
1 | """Filter used to select the first preferred output format available. | |
2 |
|
2 | |||
3 | The filter contained in the file allows the converter templates to select |
|
3 | The filter contained in the file allows the converter templates to select | |
4 | the output format that is most valuable to the active export format. The |
|
4 | the output format that is most valuable to the active export format. The | |
5 | value of the different formats is set via |
|
5 | value of the different formats is set via | |
6 | GlobalConfigurable.display_data_priority |
|
6 | GlobalConfigurable.display_data_priority | |
7 | """ |
|
7 | """ | |
8 | #----------------------------------------------------------------------------- |
|
8 | #----------------------------------------------------------------------------- | |
9 | # Copyright (c) 2013, the IPython Development Team. |
|
9 | # Copyright (c) 2013, the IPython Development Team. | |
10 | # |
|
10 | # | |
11 | # Distributed under the terms of the Modified BSD License. |
|
11 | # Distributed under the terms of the Modified BSD License. | |
12 | # |
|
12 | # | |
13 | # The full license is in the file COPYING.txt, distributed with this software. |
|
13 | # The full license is in the file COPYING.txt, distributed with this software. | |
14 | #----------------------------------------------------------------------------- |
|
14 | #----------------------------------------------------------------------------- | |
15 |
|
15 | |||
16 | #----------------------------------------------------------------------------- |
|
16 | #----------------------------------------------------------------------------- | |
17 | # Classes and functions |
|
17 | # Classes and functions | |
18 | #----------------------------------------------------------------------------- |
|
18 | #----------------------------------------------------------------------------- | |
|
19 | ||||
19 | class DataTypeFilter(object): |
|
20 | class DataTypeFilter(object): | |
20 | """ Returns the preferred display format """ |
|
21 | """ Returns the preferred display format """ | |
21 |
|
22 | |||
22 | display_data_priority = ['html', 'pdf', 'svg', 'latex', 'png', 'jpg', 'jpeg' , 'text'] |
|
23 | display_data_priority = ['html', 'pdf', 'svg', 'latex', 'png', 'jpg', 'jpeg' , 'text'] | |
23 |
|
24 | |||
24 | def __call__(self, output): |
|
25 | def __call__(self, output): | |
25 | """ Return the first available format in the priority """ |
|
26 | """ Return the first available format in the priority """ | |
26 |
|
27 | |||
27 | for fmt in self.display_data_priority: |
|
28 | for fmt in self.display_data_priority: | |
28 | if fmt in output: |
|
29 | if fmt in output: | |
29 | return [fmt] |
|
30 | return [fmt] | |
30 | return [] No newline at end of file |
|
31 | return [] |
General Comments 0
You need to be logged in to leave comments.
Login now