MCPcopy Index your code
hub / github.com/PyTables/PyTables / get_node

Method get_node

tables/file.py:1746–1817  ·  view source on GitHub ↗

Get the node under where with the given name. Parameters ---------- where : str or Node This can be a path string leading to a node or a Node instance (see :ref:`NodeClassDescr`). If no name is specified, that node is returned.

(
        self,
        where: Node | str,
        name: str | None = None,
        classname: str | None = None,
    )

Source from the content-addressed store, hash-verified

1744 return node
1745
1746 def get_node(
1747 self,
1748 where: Node | str,
1749 name: str | None = None,
1750 classname: str | None = None,
1751 ) -> Node:
1752 """Get the node under where with the given name.
1753
1754 Parameters
1755 ----------
1756 where : str or Node
1757 This can be a path string leading to a node or a Node instance (see
1758 :ref:`NodeClassDescr`). If no name is specified, that node is
1759 returned.
1760
1761 .. note::
1762
1763 If where is a Node instance from a different file than the one
1764 on which this function is called, the returned node will also
1765 be from that other file.
1766
1767 name : str, optional
1768 If a name is specified, this must be a string with the name of
1769 a node under where. In this case the where argument can only
1770 lead to a Group (see :ref:`GroupClassDescr`) instance (else a
1771 TypeError is raised). The node called name under the group
1772 where is returned.
1773 classname : str, optional
1774 If the classname argument is specified, it must be the name of
1775 a class derived from Node (e.g. Table). If the node is found but it
1776 is not an instance of that class, a NoSuchNodeError is also raised.
1777
1778 Notes
1779 -----
1780 If the node to be returned does not exist, a NoSuchNodeError is
1781 raised. Please note that hidden nodes are also considered.
1782
1783 """
1784 self._check_open()
1785
1786 if isinstance(where, Node):
1787 where._g_check_open()
1788
1789 basepath = where._v_pathname
1790 nodepath = join_path(basepath, name or "") or "/"
1791 node = where._v_file._get_node(nodepath)
1792 elif isinstance(where, (str, np.str_)):
1793 if not where.startswith("/"):
1794 raise NameError("``where`` must start with a slash ('/')")
1795
1796 basepath = where
1797 nodepath = join_path(basepath, name or "") or "/"
1798 node = self._get_node(nodepath)
1799 else:
1800 raise TypeError(f"``where`` must be a string or a node: {where!r}")
1801
1802 # Finally, check whether the desired node is an instance
1803 # of the expected class.

Callers 15

_get_or_create_pathMethod · 0.95
create_hard_linkMethod · 0.95
is_visible_nodeMethod · 0.95
rename_nodeMethod · 0.95
move_nodeMethod · 0.95
copy_nodeMethod · 0.95
remove_nodeMethod · 0.95
get_node_attrMethod · 0.95
set_node_attrMethod · 0.95
del_node_attrMethod · 0.95
copy_node_attrsMethod · 0.95
copy_childrenMethod · 0.95

Calls 6

_check_openMethod · 0.95
_get_nodeMethod · 0.95
join_pathFunction · 0.85
get_class_by_nameFunction · 0.85
NoSuchNodeErrorClass · 0.85
_g_check_openMethod · 0.80

Tested by 15

test00_NewFileMethod · 0.36
test00_OpenFileReadMethod · 0.36
setUpMethod · 0.36
setUpMethod · 0.36
test00_attributesMethod · 0.36
test01_iterEArrayMethod · 0.36
test02_sssEArrayMethod · 0.36
test03_readEArrayMethod · 0.36
test04_getitemEArrayMethod · 0.36