The default print function. Used if an object does not provide one and it's none of the builtin objects.
(obj, p, cycle)
| 596 | |
| 597 | |
| 598 | def _default_pprint(obj, p, cycle): |
| 599 | """ |
| 600 | The default print function. Used if an object does not provide one and |
| 601 | it's none of the builtin objects. |
| 602 | """ |
| 603 | klass = _safe_getattr(obj, '__class__', None) or type(obj) |
| 604 | if _safe_getattr(klass, '__repr__', None) is not object.__repr__: |
| 605 | # A user-provided repr. Find newlines and replace them with p.break_() |
| 606 | _repr_pprint(obj, p, cycle) |
| 607 | return |
| 608 | p.begin_group(1, '<') |
| 609 | p.pretty(klass) |
| 610 | p.text(' at 0x%x' % id(obj)) |
| 611 | if cycle: |
| 612 | p.text(' ...') |
| 613 | elif p.verbose: |
| 614 | first = True |
| 615 | for key in dir(obj): |
| 616 | if not key.startswith('_'): |
| 617 | try: |
| 618 | value = getattr(obj, key) |
| 619 | except AttributeError: |
| 620 | continue |
| 621 | if isinstance(value, types.MethodType): |
| 622 | continue |
| 623 | if not first: |
| 624 | p.text(',') |
| 625 | p.breakable() |
| 626 | p.text(key) |
| 627 | p.text('=') |
| 628 | step = len(key) + 1 |
| 629 | p.indentation += step |
| 630 | p.pretty(value) |
| 631 | p.indentation -= step |
| 632 | first = False |
| 633 | p.end_group(1, '>') |
| 634 | |
| 635 | |
| 636 | def _seq_pprinter_factory(start, end): |
no test coverage detected
searching dependent graphs…