MCPcopy Create free account
hub / github.com/ipython/ipython / format

Method format

IPython/core/formatters.py:89–193  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

87 return d
88
89 def format(self, obj, include=None, exclude=None):
90 """Return a format data dict for an object.
91
92 By default all format types will be computed.
93
94 The following MIME types are usually implemented:
95
96 * text/plain
97 * text/html
98 * text/markdown
99 * text/latex
100 * application/json
101 * application/javascript
102 * application/pdf
103 * image/png
104 * image/jpeg
105 * image/svg+xml
106
107 Parameters
108 ----------
109 obj : object
110 The Python object whose format data will be computed.
111 include : list, tuple or set; optional
112 A list of format type strings (MIME types) to include in the
113 format data dict. If this is set *only* the format types included
114 in this list will be computed.
115 exclude : list, tuple or set; optional
116 A list of format type string (MIME types) to exclude in the format
117 data dict. If this is set all format types will be computed,
118 except for those included in this argument.
119 Mimetypes present in exclude will take precedence over the ones in include
120
121 Returns
122 -------
123 (format_dict, metadata_dict) : tuple of two dicts
124
125 format_dict is a dictionary of key/value pairs, one of each format that was
126 generated for the object. The keys are the format types, which
127 will usually be MIME type strings and the values and JSON'able
128 data structure containing the raw data for the representation in
129 that format.
130
131 metadata_dict is a dictionary of metadata about each mime-type output.
132 Its keys will be a strict subset of the keys in format_dict.
133
134 Notes
135 -----
136
137 If an object implement `_repr_mimebundle_` as well as various
138 `_repr_*_`, the data returned by `_repr_mimebundle_` will take
139 precedence and the corresponding `_repr_*_` for this mimetype will
140 not be called.
141
142 """
143 format_dict = {}
144 md_dict = {}
145
146 if self.ipython_display_formatter(obj):

Callers 15

initialize_subcommandMethod · 0.45
_detect_screen_sizeFunction · 0.45
_pseudo_sync_runnerFunction · 0.45
_asyncifyFunction · 0.45
unregisterMethod · 0.45
triggerMethod · 0.45
code_nameFunction · 0.45
InteractiveShellAppClass · 0.45
init_extensionsMethod · 0.45
getargsFunction · 0.45
__init__Method · 0.45
__repr__Method · 0.45

Calls 1

lookupMethod · 0.80

Tested by 15

test_repr_mimeFunction · 0.36
test_repr_mime_metaFunction · 0.36
test_repr_mime_failureFunction · 0.36
test_alias_lifecycleFunction · 0.36
test_no_depMethod · 0.36
test_syntaxMethod · 0.36
test_find_next_indentFunction · 0.36
test_progress_iterFunction · 0.36