MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / _format

Method _format

tools/python-3.11.9-amd64/Lib/pprint.py:171–197  ·  view source on GitHub ↗
(self, object, stream, indent, allowance, context, level)

Source from the content-addressed store, hash-verified

169 return readable and not recursive
170
171 def _format(self, object, stream, indent, allowance, context, level):
172 objid = id(object)
173 if objid in context:
174 stream.write(_recursion(object))
175 self._recursive = True
176 self._readable = False
177 return
178 rep = self._repr(object, context, level)
179 max_width = self._width - indent - allowance
180 if len(rep) > max_width:
181 p = self._dispatch.get(type(object).__repr__, None)
182 if p is not None:
183 context[objid] = 1
184 p(self, object, stream, indent, allowance, context, level + 1)
185 del context[objid]
186 return
187 elif (_dataclasses.is_dataclass(object) and
188 not isinstance(object, type) and
189 object.__dataclass_params__.repr and
190 # Check dataclass has generated repr method.
191 hasattr(object.__repr__, "__wrapped__") and
192 "__create_fn__" in object.__repr__.__wrapped__.__qualname__):
193 context[objid] = 1
194 self._pprint_dataclass(object, stream, indent, allowance, context, level + 1)
195 del context[objid]
196 return
197 stream.write(rep)
198
199 def _pprint_dataclass(self, object, stream, indent, allowance, context, level):
200 cls_name = object.__class__.__name__

Callers 11

pprintMethod · 0.95
pformatMethod · 0.95
_pprint_ordered_dictMethod · 0.95
_pprint_mappingproxyMethod · 0.95
_format_dict_itemsMethod · 0.95
_format_itemsMethod · 0.95
_pprint_chain_mapMethod · 0.95
_pprint_user_dictMethod · 0.95
_pprint_user_listMethod · 0.95
_pprint_user_stringMethod · 0.95

Calls 8

_reprMethod · 0.95
_pprint_dataclassMethod · 0.95
_recursionFunction · 0.85
pFunction · 0.85
idFunction · 0.50
typeClass · 0.50
writeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected