Factory that returns a pprint function useful for sequences. Used by the default pprint for tuples and lists.
(start, end)
| 634 | |
| 635 | |
| 636 | def _seq_pprinter_factory(start, end): |
| 637 | """ |
| 638 | Factory that returns a pprint function useful for sequences. Used by |
| 639 | the default pprint for tuples and lists. |
| 640 | """ |
| 641 | def inner(obj, p, cycle): |
| 642 | if cycle: |
| 643 | return p.text(start + '...' + end) |
| 644 | step = len(start) |
| 645 | p.begin_group(step, start) |
| 646 | for idx, x in p._enumerate(obj): |
| 647 | if idx: |
| 648 | p.text(',') |
| 649 | p.breakable() |
| 650 | p.pretty(x) |
| 651 | if len(obj) == 1 and isinstance(obj, tuple): |
| 652 | # Special case for 1-item tuples. |
| 653 | p.text(',') |
| 654 | p.end_group(step, end) |
| 655 | return inner |
| 656 | |
| 657 | |
| 658 | def _set_pprinter_factory(start, end): |
no outgoing calls
no test coverage detected
searching dependent graphs…