def _file_operation(
    operation,
    source_path,
    target_path=None,
    allow_undo=True,
    no_confirm=False,
    rename_on_collision=True,
    silent=False,
    hWnd=None
):
    #
    # At present the Python wrapper around SHFileOperation doesn't
    # allow lists of files. Hopefully it will at some point, so
    # take account of it here.
    # If you pass this shell function a "/"-separated path with
    # a wildcard, eg c:/temp/*.tmp, it gets confused. It's ok
    # with a backslash, so convert here.
    #
    source_path = source_path or ""
    if isinstance(source_path, basestring):
        source_path = os.path.abspath(source_path)
    else:
        source_path = [os.path.abspath(i) for i in source_path]

    target_path = target_path or ""
    if isinstance(target_path, basestring):
        target_path = os.path.abspath(target_path)
    else:
        target_path = [os.path.abspath(i) for i in target_path]

    flags = 0
    if allow_undo: flags |= shellcon.FOF_ALLOWUNDO
    if no_confirm: flags |= shellcon.FOF_NOCONFIRMATION
    if rename_on_collision: flags |= shellcon.FOF_RENAMEONCOLLISION
    if silent: flags |= shellcon.FOF_SILENT

    result, n_aborted = shell.SHFileOperation(
        (hWnd or 0, operation, source_path, target_path, flags, None, None)
    )
    if result != 0:
        raise x_winshell(result)
    elif n_aborted:
        raise x_winshell(n_aborted % "%d operations were aborted by the user")
dataset/ETHPy150Open tjguk/winsys/winsys/shell.py/_file_operation/swapped operands of `%`