datatypefilter.py
33 lines
| 1.2 KiB
| text/x-python
|
PythonLexer
Jonathan Frederic
|
r10624 | """Filter used to select the first preferred output format available. | ||
Jonathan Frederic
|
r10436 | |||
The filter contained in the file allows the converter templates to select | ||||
the output format that is most valuable to the active export format. The | ||||
value of the different formats is set via | ||||
Jonathan Frederic
|
r11419 | NbConvertBase.display_data_priority | ||
Jonathan Frederic
|
r10436 | """ | ||
#----------------------------------------------------------------------------- | ||||
# Copyright (c) 2013, the IPython Development Team. | ||||
# | ||||
# Distributed under the terms of the Modified BSD License. | ||||
# | ||||
# The full license is in the file COPYING.txt, distributed with this software. | ||||
#----------------------------------------------------------------------------- | ||||
#----------------------------------------------------------------------------- | ||||
# Classes and functions | ||||
#----------------------------------------------------------------------------- | ||||
Jonathan Frederic
|
r10691 | |||
Jonathan Frederic
|
r11420 | from ..utils.base import NbConvertBase | ||
Matthias BUSSONNIER
|
r10859 | |||
Brian E. Granger
|
r11088 | __all__ = ['DataTypeFilter'] | ||
Jonathan Frederic
|
r11419 | class DataTypeFilter(NbConvertBase): | ||
Jonathan Frederic
|
r10624 | """ Returns the preferred display format """ | ||
Jonathan Frederic
|
r11547 | |||
Jonathan Frederic
|
r10436 | def __call__(self, output): | ||
""" Return the first available format in the priority """ | ||||
for fmt in self.display_data_priority: | ||||
if fmt in output: | ||||
return [fmt] | ||||
Matthias BUSSONNIER
|
r10859 | return [] | ||