MCPcopy Index your code
hub / github.com/RustPython/RustPython / _format_items

Method _format_items

Lib/pprint.py:431–470  ·  view source on GitHub ↗
(self, items, stream, indent, allowance, context, level)

Source from the content-addressed store, hash-verified

429 write(delimnl)
430
431 def _format_items(self, items, stream, indent, allowance, context, level):
432 write = stream.write
433 indent += self._indent_per_level
434 if self._indent_per_level > 1:
435 write((self._indent_per_level - 1) * ' ')
436 delimnl = ',\n' + ' ' * indent
437 delim = ''
438 width = max_width = self._width - indent + 1
439 it = iter(items)
440 try:
441 next_ent = next(it)
442 except StopIteration:
443 return
444 last = False
445 while not last:
446 ent = next_ent
447 try:
448 next_ent = next(it)
449 except StopIteration:
450 last = True
451 max_width -= allowance
452 width -= allowance
453 if self._compact:
454 rep = self._repr(ent, context, level)
455 w = len(rep) + 2
456 if width < w:
457 width = max_width
458 if delim:
459 delim = delimnl
460 if width >= w:
461 width -= w
462 write(delim)
463 delim = ', '
464 write(rep)
465 continue
466 write(delim)
467 delim = delimnl
468 self._format(ent, stream, indent,
469 allowance if last else 1,
470 context, level)
471
472 def _repr(self, object, context, level):
473 repr, readable, recursive = self.format(object, context.copy(),

Callers 4

_pprint_listMethod · 0.95
_pprint_tupleMethod · 0.95
_pprint_setMethod · 0.95
_pprint_dequeMethod · 0.95

Calls 6

_reprMethod · 0.95
_formatMethod · 0.95
iterFunction · 0.85
nextFunction · 0.85
lenFunction · 0.85
writeFunction · 0.70

Tested by

no test coverage detected