##// END OF EJS Templates
handle missing 'text/plain' in displayhook...
MinRK -
Show More
@@ -2,25 +2,11 b''
2 """Displayhook for IPython.
2 """Displayhook for IPython.
3
3
4 This defines a callable class that IPython uses for `sys.displayhook`.
4 This defines a callable class that IPython uses for `sys.displayhook`.
5
6 Authors:
7
8 * Fernando Perez
9 * Brian Granger
10 * Robert Kern
11 """
5 """
12
6
13 #-----------------------------------------------------------------------------
7 # Copyright (c) IPython Development Team.
14 # Copyright (C) 2008-2011 The IPython Development Team
8 # Distributed under the terms of the Modified BSD License.
15 # Copyright (C) 2001-2007 Fernando Perez <fperez@colorado.edu>
9
16 #
17 # Distributed under the terms of the BSD License. The full license is in
18 # the file COPYING, distributed as part of this software.
19 #-----------------------------------------------------------------------------
20
21 #-----------------------------------------------------------------------------
22 # Imports
23 #-----------------------------------------------------------------------------
24 from __future__ import print_function
10 from __future__ import print_function
25
11
26 import sys
12 import sys
@@ -32,10 +18,6 b' from IPython.utils.py3compat import builtin_mod'
32 from IPython.utils.traitlets import Instance
18 from IPython.utils.traitlets import Instance
33 from IPython.utils.warn import warn
19 from IPython.utils.warn import warn
34
20
35 #-----------------------------------------------------------------------------
36 # Main displayhook class
37 #-----------------------------------------------------------------------------
38
39 # TODO: Move the various attributes (cache_size, [others now moved]). Some
21 # TODO: Move the various attributes (cache_size, [others now moved]). Some
40 # of these are also attributes of InteractiveShell. They should be on ONE object
22 # of these are also attributes of InteractiveShell. They should be on ONE object
41 # only and the other objects should ask that one object for their values.
23 # only and the other objects should ask that one object for their values.
@@ -168,6 +150,9 b' class DisplayHook(Configurable):'
168 md_dict : dict (optional)
150 md_dict : dict (optional)
169 The metadata dict to be associated with the display data.
151 The metadata dict to be associated with the display data.
170 """
152 """
153 if 'text/plain' not in format_dict:
154 # nothing to do
155 return
171 # We want to print because we want to always make sure we have a
156 # We want to print because we want to always make sure we have a
172 # newline, even if all the prompt separators are ''. This is the
157 # newline, even if all the prompt separators are ''. This is the
173 # standard IPython behavior.
158 # standard IPython behavior.
@@ -221,6 +206,9 b' class DisplayHook(Configurable):'
221
206
222 def log_output(self, format_dict):
207 def log_output(self, format_dict):
223 """Log the output."""
208 """Log the output."""
209 if 'text/plain' not in format_dict:
210 # nothing to do
211 return
224 if self.shell.logger.log_output:
212 if self.shell.logger.log_output:
225 self.shell.logger.log_write(format_dict['text/plain'], 'output')
213 self.shell.logger.log_write(format_dict['text/plain'], 'output')
226 self.shell.history_manager.output_hist_reprs[self.prompt_count] = \
214 self.shell.history_manager.output_hist_reprs[self.prompt_count] = \
General Comments 0
You need to be logged in to leave comments. Login now