fsspec/utils.py
def other_paths(paths, path2, is_dir=None, exists=False):
    """In bulk file operations, construct a new file tree from a list of files

    Parameters
    ----------
    paths: list of str
        The input file tree
    path2: str or list of str
        Root to construct the new list in. If this is already a list of str, we just
        assert it has the right number of elements.
    is_dir: bool (optional)
        For the special case where the input in one element, whether to regard the value
        as the target path, or as a directory to put a file path within. If None, a
        directory is inferred if the path ends in '/'
    exists: bool (optional)
        For a str destination, it is already exists (and is a dir), files should
        end up inside.

    Returns
    -------
    list of str
    """
    if isinstance(path2, str):
        is_dir = is_dir or path2.endswith("/")
        path2 = path2.rstrip("/")
        if len(paths) > 1:
            cp = common_prefix(paths)
            if exists:
                cp = cp.rsplit("/", 1)[0]
            path2 = [p.replace(cp, path2, 1) for p in paths]
        else:
            if is_dir:
                path2 = [path2.rstrip("/") + "/" + paths[0].rsplit("/")[-1]]
            else:
                path2 = [path2]
    else:
        assert len(paths) == len(path2)
    return path2
In bulk file operations, construct a new file tree from a list of files

    Parameters
    ----------
    paths: list of str
        The input file tree
    path2: str or list of str
        Root to construct the new list in. If this is already a list of str, we just
        assert it has the right number of elements.
    is_dir: bool (optional)
        For the special case where the input in one element, whether to regard the value
        as the target path, or as a directory to put a file path within. If None, a
        directory is inferred if the path ends in '/'
    exists: bool (optional)
        For a str destination, it is already exists (and is a dir), files should
        end up inside.

    Returns
    -------
    list of str
    
In bulk file operations, construct a new file tree from a list of files
Parameters

list of str
The input file tree
path2: str or list of str
Root to construct the new list in. If this is already a list of str, we just
assert it has the right number of elements.
is_dir: bool (optional)
For the special case where the input in one element, whether to regard the value
as the target path, or as a directory to put a file path within. If None, a
directory is inferred if the path ends in '/'
exists: bool (optional)
For a str destination, it is already exists (and is a dir), files should
end up inside.

Returns

list of str
In bulk file operations construct a new file tree from a list of files Parameters list of str The input file tree path2 : str or list of str Root to construct the new list in . If this is already a list of str we just assert it has the right number of elements . is_dir : bool ( optional ) For the special case where the input in one element whether to regard the value as the target path or as a directory to put a file path within . If None a directory is inferred if the path ends in ' / ' exists : bool ( optional ) For a str destination it is already exists ( and is a dir ) files should end up inside . Returns list of str
def other_paths(paths, path2, is_dir=None, exists=False):
    if isinstance(path2, str):
        is_dir = is_dir or path2.endswith("/")
        path2 = path2.rstrip("/")
        if len(paths) > 1:
            cp = common_prefix(paths)
            if exists:
                cp = cp.rsplit("/", 1)[0]
            path2 = [p.replace(cp, path2, 1) for p in paths]
        else:
            if is_dir:
                path2 = [path2.rstrip("/") + "/" + paths[0].rsplit("/")[-1]]
            else:
                path2 = [path2]
    else:
        assert len(paths) == len(path2)
    return path2
def other_paths ( paths , path2 , is_dir = None , exists = False ) : if isinstance ( path2 , str ) : is_dir = is_dir or path2 . endswith ( "/" ) path2 = path2 . rstrip ( "/" ) if len ( paths ) > 1 : cp = common_prefix ( paths ) if exists : cp = cp . rsplit ( "/" , 1 ) [ 0 ] path2 = [ p . replace ( cp , path2 , 1 ) for p in paths ] else : if is_dir : path2 = [ path2 . rstrip ( "/" ) + "/" + paths [ 0 ] . rsplit ( "/" ) [ - 1 ] ] else : path2 = [ path2 ] else : assert len ( paths ) == len ( path2 ) return path2
In bulk file operations, construct a new file tree from a list of files
Parameters
In bulk file operations construct a new file tree from a list of files Parameters
"""In bulk file operations, construct a new file tree from a list of files

    Parameters
    ----------
    paths: list of str
        The input file tree
    path2: str or list of str
        Root to construct the new list in. If this is already a list of str, we just
        assert it has the right number of elements.
    is_dir: bool (optional)
        For the special case where the input in one element, whether to regard the value
        as the target path, or as a directory to put a file path within. If None, a
        directory is inferred if the path ends in '/'
    exists: bool (optional)
        For a str destination, it is already exists (and is a dir), files should
        end up inside.

    Returns
    -------
    list of str
    """
paths
path2
is_dir
exists