(file_abs_path: Text)
return new_file_path
ensure file path valid for pytest, handle cases when directory name includes dot/hyphen/space

    Args:
        file_abs_path: absolute file path

    Returns:
        ensured valid absolute file path
ensure file path valid for pytest, handle cases when directory name includes dot/hyphen/space
ensure file path valid for pytest handle cases when directory name includes dot / hyphen / space
def ensure_file_abs_path_valid(file_abs_path: Text) -> Text:
    """ ensure file path valid for pytest, handle cases when directory name includes dot/hyphen/space

    Args:
        file_abs_path: absolute file path

    Returns:
        ensured valid absolute file path

    """
    project_meta = load_project_meta(file_abs_path)
    raw_abs_file_name, file_suffix = os.path.splitext(file_abs_path)
    file_suffix = file_suffix.lower()

    raw_file_relative_name = convert_relative_project_root_dir(raw_abs_file_name)
    if raw_file_relative_name == "":
        return file_abs_path

    path_names = []
    for name in raw_file_relative_name.rstrip(os.sep).split(os.sep):

        if name[0] in string.digits:
            # ensure file name not startswith digit
            # 19 => T19, 2C => T2C
            name = f"T{name}"

        if name.startswith("."):
            # avoid ".csv" been converted to "_csv"
            pass
        else:
            # handle cases when directory name includes dot/hyphen/space
            name = name.replace(" ", "_").replace(".", "_").replace("-", "_")

        path_names.append(name)

    new_file_path = os.path.join(
        project_meta.RootDir, f"{os.sep.join(path_names)}{file_suffix}"
    )
    return new_file_path
def ensure_file_abs_path_valid ( file_abs_path : Text ) -> Text : project_meta = load_project_meta ( file_abs_path ) raw_abs_file_name , file_suffix = os . path . splitext ( file_abs_path ) file_suffix = file_suffix . lower ( ) raw_file_relative_name = convert_relative_project_root_dir ( raw_abs_file_name ) if raw_file_relative_name == "" : return file_abs_path path_names = [ ] for name in raw_file_relative_name . rstrip ( os . sep ) . split ( os . sep ) : if name [ 0 ] in string . digits : # ensure file name not startswith digit # 19 => T19, 2C => T2C name = f"T{name}" if name . startswith ( "." ) : # avoid ".csv" been converted to "_csv" pass else : # handle cases when directory name includes dot/hyphen/space name = name . replace ( " " , "_" ) . replace ( "." , "_" ) . replace ( "-" , "_" ) path_names . append ( name ) new_file_path = os . path . join ( project_meta . RootDir , f"{os.sep.join(path_names)}{file_suffix}" ) return new_file_path