Copy this node and return the new node. Creates and returns a copy of the node, maybe in a different place in the hierarchy. newparent can be a Group object (see :ref:`GroupClassDescr`) or a pathname in string form. If it is not specified or None, the current parent
(
self,
newparent: Group | str | None = None,
newname: str | None = None,
overwrite: bool = False,
recursive: bool = False,
createparents: bool = False,
**kwargs,
)
| 738 | ) |
| 739 | |
| 740 | def _f_copy( |
| 741 | self, |
| 742 | newparent: Group | str | None = None, |
| 743 | newname: str | None = None, |
| 744 | overwrite: bool = False, |
| 745 | recursive: bool = False, |
| 746 | createparents: bool = False, |
| 747 | **kwargs, |
| 748 | ) -> Node: |
| 749 | """Copy this node and return the new node. |
| 750 | |
| 751 | Creates and returns a copy of the node, maybe in a different place in |
| 752 | the hierarchy. newparent can be a Group object (see |
| 753 | :ref:`GroupClassDescr`) or a pathname in string form. If it is not |
| 754 | specified or None, the current parent group is chosen as the new |
| 755 | parent. newname must be a string with a new name. If it is not |
| 756 | specified or None, the current name is chosen as the new name. If |
| 757 | recursive copy is stated, all descendants are copied as well. If |
| 758 | createparents is true, the needed groups for the given new parent group |
| 759 | path to exist will be created. |
| 760 | |
| 761 | Copying a node across databases is supported but can not be |
| 762 | undone. Copying a node over itself is not allowed, nor it is |
| 763 | recursively copying a node into itself. These result in a |
| 764 | NodeError. Copying over another existing node is similarly not allowed, |
| 765 | unless the optional overwrite argument is true, in which case that node |
| 766 | is recursively removed before copying. |
| 767 | |
| 768 | Additional keyword arguments may be passed to customize the copying |
| 769 | process. For instance, title and filters may be changed, user |
| 770 | attributes may be or may not be copied, data may be sub-sampled, stats |
| 771 | may be collected, etc. See the documentation for the particular node |
| 772 | type. |
| 773 | |
| 774 | Using only the first argument is equivalent to copying the node to a |
| 775 | new location without changing its name. Using only the second argument |
| 776 | is equivalent to making a copy of the node in the same group. |
| 777 | |
| 778 | """ |
| 779 | self._g_check_open() |
| 780 | srcfile = self._v_file |
| 781 | srcparent = self._v_parent |
| 782 | srcname = self._v_name |
| 783 | |
| 784 | dstparent = newparent |
| 785 | dstname = newname |
| 786 | |
| 787 | # Set default arguments. |
| 788 | if dstparent is None and dstname is None: |
| 789 | raise NodeError( |
| 790 | "you should specify at least " |
| 791 | "a ``newparent`` or a ``newname`` parameter" |
| 792 | ) |
| 793 | if dstparent is None: |
| 794 | dstparent = srcparent |
| 795 | if dstname is None: |
| 796 | dstname = srcname |
| 797 |