Return a format data dict for an object. By default all format types will be computed. The following MIME types are usually implemented: * text/plain * text/html * text/markdown * text/latex * application/json * application/javascrip
(self, obj, include=None, exclude=None)
| 147 | return d |
| 148 | |
| 149 | def format(self, obj, include=None, exclude=None): |
| 150 | """Return a format data dict for an object. |
| 151 | |
| 152 | By default all format types will be computed. |
| 153 | |
| 154 | The following MIME types are usually implemented: |
| 155 | |
| 156 | * text/plain |
| 157 | * text/html |
| 158 | * text/markdown |
| 159 | * text/latex |
| 160 | * application/json |
| 161 | * application/javascript |
| 162 | * application/pdf |
| 163 | * image/png |
| 164 | * image/jpeg |
| 165 | * image/svg+xml |
| 166 | |
| 167 | Parameters |
| 168 | ---------- |
| 169 | obj : object |
| 170 | The Python object whose format data will be computed. |
| 171 | include : list, tuple or set; optional |
| 172 | A list of format type strings (MIME types) to include in the |
| 173 | format data dict. If this is set *only* the format types included |
| 174 | in this list will be computed. |
| 175 | exclude : list, tuple or set; optional |
| 176 | A list of format type string (MIME types) to exclude in the format |
| 177 | data dict. If this is set all format types will be computed, |
| 178 | except for those included in this argument. |
| 179 | Mimetypes present in exclude will take precedence over the ones in include |
| 180 | |
| 181 | Returns |
| 182 | ------- |
| 183 | (format_dict, metadata_dict) : tuple of two dicts |
| 184 | format_dict is a dictionary of key/value pairs, one of each format that was |
| 185 | generated for the object. The keys are the format types, which |
| 186 | will usually be MIME type strings and the values and JSON'able |
| 187 | data structure containing the raw data for the representation in |
| 188 | that format. |
| 189 | |
| 190 | metadata_dict is a dictionary of metadata about each mime-type output. |
| 191 | Its keys will be a strict subset of the keys in format_dict. |
| 192 | |
| 193 | Notes |
| 194 | ----- |
| 195 | If an object implement `_repr_mimebundle_` as well as various |
| 196 | `_repr_*_`, the data returned by `_repr_mimebundle_` will take |
| 197 | precedence and the corresponding `_repr_*_` for this mimetype will |
| 198 | not be called. |
| 199 | |
| 200 | """ |
| 201 | format_dict = {} |
| 202 | md_dict = {} |
| 203 | |
| 204 | if self.ipython_display_formatter(obj): |
| 205 | # object handled itself, don't proceed |
| 206 | return {}, {} |
no test coverage detected