Show More
@@ -34,7 +34,7 b' from IPython.core import page' | |||||
34 | from IPython.core import prefilter |
|
34 | from IPython.core import prefilter | |
35 | from IPython.core import shadowns |
|
35 | from IPython.core import shadowns | |
36 | from IPython.core import ultratb |
|
36 | from IPython.core import ultratb | |
37 |
from IPython.core.alias import Alias |
|
37 | from IPython.core.alias import Alias, AliasManager | |
38 | from IPython.core.autocall import ExitAutocall |
|
38 | from IPython.core.autocall import ExitAutocall | |
39 | from IPython.core.builtin_trap import BuiltinTrap |
|
39 | from IPython.core.builtin_trap import BuiltinTrap | |
40 | from IPython.core.events import EventManager, available_events |
|
40 | from IPython.core.events import EventManager, available_events | |
@@ -1502,6 +1502,7 b' class InteractiveShell(SingletonConfigurable):' | |||||
1502 | found = True |
|
1502 | found = True | |
1503 | ospace = 'IPython internal' |
|
1503 | ospace = 'IPython internal' | |
1504 | ismagic = True |
|
1504 | ismagic = True | |
|
1505 | isalias = isinstance(obj, Alias) | |||
1505 |
|
1506 | |||
1506 | # Last try: special-case some literals like '', [], {}, etc: |
|
1507 | # Last try: special-case some literals like '', [], {}, etc: | |
1507 | if not found and oname_head in ["''",'""','[]','{}','()']: |
|
1508 | if not found and oname_head in ["''",'""','[]','{}','()']: |
@@ -554,23 +554,6 b' class Inspector:' | |||||
554 | title = header((title+":").ljust(title_width)) |
|
554 | title = header((title+":").ljust(title_width)) | |
555 | out.append(cast_unicode(title) + cast_unicode(content)) |
|
555 | out.append(cast_unicode(title) + cast_unicode(content)) | |
556 | return "\n".join(out) |
|
556 | return "\n".join(out) | |
557 |
|
||||
558 | # The fields to be displayed by pinfo: (fancy_name, key_in_info_dict) |
|
|||
559 | pinfo_fields1 = [("Type", "type_name"), |
|
|||
560 | ] |
|
|||
561 |
|
||||
562 | pinfo_fields2 = [("String form", "string_form"), |
|
|||
563 | ] |
|
|||
564 |
|
||||
565 | pinfo_fields3 = [("Length", "length"), |
|
|||
566 | ("File", "file"), |
|
|||
567 | ("Definition", "definition"), |
|
|||
568 | ] |
|
|||
569 |
|
||||
570 | pinfo_fields_obj = [("Class docstring", "class_docstring"), |
|
|||
571 | ("Init docstring", "init_docstring"), |
|
|||
572 | ("Call def", "call_def"), |
|
|||
573 | ("Call docstring", "call_docstring")] |
|
|||
574 |
|
557 | |||
575 | def _format_info(self, obj, oname='', formatter=None, info=None, detail_level=0): |
|
558 | def _format_info(self, obj, oname='', formatter=None, info=None, detail_level=0): | |
576 | """Format an info dict as text""" |
|
559 | """Format an info dict as text""" | |
@@ -582,41 +565,62 b' class Inspector:' | |||||
582 | field = info[key] |
|
565 | field = info[key] | |
583 | if field is not None: |
|
566 | if field is not None: | |
584 | displayfields.append((title, field.rstrip())) |
|
567 | displayfields.append((title, field.rstrip())) | |
585 |
|
568 | |||
586 | add_fields(self.pinfo_fields1) |
|
569 | if info['isalias']: | |
587 |
|
570 | add_fields([('Repr', "string_form")]) | ||
588 | # Base class for old-style instances |
|
571 | ||
589 | if (not py3compat.PY3) and isinstance(obj, types.InstanceType) and info['base_class']: |
|
572 | elif info['ismagic']: | |
590 | displayfields.append(("Base Class", info['base_class'].rstrip())) |
|
573 | add_fields([("Docstring", "docstring"), | |
591 |
|
574 | ("File", "file") | ||
592 | add_fields(self.pinfo_fields2) |
|
575 | ]) | |
593 |
|
576 | |||
594 | # Namespace |
|
577 | elif info['isclass'] or is_simple_callable(obj): | |
595 | if info['namespace'] != 'Interactive': |
|
578 | # Functions, methods, classes | |
596 | displayfields.append(("Namespace", info['namespace'].rstrip())) |
|
579 | add_fields([("Signature", "definition"), | |
597 |
|
580 | ("Init signature", "init_definition"), | ||
598 | add_fields(self.pinfo_fields3) |
|
581 | ]) | |
599 | if info['isclass'] and info['init_definition']: |
|
582 | if detail_level > 0 and info['source'] is not None: | |
600 | displayfields.append(("Init definition", |
|
583 | add_fields([("Source", "source")]) | |
601 | info['init_definition'].rstrip())) |
|
584 | else: | |
602 |
|
585 | add_fields([("Docstring", "docstring"), | ||
603 | # Source or docstring, depending on detail level and whether |
|
586 | ("Init docstring", "init_docstring"), | |
604 | # source found. |
|
587 | ]) | |
605 | if detail_level > 0 and info['source'] is not None: |
|
588 | ||
606 | displayfields.append(("Source", |
|
589 | add_fields([('File', 'file'), | |
607 | self.format(cast_unicode(info['source'])))) |
|
590 | ('Type', 'type_name'), | |
608 | elif info['docstring'] is not None: |
|
591 | ]) | |
609 | displayfields.append(("Docstring", info["docstring"])) |
|
592 | ||
610 |
|
||||
611 | # Constructor info for classes |
|
|||
612 | if info['isclass']: |
|
|||
613 | if info['init_docstring'] is not None: |
|
|||
614 | displayfields.append(("Init docstring", |
|
|||
615 | info['init_docstring'])) |
|
|||
616 |
|
||||
617 | # Info for objects: |
|
|||
618 | else: |
|
593 | else: | |
619 | add_fields(self.pinfo_fields_obj) |
|
594 | # General Python objects | |
|
595 | add_fields([("Type", "type_name")]) | |||
|
596 | ||||
|
597 | # Base class for old-style instances | |||
|
598 | if (not py3compat.PY3) and isinstance(obj, types.InstanceType) and info['base_class']: | |||
|
599 | displayfields.append(("Base Class", info['base_class'].rstrip())) | |||
|
600 | ||||
|
601 | add_fields([("String form", "string_form")]) | |||
|
602 | ||||
|
603 | # Namespace | |||
|
604 | if info['namespace'] != 'Interactive': | |||
|
605 | displayfields.append(("Namespace", info['namespace'].rstrip())) | |||
|
606 | ||||
|
607 | add_fields([("Length", "length"), | |||
|
608 | ("File", "file"), | |||
|
609 | ("Definition", "definition"), | |||
|
610 | ]) | |||
|
611 | ||||
|
612 | # Source or docstring, depending on detail level and whether | |||
|
613 | # source found. | |||
|
614 | if detail_level > 0 and info['source'] is not None: | |||
|
615 | displayfields.append(("Source", | |||
|
616 | self.format(cast_unicode(info['source'])))) | |||
|
617 | elif info['docstring'] is not None: | |||
|
618 | displayfields.append(("Docstring", info["docstring"])) | |||
|
619 | ||||
|
620 | add_fields([("Class docstring", "class_docstring"), | |||
|
621 | ("Init docstring", "init_docstring"), | |||
|
622 | ("Call def", "call_def"), | |||
|
623 | ("Call docstring", "call_docstring")]) | |||
620 |
|
624 | |||
621 | if displayfields: |
|
625 | if displayfields: | |
622 | return self._format_fields(displayfields) |
|
626 | return self._format_fields(displayfields) |
General Comments 0
You need to be logged in to leave comments.
Login now