MCPcopy Create free account
hub / github.com/ipython/ipython / _info

Method _info

IPython/core/oinspect.py:694–905  ·  view source on GitHub ↗

Compute a dict with detailed information about an object. Parameters ========== obj: any An object to find information about oname: str (default: ''): Name of the variable pointing to `obj`. info: (default: None) A struct

(self, obj, oname='', info=None, detail_level=0)

Source from the content-addressed store, hash-verified

692 return self._info(obj, oname=oname, info=info, detail_level=detail_level)
693
694 def _info(self, obj, oname='', info=None, detail_level=0) -> dict:
695 """Compute a dict with detailed information about an object.
696
697 Parameters
698 ==========
699
700 obj: any
701 An object to find information about
702 oname: str (default: ''):
703 Name of the variable pointing to `obj`.
704 info: (default: None)
705 A struct (dict like with attr access) with some information fields
706 which may have been precomputed already.
707 detail_level: int (default:0)
708 If set to 1, more information is given.
709
710 Returns
711 =======
712
713 An object info dict with known fields from `info_fields`. Keys are
714 strings, values are string or None.
715 """
716
717 if info is None:
718 ismagic = False
719 isalias = False
720 ospace = ''
721 else:
722 ismagic = info.ismagic
723 isalias = info.isalias
724 ospace = info.namespace
725
726 # Get docstring, special-casing aliases:
727 if isalias:
728 if not callable(obj):
729 try:
730 ds = "Alias to the system command:\n %s" % obj[1]
731 except:
732 ds = "Alias: " + str(obj)
733 else:
734 ds = "Alias to " + str(obj)
735 if obj.__doc__:
736 ds += "\nDocstring:\n" + obj.__doc__
737 else:
738 ds = getdoc(obj)
739 if ds is None:
740 ds = '<no docstring>'
741
742 # store output in a dict, we initialize it here and fill it as we go
743 out = dict(name=oname, found=True, isalias=isalias, ismagic=ismagic, subclasses=None)
744
745 string_max = 200 # max size of strings to show (snipped if longer)
746 shalf = int((string_max - 5) / 2)
747
748 if ismagic:
749 out['type_name'] = 'Magic function'
750 elif isalias:
751 out['type_name'] = 'System alias'

Callers 2

_get_infoMethod · 0.95
infoMethod · 0.95

Calls 9

_getdefMethod · 0.95
compress_userFunction · 0.90
safe_hasattrFunction · 0.90
getdocFunction · 0.85
find_fileFunction · 0.85
getsourceFunction · 0.85
is_simple_callableFunction · 0.85
object_infoFunction · 0.85

Tested by

no test coverage detected