The default pretty-printer. This uses :mod:`IPython.lib.pretty` to compute the format data of the object. If the object cannot be pretty printed, :func:`repr` is used. See the documentation of :mod:`IPython.lib.pretty` for details on how to write pretty printers. Here is a simple e
| 629 | |
| 630 | |
| 631 | class PlainTextFormatter(BaseFormatter): |
| 632 | """The default pretty-printer. |
| 633 | |
| 634 | This uses :mod:`IPython.lib.pretty` to compute the format data of |
| 635 | the object. If the object cannot be pretty printed, :func:`repr` is used. |
| 636 | See the documentation of :mod:`IPython.lib.pretty` for details on |
| 637 | how to write pretty printers. Here is a simple example:: |
| 638 | |
| 639 | def dtype_pprinter(obj, p, cycle): |
| 640 | if cycle: |
| 641 | return p.text('dtype(...)') |
| 642 | if hasattr(obj, 'fields'): |
| 643 | if obj.fields is None: |
| 644 | p.text(repr(obj)) |
| 645 | else: |
| 646 | p.begin_group(7, 'dtype([') |
| 647 | for i, field in enumerate(obj.descr): |
| 648 | if i > 0: |
| 649 | p.text(',') |
| 650 | p.breakable() |
| 651 | p.pretty(field) |
| 652 | p.end_group(7, '])') |
| 653 | """ |
| 654 | |
| 655 | # The format type of data returned. |
| 656 | format_type = Unicode('text/plain') |
| 657 | |
| 658 | # This subclass ignores this attribute as it always need to return |
| 659 | # something. |
| 660 | enabled = Bool(True).tag(config=False) |
| 661 | |
| 662 | max_seq_length = Integer(pretty.MAX_SEQ_LENGTH, |
| 663 | help="""Truncate large collections (lists, dicts, tuples, sets) to this size. |
| 664 | |
| 665 | Set to 0 to disable truncation. |
| 666 | """, |
| 667 | ).tag(config=True) |
| 668 | |
| 669 | # Look for a _repr_pretty_ methods to use for pretty printing. |
| 670 | print_method = ObjectName('_repr_pretty_') |
| 671 | |
| 672 | # Whether to pretty-print or not. |
| 673 | pprint = Bool(True).tag(config=True) |
| 674 | |
| 675 | # Whether to be verbose or not. |
| 676 | verbose = Bool(False).tag(config=True) |
| 677 | |
| 678 | # The maximum width. |
| 679 | max_width = Integer(79).tag(config=True) |
| 680 | |
| 681 | # The newline character. |
| 682 | newline = Unicode('\n').tag(config=True) |
| 683 | |
| 684 | # format-string for pprinting floats |
| 685 | float_format = Unicode('%r') |
| 686 | # setter for float precision, either int or direct format-string |
| 687 | float_precision = CUnicode('').tag(config=True) |
| 688 |
no outgoing calls
searching dependent graphs…