extend to pathlib.Path to add the attribute wsl_path and win_path that holds respectively the WSL (Windows Subsystem for Linux) representation and Windows representation of that path.
Project description
wsl-pathlib
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.
Features
- 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.
Limitations
- Only works for the windows drives, (paths living in the wsl's
'/mnt/'
mount point) so'/home/'
won't work for example.
Installation
pip install wsl-pathlib
Usage
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'
License
Credits
This project was generated with wemake-python-package
. Current template version is: 465848d4daab031f9be6e334ef34af011c2577bc. See what is updated since then.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
wsl-pathlib-0.1.2.tar.gz
(4.6 kB
view hashes)
Built Distribution
Close
Hashes for wsl_pathlib-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8dc75e75ecae49192b0c09e3f543d79f2e86c4bf4cc96308f3876d13a6be19e1 |
|
MD5 | 173391360756e73b7b4be6cc0b7b275b |
|
BLAKE2b-256 | 05717ced1c6b06425e7712f9cee7435245c8f77db0754280afb609bd37a6bd2b |