Show More
@@ -241,13 +241,16 class DisplayHook(Configurable): | |||
|
241 | 241 | """ |
|
242 | 242 | self.check_for_underscore() |
|
243 | 243 | if result is not None and not self.quiet(): |
|
244 | self.start_displayhook() | |
|
245 | self.write_output_prompt() | |
|
246 | format_dict, md_dict = self.compute_format_data(result) | |
|
247 | self.write_format_data(format_dict, md_dict) | |
|
248 | self.update_user_ns(result) | |
|
249 | self.log_output(format_dict) | |
|
250 | self.finish_displayhook() | |
|
244 | # If _ipython_display_ is defined, use that to display this object. If | |
|
245 | # it returns NotImplemented, use the _repr_ logic (default). | |
|
246 | if not hasattr(result, '_ipython_display_') or result._ipython_display_() == NotImplemented: | |
|
247 | self.start_displayhook() | |
|
248 | self.write_output_prompt() | |
|
249 | format_dict, md_dict = self.compute_format_data(result) | |
|
250 | self.write_format_data(format_dict, md_dict) | |
|
251 | self.update_user_ns(result) | |
|
252 | self.log_output(format_dict) | |
|
253 | self.finish_displayhook() | |
|
251 | 254 | |
|
252 | 255 | def flush(self): |
|
253 | 256 | if not self.do_full_cache: |
@@ -149,30 +149,27 class DisplayFormatter(Configurable): | |||
|
149 | 149 | format_dict = {} |
|
150 | 150 | md_dict = {} |
|
151 | 151 | |
|
152 | # If _ipython_display_ is defined, use that to display this object. If | |
|
153 | # it returns NotImplemented, use the _repr_ logic (default). | |
|
154 | if not hasattr(obj, '_ipython_display_') or obj._ipython_display_(**kwargs) == NotImplemented: | |
|
155 | for format_type, formatter in self.formatters.items(): | |
|
156 | if include and format_type not in include: | |
|
157 |
|
|
|
158 | if exclude and format_type in exclude: | |
|
159 | continue | |
|
160 | ||
|
161 | md = None | |
|
162 | try: | |
|
163 | data = formatter(obj) | |
|
164 |
|
|
|
165 | # FIXME: log the exception | |
|
166 | raise | |
|
167 | ||
|
168 | # formatters can return raw data or (data, metadata) | |
|
169 | if isinstance(data, tuple) and len(data) == 2: | |
|
170 |
|
|
|
171 | ||
|
172 | if data is not None: | |
|
173 | format_dict[format_type] = data | |
|
174 | if md is not None: | |
|
175 | md_dict[format_type] = md | |
|
152 | for format_type, formatter in self.formatters.items(): | |
|
153 | if include and format_type not in include: | |
|
154 | continue | |
|
155 | if exclude and format_type in exclude: | |
|
156 | continue | |
|
157 | ||
|
158 | md = None | |
|
159 | try: | |
|
160 | data = formatter(obj) | |
|
161 | except: | |
|
162 | # FIXME: log the exception | |
|
163 | raise | |
|
164 | ||
|
165 | # formatters can return raw data or (data, metadata) | |
|
166 | if isinstance(data, tuple) and len(data) == 2: | |
|
167 | data, md = data | |
|
168 | ||
|
169 | if data is not None: | |
|
170 | format_dict[format_type] = data | |
|
171 | if md is not None: | |
|
172 | md_dict[format_type] = md | |
|
176 | 173 | |
|
177 | 174 | return format_dict, md_dict |
|
178 | 175 |
General Comments 0
You need to be logged in to leave comments.
Login now