Skip to main content

A utility for converting file paths between WSL and Windows formats

Project description

wslconv

Version License

A utility for converting file paths between WSL (Windows Subsystem for Linux) and Windows formats.

wslconv helps developers working with WSL, bridge the path differences between Windows and Linux, making the experience smoother and error-free.

Features

  • Detect and convert paths automatically based on their format.
  • Support for native Linux paths, native Windows paths, Linux paths on Windows, and Windows paths on Linux.
  • Simple, intuitive API for developers.

Installation

To install wslconv, use pip:

pip install wslconv

Quickstart

Here's a quick example:

from wslconv import WSLPathConverter

# Create an instance with the path and distro name
converter = WSLPathConverter("C:\\Users\\user\\Documents", "Ubuntu")

# Convert to Linux format
linux_path = converter.to_linux()
print(linux_path)  # Expected: /mnt/c/Users/user/Documents

# Convert to Windows format
windows_path = converter.to_windows()
print(windows_path)  # Expected: C:\Users\user\Documents

API Reference

WSLPathConverter

Main class for the path conversion.

Methods

  • __init__(self, path, distro): Initialize with a path and the name of the WSL distro.
  • filesystem_type(self): Return the filesystem type of the path (Linux or Windows).
  • os_type(self): Return the OS type based on the path format (Linux or Windows).
  • to_linux(self): Convert the path to its Linux representation.
  • to_windows(self): Convert the path to its Windows representation.

Contributing

Feel free to open issues or PRs if you find any bugs or have suggestions for improvements!

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

wslconv-0.0.1.tar.gz (4.0 kB view hashes)

Uploaded Source

Built Distribution

wslconv-0.0.1-py3-none-any.whl (3.9 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