Module wslPath.main

Functions

def has_invalid_windows_path_chars(path: str | Path) ‑> bool

Check if the given path contains invalid Windows path characters.

def is_posix_path(path: str | Path) ‑> bool

Determine if the given path is in POSIX format.

def is_windows_path(path: str | Path) ‑> bool

Determine if the given path is in Windows format.

def to_posix(path: str | Path) ‑> str | pathlib.Path

Convert a Windows path to a POSIX path

Examples

>>> import wslPath
>>> pathwin = "hoge\fuga"
>>> wslPath.to_posix(pathwin)
hoge/fuga
>>> pathwin = "C:\hoge\fuga"
>>> wslPath.to_posix(pathwin)
/mnt/c/hoge/fuga
def to_windows(path: str | Path) ‑> str | pathlib.Path

Convert a POSIX path to a Windows path Examples:

>>> import wslPath
>>> pathposix = "hoge/fuga"
>>> wslPath.to_windows(pathposix)
hoge\fuga
>>> pathposix = "/mnt/c/hoge/fuga"
>>> wslPath.to_windows(pathposix)
C:\hoge\fuga
def wslpath(path: str | Path) ‑> str | pathlib.Path

Convert a path to the appropriate format for the current platform. Examples:

>>> import wslPath
>>> # If the current platform is Windows and the path is POSIX, convert to Windows path
>>> wslPath.wslpath("hoge/fuga")
hoge\fuga
>>> # If the current platform is Windows and the path is Windows, return the path as is
>>> wslPath.wslpath("hoge\fuga")
hoge\fuga
>>> # If the current platform is Linux and the path is Windows, convert to POSIX path
>>> wslPath.wslpath("hoge\fuga")
hoge/fuga
>>> # If the current platform is Linux and the path is POSIX, return the path as is
>>> wslPath.wslpath("hoge/fuga")
hoge/fuga