Factory that returns a pprint function used by the default pprint of dicts and dict proxies.
(start, end)
| 588 | |
| 589 | |
| 590 | def _dict_pprinter_factory(start, end): |
| 591 | """ |
| 592 | Factory that returns a pprint function used by the default pprint of |
| 593 | dicts and dict proxies. |
| 594 | """ |
| 595 | def inner(obj, p, cycle): |
| 596 | if cycle: |
| 597 | return p.text('{...}') |
| 598 | step = len(start) |
| 599 | p.begin_group(step, start) |
| 600 | keys = obj.keys() |
| 601 | for idx, key in p._enumerate(keys): |
| 602 | if idx: |
| 603 | p.text(',') |
| 604 | p.breakable() |
| 605 | p.pretty(key) |
| 606 | p.text(': ') |
| 607 | p.pretty(obj[key]) |
| 608 | p.end_group(step, end) |
| 609 | return inner |
| 610 | |
| 611 | |
| 612 | def _super_pprint(obj, p, cycle): |