scitacean.filesystem.escape_path#

scitacean.filesystem.escape_path(path)[source]#

Escape disallowed characters for file paths.

Replaces

  • Unicode characters using "backslashreplace". See the Python docs.

  • Non-word characters by ‘_’. This includes backslashes introduced by the above.

The result should be a valid path name on Linux, macOS, and Windows.

Parameters:

path (TypeVar(P, bound= str | Path | RemotePath)) – Input string or path.

Returns:

TypeVar(P, bound= str | Path | RemotePath)path with offending characters replaced. Has the same type as path.