Extend pathlib.Path
by addding the properties wsl_path
and win_path
that holds respectively the WSL (Windows Subsystem for Linux) and Windows representation of the Path
object.
- Lazy loading of the wsl_path and win_path properties on first access.
- Base
Path
object remains fully functional. - Obviously works on both WSL and Windows side.
- Only works for the windows drives, (paths living in the wsl's
'/mnt/'
mount point) so'/home/'
won't work for example.
pip install wsl-pathlib
from wsl_pathlib.path import WslPath
# Running on WSL
wsl_p = WslPath("C:\\foo")
print(wsl_p)
# => '/mnt/c/foo'
print(wsl_p.exists())
# => True
print(wsl_p.win_path)
# => 'C:\foo'
wsl_p2 = wsl_p / "file.txt"
print(wsl_p2.win_path)
# => 'C:\foo\file.txt'
This project was generated with wemake-python-package
. Current template version is: 465848d4daab031f9be6e334ef34af011c2577bc. See what is updated since then.