tests/test_dx.py
def random_project_folder(length: int = 8, prefix: str = "") -> str:
    """
    ContextManager that generates a random folder name, ensures that it doesn't
    already exist in the current project, yields it, and then deletes the folder if it
    exists.

    Returns:
        The folder path.
    """
    letters = string.ascii_letters + string.digits
    project = dxpy.DXProject(dxpy.PROJECT_CONTEXT_ID)

    while True:
        folder = "".join(random.choices(letters, k=length))
        folder_path = f"{prefix}{'' if prefix.endswith('/') else '/'}{folder}"
        try:
            project.list_folder(folder_path)
        except dxpy.exceptions.ResourceNotFound:
            # We found a folder that does not exist
            break

    try:
        yield folder_path
    finally:
        project.remove_folder(folder_path, recurse=True, force=True)

    ContextManager that generates a random folder name, ensures that it doesn't
    already exist in the current project, yields it, and then deletes the folder if it
    exists.

    Returns:
        The folder path.
    
ContextManager that generates a random folder name, ensures that it doesn't
already exist in the current project, yields it, and then deletes the folder if it
exists.
ContextManager that generates a random folder name ensures that it doesn ' t already exist in the current project yields it and then deletes the folder if it exists .
def random_project_folder(length: int = 8, prefix: str = "") -> str:
    letters = string.ascii_letters + string.digits
    project = dxpy.DXProject(dxpy.PROJECT_CONTEXT_ID)
    while True:
        folder = "".join(random.choices(letters, k=length))
        folder_path = f"{prefix}{'' if prefix.endswith('/') else '/'}{folder}"
        try:
            project.list_folder(folder_path)
        except dxpy.exceptions.ResourceNotFound:
            break
    try:
        yield folder_path
    finally:
        project.remove_folder(folder_path, recurse=True, force=True)
def random_project_folder ( length : int = 8 , prefix : str = "" ) -> str : letters = string . ascii_letters + string . digits project = dxpy . DXProject ( dxpy . PROJECT_CONTEXT_ID ) while True : folder = "" . join ( random . choices ( letters , k = length ) ) folder_path = f"{prefix}{'' if prefix.endswith('/') else '/'}{folder}" try : project . list_folder ( folder_path ) except dxpy . exceptions . ResourceNotFound : break try : yield folder_path finally : project . remove_folder ( folder_path , recurse = True , force = True )
ContextManager that generates a random folder name, ensures that it doesn't
already exist in the current project, yields it, and then deletes the folder if it
exists.
ContextManager that generates a random folder name ensures that it doesn ' t already exist in the current project yields it and then deletes the folder if it exists .
"""
    ContextManager that generates a random folder name, ensures that it doesn't
    already exist in the current project, yields it, and then deletes the folder if it
    exists.

    Returns:
        The folder path.
    """ # We found a folder that does not exist
The folder path.
The folder path .
length
int
prefix
str