Show More
@@ -196,18 +196,9 b' class DisplayHook(Configurable):' | |||||
196 | """Compute and return the repr of the object to be displayed. |
|
196 | """Compute and return the repr of the object to be displayed. | |
197 |
|
197 | |||
198 | This method only compute the string form of the repr and should NOT |
|
198 | This method only compute the string form of the repr and should NOT | |
199 | actual print or write that to a stream. |
|
199 | actually print or write that to a stream. | |
200 | """ |
|
200 | """ | |
201 | result_repr = self.default_formatter(result) |
|
201 | result_repr = self.default_formatter(result) | |
202 | if '\n' in result_repr: |
|
|||
203 | # So that multi-line strings line up with the left column of |
|
|||
204 | # the screen, instead of having the output prompt mess up |
|
|||
205 | # their first line. |
|
|||
206 | outprompt = str(self.prompt_out) |
|
|||
207 | if outprompt and not outprompt.endswith('\n'): |
|
|||
208 | # But avoid extraneous empty lines. |
|
|||
209 | result_repr = '\n' + result_repr |
|
|||
210 |
|
||||
211 | extra_formats = [] |
|
202 | extra_formats = [] | |
212 | for f in self.extra_formatters: |
|
203 | for f in self.extra_formatters: | |
213 | try: |
|
204 | try: | |
@@ -224,6 +215,18 b' class DisplayHook(Configurable):' | |||||
224 | # We want to print because we want to always make sure we have a |
|
215 | # We want to print because we want to always make sure we have a | |
225 | # newline, even if all the prompt separators are ''. This is the |
|
216 | # newline, even if all the prompt separators are ''. This is the | |
226 | # standard IPython behavior. |
|
217 | # standard IPython behavior. | |
|
218 | if '\n' in result_repr: | |||
|
219 | # So that multi-line strings line up with the left column of | |||
|
220 | # the screen, instead of having the output prompt mess up | |||
|
221 | # their first line. | |||
|
222 | # We use the ps_out_str template instead of the expanded prompt | |||
|
223 | # because the expansion may add ANSI escapes that will interfere | |||
|
224 | # with our ability to determine whether or not we should add | |||
|
225 | # a newline. | |||
|
226 | if self.ps_out_str and not self.ps_out_str.endswith('\n'): | |||
|
227 | # But avoid extraneous empty lines. | |||
|
228 | result_repr = '\n' + result_repr | |||
|
229 | ||||
227 | print >>IPython.utils.io.Term.cout, result_repr |
|
230 | print >>IPython.utils.io.Term.cout, result_repr | |
228 |
|
231 | |||
229 | def update_user_ns(self, result): |
|
232 | def update_user_ns(self, result): |
@@ -31,20 +31,29 b' a function.' | |||||
31 |
|
31 | |||
32 | See the `IPython.external.pretty` documentation for how to write |
|
32 | See the `IPython.external.pretty` documentation for how to write | |
33 | pretty-printer functions. |
|
33 | pretty-printer functions. | |
34 |
|
||||
35 | Authors: |
|
|||
36 |
|
||||
37 | * Robert Kern |
|
|||
38 | """ |
|
34 | """ | |
39 |
|
35 | #----------------------------------------------------------------------------- | ||
|
36 | # Copyright (c) 2010, IPython Development Team. | |||
|
37 | # | |||
|
38 | # Distributed under the terms of the Modified BSD License. | |||
|
39 | # | |||
|
40 | # The full license is in the file COPYING.txt, distributed with this software. | |||
|
41 | #----------------------------------------------------------------------------- | |||
|
42 | ||||
|
43 | # Stdlib imports | |||
40 | import abc |
|
44 | import abc | |
41 | from cStringIO import StringIO |
|
45 | from cStringIO import StringIO | |
42 |
|
46 | |||
|
47 | # Our own imports | |||
43 | from IPython.config.configurable import Configurable |
|
48 | from IPython.config.configurable import Configurable | |
44 | from IPython.external import pretty |
|
49 | from IPython.external import pretty | |
45 | from IPython.utils.traitlets import Bool, Dict, Int, Str |
|
50 | from IPython.utils.traitlets import Bool, Dict, Int, Str | |
46 |
|
51 | |||
47 |
|
52 | |||
|
53 | #----------------------------------------------------------------------------- | |||
|
54 | # Classes and functions | |||
|
55 | #----------------------------------------------------------------------------- | |||
|
56 | ||||
48 | class DefaultFormatter(Configurable): |
|
57 | class DefaultFormatter(Configurable): | |
49 | """ The default pretty-printer. |
|
58 | """ The default pretty-printer. | |
50 | """ |
|
59 | """ |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now