MCPcopy Index your code
hub / github.com/ipython/ipython / _ofind

Method _ofind

IPython/core/interactiveshell.py:1704–1824  ·  view source on GitHub ↗

Find an object in the available namespaces. Returns ------- OInfo with fields: - ismagic - isalias - found - obj - namespac - parent Has special code to detect magic functions.

(
        self, oname: str, namespaces: Optional[Sequence[Tuple[str, AnyType]]] = None
    )

Source from the content-addressed store, hash-verified

1702 return parts_ok, parts
1703
1704 def _ofind(
1705 self, oname: str, namespaces: Optional[Sequence[Tuple[str, AnyType]]] = None
1706 ) -> OInfo:
1707 """Find an object in the available namespaces.
1708
1709
1710 Returns
1711 -------
1712 OInfo with fields:
1713 - ismagic
1714 - isalias
1715 - found
1716 - obj
1717 - namespac
1718 - parent
1719
1720 Has special code to detect magic functions.
1721 """
1722 oname = oname.strip()
1723 parts_ok, parts = self._find_parts(oname)
1724
1725 if (
1726 not oname.startswith(ESC_MAGIC)
1727 and not oname.startswith(ESC_MAGIC2)
1728 and not parts_ok
1729 ):
1730 return OInfo(
1731 ismagic=False,
1732 isalias=False,
1733 found=False,
1734 obj=None,
1735 namespace=None,
1736 parent=None,
1737 )
1738
1739 if namespaces is None:
1740 # Namespaces to search in:
1741 # Put them in a list. The order is important so that we
1742 # find things in the same order that Python finds them.
1743 namespaces = [ ('Interactive', self.user_ns),
1744 ('Interactive (global)', self.user_global_ns),
1745 ('Python builtin', builtin_mod.__dict__),
1746 ]
1747
1748 ismagic = False
1749 isalias = False
1750 found = False
1751 ospace = None
1752 parent = None
1753 obj = None
1754
1755
1756 # Look for the given name by splitting it in parts. If the head is
1757 # found, then we look for all the remaining parts as members, and only
1758 # declare success if we can find them all.
1759 oname_parts = parts
1760 oname_head, oname_rest = oname_parts[0],oname_parts[1:]
1761 for nsname,ns in namespaces:

Callers 11

_object_findMethod · 0.95
ofindMethod · 0.80
checkMethod · 0.80
handleMethod · 0.80
pageMethod · 0.80
test_ofind_line_magicMethod · 0.80
test_ofind_cell_magicMethod · 0.80

Calls 6

_find_partsMethod · 0.95
_getattr_propertyMethod · 0.95
find_cell_magicMethod · 0.95
find_line_magicMethod · 0.95
OInfoClass · 0.90
is_integer_stringFunction · 0.85