Show More
@@ -14,7 +14,6 b' import abc' | |||
|
14 | 14 | import inspect |
|
15 | 15 | import sys |
|
16 | 16 | import traceback |
|
17 | import types | |
|
18 | 17 | import warnings |
|
19 | 18 | |
|
20 | 19 | from IPython.external.decorator import decorator |
@@ -24,7 +23,7 b' from IPython.core.getipython import get_ipython' | |||
|
24 | 23 | from IPython.lib import pretty |
|
25 | 24 | from IPython.utils.traitlets import ( |
|
26 | 25 | Bool, Dict, Integer, Unicode, CUnicode, ObjectName, List, |
|
27 | Instance, | |
|
26 | ForwardDeclaredInstance, | |
|
28 | 27 | ) |
|
29 | 28 | from IPython.utils.py3compat import ( |
|
30 | 29 | unicode_to_str, with_metaclass, PY3, string_types, unicode_type, |
@@ -90,9 +89,9 b' class DisplayFormatter(Configurable):' | |||
|
90 | 89 | else: |
|
91 | 90 | formatter.enabled = False |
|
92 | 91 | |
|
93 | self_formatter = Instance(__name__ +'.SelfDisplayingFormatter') | |
|
94 |
def _ |
|
|
95 |
return |
|
|
92 | ipython_display_formatter = ForwardDeclaredInstance('FormatterABC') | |
|
93 | def _ipython_display_formatter_default(self): | |
|
94 | return IPythonDisplayFormatter(parent=self) | |
|
96 | 95 | |
|
97 | 96 | # A dict of formatter whose keys are format types (MIME types) and whose |
|
98 | 97 | # values are subclasses of BaseFormatter. |
@@ -164,7 +163,7 b' class DisplayFormatter(Configurable):' | |||
|
164 | 163 | format_dict = {} |
|
165 | 164 | md_dict = {} |
|
166 | 165 | |
|
167 |
if self. |
|
|
166 | if self.ipython_display_formatter(obj): | |
|
168 | 167 | # object handled itself, don't proceed |
|
169 | 168 | return {}, {} |
|
170 | 169 | |
@@ -840,7 +839,7 b' class PDFFormatter(BaseFormatter):' | |||
|
840 | 839 | |
|
841 | 840 | _return_type = (bytes, unicode_type) |
|
842 | 841 | |
|
843 |
class |
|
|
842 | class IPythonDisplayFormatter(BaseFormatter): | |
|
844 | 843 | """A Formatter for objects that know how to display themselves. |
|
845 | 844 | |
|
846 | 845 | To define the callables that compute the representation of your |
@@ -886,7 +885,7 b' FormatterABC.register(JPEGFormatter)' | |||
|
886 | 885 | FormatterABC.register(LatexFormatter) |
|
887 | 886 | FormatterABC.register(JSONFormatter) |
|
888 | 887 | FormatterABC.register(JavascriptFormatter) |
|
889 |
FormatterABC.register( |
|
|
888 | FormatterABC.register(IPythonDisplayFormatter) | |
|
890 | 889 | |
|
891 | 890 | |
|
892 | 891 | def format_display_data(obj, include=None, exclude=None): |
General Comments 0
You need to be logged in to leave comments.
Login now