MCPcopy Create free account
hub / github.com/PyTables/PyTables / copy_node

Method copy_node

tables/file.py:1893–1963  ·  view source on GitHub ↗

Copy the node specified by where and name to newparent/newname. Parameters ---------- where : str These arguments work as in :meth:`File.get_node`, referencing the node to be acted upon. newparent : str or Group The des

(
        self,
        where: Node | str,
        newparent: Group | str | None = None,
        newname: str | None = None,
        name: str | None = None,
        overwrite: bool = False,
        recursive: bool = False,
        createparents: bool = False,
        **kwargs,
    )

Source from the content-addressed store, hash-verified

1891 obj._f_move(newparent, newname, overwrite, createparents)
1892
1893 def copy_node(
1894 self,
1895 where: Node | str,
1896 newparent: Group | str | None = None,
1897 newname: str | None = None,
1898 name: str | None = None,
1899 overwrite: bool = False,
1900 recursive: bool = False,
1901 createparents: bool = False,
1902 **kwargs,
1903 ) -> Node:
1904 """Copy the node specified by where and name to newparent/newname.
1905
1906 Parameters
1907 ----------
1908 where : str
1909 These arguments work as in
1910 :meth:`File.get_node`, referencing the node to be acted
1911 upon.
1912 newparent : str or Group
1913 The destination group that the node will be copied
1914 into (a path name or a Group
1915 instance). If not specified or None, the
1916 current parent group is chosen as the new parent.
1917 newname : str
1918 The name to be assigned to the new copy in its
1919 destination (a string). If it is not specified or
1920 None, the current name is chosen as the
1921 new name.
1922 name : str
1923 These arguments work as in
1924 :meth:`File.get_node`, referencing the node to be acted
1925 upon.
1926 overwrite : bool, optional
1927 If True, the destination group will be overwritten if it already
1928 exists. Defaults to False.
1929 recursive : bool, optional
1930 If True, all descendant nodes of the node to be acted upon are
1931 recursively copied. Defaults to False.
1932 createparents : bool, optional
1933 If True, any necessary parents of newparent will be created.
1934 Defaults to False.
1935 kwargs
1936 Additional keyword arguments can be used to customize the copying
1937 process. See the documentation of :meth:`Group._f_copy`
1938 for a description of those arguments.
1939
1940 Returns
1941 -------
1942 node : Node
1943 The newly created copy of the source node (i.e. the destination
1944 node). See :meth:`.Node._f_copy` for further details on the
1945 semantics of copying nodes.
1946
1947 """
1948 obj = self.get_node(where, name=name)
1949 if obj._v_depth == 0 and newparent and not newname:
1950 npobj = self.get_node(newparent)

Callers 15

test01a_copyDeepTreeMethod · 0.80
test01b_copyDeepTreeMethod · 0.80
test01c_copyDeepTreeMethod · 0.80
test01d_copyDeepTreeMethod · 0.80
test13a_copyLeafMethod · 0.80
test13b_copyGroupMethod · 0.80
test13c_copyGroupSelfMethod · 0.80

Calls 3

get_nodeMethod · 0.95
_f_copy_childrenMethod · 0.80
_f_copyMethod · 0.45

Tested by 15

test01a_copyDeepTreeMethod · 0.64
test01b_copyDeepTreeMethod · 0.64
test01c_copyDeepTreeMethod · 0.64
test01d_copyDeepTreeMethod · 0.64
test13a_copyLeafMethod · 0.64
test13b_copyGroupMethod · 0.64
test13c_copyGroupSelfMethod · 0.64