Show More
@@ -1502,6 +1502,7 class InteractiveShell(SingletonConfigurable): | |||||
1502 | return 'not found' # so callers can take other action |
|
1502 | return 'not found' # so callers can take other action | |
1503 |
|
1503 | |||
1504 | def object_inspect(self, oname, detail_level=0): |
|
1504 | def object_inspect(self, oname, detail_level=0): | |
|
1505 | """Get object info about oname""" | |||
1505 | with self.builtin_trap: |
|
1506 | with self.builtin_trap: | |
1506 | info = self._object_find(oname) |
|
1507 | info = self._object_find(oname) | |
1507 | if info.found: |
|
1508 | if info.found: | |
@@ -1511,6 +1512,17 class InteractiveShell(SingletonConfigurable): | |||||
1511 | else: |
|
1512 | else: | |
1512 | return oinspect.object_info(name=oname, found=False) |
|
1513 | return oinspect.object_info(name=oname, found=False) | |
1513 |
|
1514 | |||
|
1515 | def object_inspect_text(self, oname, detail_level=0): | |||
|
1516 | """Get object info as formatted text""" | |||
|
1517 | with self.builtin_trap: | |||
|
1518 | info = self._object_find(oname) | |||
|
1519 | if info.found: | |||
|
1520 | return self.inspector._format_info(info.obj, oname, info=info, | |||
|
1521 | detail_level=detail_level | |||
|
1522 | ) | |||
|
1523 | else: | |||
|
1524 | raise KeyError(oname) | |||
|
1525 | ||||
1514 | #------------------------------------------------------------------------- |
|
1526 | #------------------------------------------------------------------------- | |
1515 | # Things related to history management |
|
1527 | # Things related to history management | |
1516 | #------------------------------------------------------------------------- |
|
1528 | #------------------------------------------------------------------------- |
@@ -7,12 +7,9 Similar in spirit to the inspect module, but all calls take a name argument to | |||||
7 | reference the name under which an object is being read. |
|
7 | reference the name under which an object is being read. | |
8 | """ |
|
8 | """ | |
9 |
|
9 | |||
10 | #***************************************************************************** |
|
10 | # Copyright (c) IPython Development Team. | |
11 | # Copyright (C) 2001-2004 Fernando Perez <fperez@colorado.edu> |
|
11 | # Distributed under the terms of the Modified BSD License. | |
12 | # |
|
12 | ||
13 | # Distributed under the terms of the BSD License. The full license is in |
|
|||
14 | # the file COPYING, distributed as part of this software. |
|
|||
15 | #***************************************************************************** |
|
|||
16 | from __future__ import print_function |
|
13 | from __future__ import print_function | |
17 |
|
14 | |||
18 | __all__ = ['Inspector','InspectColors'] |
|
15 | __all__ = ['Inspector','InspectColors'] | |
@@ -532,21 +529,9 class Inspector: | |||||
532 | ("Init docstring", "init_docstring"), |
|
529 | ("Init docstring", "init_docstring"), | |
533 | ("Call def", "call_def"), |
|
530 | ("Call def", "call_def"), | |
534 | ("Call docstring", "call_docstring")] |
|
531 | ("Call docstring", "call_docstring")] | |
535 |
|
532 | |||
536 |
def |
|
533 | def _format_info(self, obj, oname='', formatter=None, info=None, detail_level=0): | |
537 | """Show detailed information about an object. |
|
534 | """Format an info dict as text""" | |
538 |
|
||||
539 | Optional arguments: |
|
|||
540 |
|
||||
541 | - oname: name of the variable pointing to the object. |
|
|||
542 |
|
||||
543 | - formatter: special formatter for docstrings (see pdoc) |
|
|||
544 |
|
||||
545 | - info: a structure with some information fields which may have been |
|
|||
546 | precomputed already. |
|
|||
547 |
|
||||
548 | - detail_level: if set to 1, more information is given. |
|
|||
549 | """ |
|
|||
550 | info = self.info(obj, oname=oname, formatter=formatter, |
|
535 | info = self.info(obj, oname=oname, formatter=formatter, | |
551 | info=info, detail_level=detail_level) |
|
536 | info=info, detail_level=detail_level) | |
552 | displayfields = [] |
|
537 | displayfields = [] | |
@@ -590,11 +575,30 class Inspector: | |||||
590 | # Info for objects: |
|
575 | # Info for objects: | |
591 | else: |
|
576 | else: | |
592 | add_fields(self.pinfo_fields_obj) |
|
577 | add_fields(self.pinfo_fields_obj) | |
593 |
|
578 | |||
594 | # Finally send to printer/pager: |
|
|||
595 | if displayfields: |
|
579 | if displayfields: | |
596 |
|
|
580 | return self._format_fields(displayfields) | |
|
581 | else: | |||
|
582 | return u'' | |||
|
583 | ||||
|
584 | def pinfo(self, obj, oname='', formatter=None, info=None, detail_level=0): | |||
|
585 | """Show detailed information about an object. | |||
|
586 | ||||
|
587 | Optional arguments: | |||
|
588 | ||||
|
589 | - oname: name of the variable pointing to the object. | |||
597 |
|
|
590 | ||
|
591 | - formatter: special formatter for docstrings (see pdoc) | |||
|
592 | ||||
|
593 | - info: a structure with some information fields which may have been | |||
|
594 | precomputed already. | |||
|
595 | ||||
|
596 | - detail_level: if set to 1, more information is given. | |||
|
597 | """ | |||
|
598 | text = self._format_info(obj, oname, formatter, info, detail_level) | |||
|
599 | if text: | |||
|
600 | page.page(text) | |||
|
601 | ||||
598 | def info(self, obj, oname='', formatter=None, info=None, detail_level=0): |
|
602 | def info(self, obj, oname='', formatter=None, info=None, detail_level=0): | |
599 | """Compute a dict with detailed information about an object. |
|
603 | """Compute a dict with detailed information about an object. | |
600 |
|
604 |
General Comments 0
You need to be logged in to leave comments.
Login now