##// END OF EJS Templates
Merge pull request #10557 from ipython/auto-backport-of-pr-10543...
Matthias Bussonnier -
r23651:e0d9c069 merge
parent child Browse files
Show More
@@ -149,7 +149,7 b' class DisplayFormatter(Configurable):'
149 # object handled itself, don't proceed
149 # object handled itself, don't proceed
150 return {}, {}
150 return {}, {}
151
151
152 format_dict, md_dict = self.mimebundle_formatter(obj)
152 format_dict, md_dict = self.mimebundle_formatter(obj, include=include, exclude=exclude)
153
153
154 if format_dict or md_dict:
154 if format_dict or md_dict:
155 if include:
155 if include:
@@ -943,6 +943,35 b' class MimeBundleFormatter(BaseFormatter):'
943 return r, {}
943 return r, {}
944 return r
944 return r
945
945
946 @catch_format_error
947 def __call__(self, obj, include=None, exclude=None):
948 """Compute the format for an object.
949
950 Identical to parent's method but we pass extra parameters to the method.
951
952 Unlike other _repr_*_ `_repr_mimebundle_` should allow extra kwargs, in
953 particular `include` and `exclude`.
954 """
955 if self.enabled:
956 # lookup registered printer
957 try:
958 printer = self.lookup(obj)
959 except KeyError:
960 pass
961 else:
962 return printer(obj)
963 # Finally look for special method names
964 method = get_real_method(obj, self.print_method)
965
966 if method is not None:
967 d = {}
968 d['include'] = include
969 d['exclude'] = include
970 return method(**d)
971 return None
972 else:
973 return None
974
946
975
947 FormatterABC.register(BaseFormatter)
976 FormatterABC.register(BaseFormatter)
948 FormatterABC.register(PlainTextFormatter)
977 FormatterABC.register(PlainTextFormatter)
@@ -440,7 +440,7 b' def test_json_as_string_deprecated():'
440
440
441 def test_repr_mime():
441 def test_repr_mime():
442 class HasReprMime(object):
442 class HasReprMime(object):
443 def _repr_mimebundle_(self):
443 def _repr_mimebundle_(self, include=None, exclude=None):
444 return {
444 return {
445 'application/json+test.v2': {
445 'application/json+test.v2': {
446 'x': 'y'
446 'x': 'y'
@@ -477,7 +477,7 b' def test_repr_mime():'
477
477
478 def test_repr_mime_meta():
478 def test_repr_mime_meta():
479 class HasReprMimeMeta(object):
479 class HasReprMimeMeta(object):
480 def _repr_mimebundle_(self):
480 def _repr_mimebundle_(self, include=None, exclude=None):
481 data = {
481 data = {
482 'image/png': 'base64-image-data',
482 'image/png': 'base64-image-data',
483 }
483 }
General Comments 0
You need to be logged in to leave comments. Login now