##// END OF EJS Templates
Cleaning of Oinspect....
Matthias Bussonnier -
Show More
@@ -1445,8 +1445,20 b' class InteractiveShell(SingletonConfigurable):'
1445 1445 ismagic = True
1446 1446 isalias = isinstance(obj, Alias)
1447 1447
1448 return {'found':found, 'obj':obj, 'namespace':ospace,
1449 'ismagic':ismagic, 'isalias':isalias, 'parent':parent}
1448 # Last try: special-case some literals like '', [], {}, etc:
1449 if not found and oname_head in ["''",'""','[]','{}','()']:
1450 obj = eval(oname_head)
1451 found = True
1452 ospace = 'Interactive'
1453
1454 return {
1455 'obj':obj,
1456 'found':found,
1457 'parent':parent,
1458 'ismagic':ismagic,
1459 'isalias':isalias,
1460 'namespace':ospace
1461 }
1450 1462
1451 1463 @staticmethod
1452 1464 def _getattr_property(obj, attrname):
@@ -2550,7 +2562,7 b' class InteractiveShell(SingletonConfigurable):'
2550 2562 where.update(
2551 2563 runpy.run_module(str(mod_name), run_name="__main__",
2552 2564 alter_sys=True)
2553 )
2565 )
2554 2566 except SystemExit as status:
2555 2567 if status.code:
2556 2568 raise
@@ -587,7 +587,21 b' class Inspector(Colorable):'
587 587 return bundle
588 588
589 589 def _get_info(self, obj, oname='', formatter=None, info=None, detail_level=0):
590 """Retrieve an info dict and format it."""
590 """Retrieve an info dict and format it.
591
592 Parameters
593 ==========
594
595 obj: any
596 Object to inspect and return info from
597 oname: str (default: ''):
598 Name of the variable pointing to `obj`.
599 formatter: callable
600 info:
601 already computed informations
602 detail_level: integer
603 Granularity of detail level, if set to 1, give more informations.
604 """
591 605
592 606 info = self._info(obj, oname=oname, info=info, detail_level=detail_level)
593 607
@@ -696,24 +710,31 b' class Inspector(Colorable):'
696 710 DeprecationWarning, stacklevel=2)
697 711 return self._info(obj, oname=oname, info=info, detail_level=detail_level)
698 712
699 def _info(self, obj, oname='', info=None, detail_level=0):
713 def _info(self, obj, oname='', info=None, detail_level=0) -> dict:
700 714 """Compute a dict with detailed information about an object.
701 715
702 Optional arguments:
703
704 - oname: name of the variable pointing to the object.
705
706 - info: a structure with some information fields which may have been
707 precomputed already.
708
709 - detail_level: if set to 1, more information is given.
716 Parameters
717 ==========
718
719 obj: any
720 An object to find information about
721 oname: str (default: ''):
722 Name of the variable pointing to `obj`.
723 info: (default: None)
724 A struct (dict like with attr access) with some information fields
725 which may have been precomputed already.
726 detail_level: int (default:0)
727 If set to 1, more information is given.
728
729 Returns
730 =======
731
732 An object info dict with known fields from `info_fields`.
710 733 """
711 734
712 obj_type = type(obj)
713
714 735 if info is None:
715 ismagic = 0
716 isalias = 0
736 ismagic = False
737 isalias = False
717 738 ospace = ''
718 739 else:
719 740 ismagic = info.ismagic
@@ -743,17 +764,17 b' class Inspector(Colorable):'
743 764 shalf = int((string_max - 5) / 2)
744 765
745 766 if ismagic:
746 obj_type_name = 'Magic function'
767 out['type_name'] = 'Magic function'
747 768 elif isalias:
748 obj_type_name = 'System alias'
769 out['type_name'] = 'System alias'
749 770 else:
750 obj_type_name = obj_type.__name__
751 out['type_name'] = obj_type_name
771 out['type_name'] = type(obj).__name__
752 772
753 773 try:
754 774 bclass = obj.__class__
755 775 out['base_class'] = str(bclass)
756 except: pass
776 except:
777 pass
757 778
758 779 # String form, but snip if too long in ? form (full in ??)
759 780 if detail_level >= self.str_detail_level:
@@ -774,7 +795,8 b' class Inspector(Colorable):'
774 795 # Length (for strings and lists)
775 796 try:
776 797 out['length'] = str(len(obj))
777 except: pass
798 except Exception:
799 pass
778 800
779 801 # Filename where object was defined
780 802 binary_file = False
General Comments 0
You need to be logged in to leave comments. Login now