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

Method compute_format_data

IPython/core/displayhook.py:121–151  ·  view source on GitHub ↗

Compute format data of the object to be displayed. The format data is a generalization of the :func:`repr` of an object. In the default implementation the format data is a :class:`dict` of key value pair where the keys are valid MIME types and the values are JSON'abl

(self, result)

Source from the content-addressed store, hash-verified

119 sys.stdout.write(outprompt)
120
121 def compute_format_data(self, result):
122 """Compute format data of the object to be displayed.
123
124 The format data is a generalization of the :func:`repr` of an object.
125 In the default implementation the format data is a :class:`dict` of
126 key value pair where the keys are valid MIME types and the values
127 are JSON'able data structure containing the raw data for that MIME
128 type. It is up to frontends to determine pick a MIME to to use and
129 display that data in an appropriate manner.
130
131 This method only computes the format data for the object and should
132 NOT actually print or write that to a stream.
133
134 Parameters
135 ----------
136 result : object
137 The Python object passed to the display hook, whose format will be
138 computed.
139
140 Returns
141 -------
142 (format_dict, md_dict) : dict
143 format_dict is a :class:`dict` whose keys are valid MIME types and values are
144 JSON'able raw data for that MIME type. It is recommended that
145 all return values of this should always include the "text/plain"
146 MIME type representation of the object.
147 md_dict is a :class:`dict` with the same MIME type keys
148 of metadata associated with each output.
149
150 """
151 return self.shell.display_formatter.format(result)
152
153 # This can be set to True by the write_output_prompt method in a subclass
154 prompt_end_newline = False

Callers 1

__call__Method · 0.95

Calls 1

formatMethod · 0.45

Tested by

no test coverage detected