Factory that returns a pprint function useful for sets and frozensets.
(start, end)
| 656 | |
| 657 | |
| 658 | def _set_pprinter_factory(start, end): |
| 659 | """ |
| 660 | Factory that returns a pprint function useful for sets and frozensets. |
| 661 | """ |
| 662 | def inner(obj, p, cycle): |
| 663 | if cycle: |
| 664 | return p.text(start + '...' + end) |
| 665 | if len(obj) == 0: |
| 666 | # Special case. |
| 667 | p.text(type(obj).__name__ + '()') |
| 668 | else: |
| 669 | step = len(start) |
| 670 | p.begin_group(step, start) |
| 671 | # Like dictionary keys, we will try to sort the items if there aren't too many |
| 672 | if not (p.max_seq_length and len(obj) >= p.max_seq_length): |
| 673 | items = _sorted_for_pprint(obj) |
| 674 | else: |
| 675 | items = obj |
| 676 | for idx, x in p._enumerate(items): |
| 677 | if idx: |
| 678 | p.text(',') |
| 679 | p.breakable() |
| 680 | p.pretty(x) |
| 681 | p.end_group(step, end) |
| 682 | return inner |
| 683 | |
| 684 | |
| 685 | def _dict_pprinter_factory(start, end): |
no outgoing calls
no test coverage detected
searching dependent graphs…