

def copy_files(src, target_node, parent=None, name=None):
    'Copy the files from src to the target node\n    :param Folder src: The source to copy children from\n    :param Node target_node: The node settings of the project to copy files to\n    :param Folder parent: The parent of to attach the clone of src to, if applicable\n    '
    assert ((not parent) or (not parent.is_file)), 'Parent must be a folder'
    cloned = src.clone().wrapped()
    cloned.parent = parent
    cloned.node = target_node
    cloned.name = (name or parent.name)
    if src.is_file:
        cloned.versions = src.versions
    cloned.save()
    if (not src.is_file):
        for child in src.children:
            copy_files(child, target_node, parent=cloned)
    return cloned

dataset/ETHPy150Open CenterForOpenScience/osf.io/website/files/utils.py copy_files/VarMisuse@70/201 `cloned`->`parent`