Show More
@@ -149,27 +149,30 b' class DisplayFormatter(Configurable):' | |||
|
149 | 149 | format_dict = {} |
|
150 | 150 | md_dict = {} |
|
151 | 151 | |
|
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 |
|
|
|
161 | except: | |
|
162 | # FIXME: log the exception | |
|
163 |
|
|
|
164 | ||
|
165 | # formatters can return raw data or (data, metadata) | |
|
166 | if isinstance(data, tuple) and len(data) == 2: | |
|
167 |
|
|
|
168 | ||
|
169 | if data is not None: | |
|
170 |
|
|
|
171 |
|
|
|
172 | md_dict[format_type] = md | |
|
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 | continue | |
|
158 | if exclude and format_type in exclude: | |
|
159 | continue | |
|
160 | ||
|
161 | md = None | |
|
162 | try: | |
|
163 | data = formatter(obj) | |
|
164 | except: | |
|
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 | data, md = data | |
|
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 | |
|
173 | 176 | |
|
174 | 177 | return format_dict, md_dict |
|
175 | 178 |
General Comments 0
You need to be logged in to leave comments.
Login now