MCPcopy Index your code
hub / github.com/python/cpython / _pprint_simplenamespace

Method _pprint_simplenamespace

Lib/pprint.py:513–528  ·  view source on GitHub ↗
(self, object, stream, indent, allowance, context, level)

Source from the content-addressed store, hash-verified

511 _dispatch[_types.MappingProxyType.__repr__] = _pprint_mappingproxy
512
513 def _pprint_simplenamespace(self, object, stream, indent, allowance, context, level):
514 if type(object) is _types.SimpleNamespace:
515 # The SimpleNamespace repr is "namespace" instead of the class
516 # name, so we do the same here. For subclasses; use the class name.
517 cls_name = 'namespace'
518 else:
519 cls_name = object.__class__.__name__
520 if self._expand:
521 indent += self._indent_per_level
522 else:
523 indent += len(cls_name) + 1
524 items = object.__dict__.items()
525 stream.write(self._format_block_start(cls_name + '(', indent))
526 self._format_namespace_items(items, stream, indent, allowance, context,
527 level)
528 stream.write(self._format_block_end(')', indent - self._indent_per_level))
529
530 _dispatch[_types.SimpleNamespace.__repr__] = _pprint_simplenamespace
531

Callers

nothing calls this directly

Calls 5

_format_block_startMethod · 0.95
_format_block_endMethod · 0.95
itemsMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected