Skip to main content

Add wsl_path and win_path Properties to pathlib.Path Class.

Project description

wsl-pathlib

Build Status codecov Python Version wemake-python-styleguide

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

MIT

Credits

This project was generated with wemake-python-package. Current template version is: 465848d4daab031f9be6e334ef34af011c2577bc. See what is updated since then.

Project details


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.4.tar.gz (4.1 kB view hashes)

Uploaded Source

Built Distribution

wsl_pathlib-0.1.4-py3-none-any.whl (4.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page