Пример #1
0
def path_exists(drive: GoogleDrive, path:str, return_file=False) -> Tuple[bool, GoogleDriveFile]:
    """Checks whether the path exists in the google drive.
    Args:
      drive: The google drive in question.
      path: The path to check for.
      return_file: Whether the path should be returned if it exists.
    Returns:
      Tuple of boolean and GoogleDriveFile or None
    """
    try:
        res = drive.get_file_by_path(path)
        if return_file:
            return True, res 
        else:
            return True
    except FileNotFoundError:
        if return_file:
            return False, None
        else:
            return False