# WSLPathConverter
Easily convert paths between Windows and WSL (Windows Subsystem for Linux) environments.
## Features
- Identify the format of provided paths.
- Convert paths to their native Linux or Windows format.
- Handle paths that mix Linux and Windows notations.
- Extract folder structures from paths.
## Installation
```bash
pip install wslbridge
```
## Usage
### Using WSLPathConverter:
```python
from wslbridge import WSLPathConverter
converter = WSLPathConverter(distro_name="Debian")
# Convert a Windows path to its native Linux format:
linux_path = converter.convert_to_linux_format("C:\\Users\\username\\file.txt")
print(linux_path) # Expected Output: /mnt/c/Users/username/file.txt
# Convert a Linux path to its native Windows format:
windows_path = converter.convert_to_windows_format("/mnt/c/Users/username/file.txt")
print(windows_path) # Expected Output: C:\Users\username\file.txt
```
### Using UniversalPath:
```python
from wslbridge import UniversalPath
up = UniversalPath("/mnt/c/Users/username/file.txt", distro_name="Debian")
# Get the path in Linux format:
print(up.get_linux_path()) # Expected Output: /mnt/c/Users/username/file.txt
# Get the path in Windows format:
print(up.get_windows_path()) # Expected Output: \\wsl.localhost\Debian\mnt\c\Users\username\file.txt
```
## Notes
- When a path in Windows format is converted to a list of folders, the drive letter is treated specially. For example, the path "C:\Users\username\file.txt" would be represented as `['c', 'Users', 'username', 'file.txt']`.
- The `UniversalPath` class simplifies the usage of the converter by identifying the path format automatically and providing convenient methods to get the path in desired formats.
## Contributing
Feel free to submit issues, fork the repository and send pull requests!
Raw data
{
"_id": null,
"home_page": "https://github.com/yourusername/wslbridge",
"name": "wslbridge",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "",
"author": "Lasha Koroshinadze",
"author_email": "lashakoroshinadze199@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/20/37/d25c5020cea857bf303a4efb81d1298b0869f46f12f9fb020ac1bbaf7d74/wslbridge-0.1.tar.gz",
"platform": null,
"description": "# WSLPathConverter\n\nEasily convert paths between Windows and WSL (Windows Subsystem for Linux) environments.\n\n## Features\n\n- Identify the format of provided paths.\n- Convert paths to their native Linux or Windows format.\n- Handle paths that mix Linux and Windows notations.\n- Extract folder structures from paths.\n\n## Installation\n\n```bash\npip install wslbridge\n```\n\n## Usage\n\n### Using WSLPathConverter:\n\n```python\nfrom wslbridge import WSLPathConverter\n\nconverter = WSLPathConverter(distro_name=\"Debian\")\n\n# Convert a Windows path to its native Linux format:\nlinux_path = converter.convert_to_linux_format(\"C:\\\\Users\\\\username\\\\file.txt\")\nprint(linux_path) # Expected Output: /mnt/c/Users/username/file.txt\n\n# Convert a Linux path to its native Windows format:\nwindows_path = converter.convert_to_windows_format(\"/mnt/c/Users/username/file.txt\")\nprint(windows_path) # Expected Output: C:\\Users\\username\\file.txt\n```\n\n### Using UniversalPath:\n\n```python\nfrom wslbridge import UniversalPath\n\nup = UniversalPath(\"/mnt/c/Users/username/file.txt\", distro_name=\"Debian\")\n\n# Get the path in Linux format:\nprint(up.get_linux_path()) # Expected Output: /mnt/c/Users/username/file.txt\n\n# Get the path in Windows format:\nprint(up.get_windows_path()) # Expected Output: \\\\wsl.localhost\\Debian\\mnt\\c\\Users\\username\\file.txt\n```\n\n## Notes\n\n- When a path in Windows format is converted to a list of folders, the drive letter is treated specially. For example, the path \"C:\\Users\\username\\file.txt\" would be represented as `['c', 'Users', 'username', 'file.txt']`.\n- The `UniversalPath` class simplifies the usage of the converter by identifying the path format automatically and providing convenient methods to get the path in desired formats.\n\n## Contributing\n\nFeel free to submit issues, fork the repository and send pull requests!\n",
"bugtrack_url": null,
"license": "",
"summary": "A bridge to convert WSL paths",
"version": "0.1",
"project_urls": {
"Homepage": "https://github.com/yourusername/wslbridge"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "12c167a1510de25eb51fea6ed85d89bdc28d65695a64cce8590c46390a68e7d1",
"md5": "3608926d36601ea81216dc496db29799",
"sha256": "fa976f7e0cbb14843994b4cc94e61f0cecfb47bb51b9b68a174a6f64e99210eb"
},
"downloads": -1,
"filename": "wslbridge-0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "3608926d36601ea81216dc496db29799",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 2674,
"upload_time": "2023-11-01T20:54:16",
"upload_time_iso_8601": "2023-11-01T20:54:16.914859Z",
"url": "https://files.pythonhosted.org/packages/12/c1/67a1510de25eb51fea6ed85d89bdc28d65695a64cce8590c46390a68e7d1/wslbridge-0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "2037d25c5020cea857bf303a4efb81d1298b0869f46f12f9fb020ac1bbaf7d74",
"md5": "041d11250d5e5fa0766a1e6e114ec085",
"sha256": "b537db3e559344c107973d762bef357a6c655435a4cd2e8130530e977a5bff1b"
},
"downloads": -1,
"filename": "wslbridge-0.1.tar.gz",
"has_sig": false,
"md5_digest": "041d11250d5e5fa0766a1e6e114ec085",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 2511,
"upload_time": "2023-11-01T20:54:19",
"upload_time_iso_8601": "2023-11-01T20:54:19.103594Z",
"url": "https://files.pythonhosted.org/packages/20/37/d25c5020cea857bf303a4efb81d1298b0869f46f12f9fb020ac1bbaf7d74/wslbridge-0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-11-01 20:54:19",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "yourusername",
"github_project": "wslbridge",
"github_not_found": true,
"lcname": "wslbridge"
}