Skip to content

akikuno/wslPath

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Licence Test Python PyPI Conda

wslPath

wslPath is a Python module designed to convert paths between Windows and POSIX formats within the Windows Subsystem for Linux (WSL).

Install

From PyPI:

pip install wslPath

From Conda:

conda install -c conda-forge wslPath

Usages

Windows to Posix

import wslPath

## Relative path
pathwin = "hoge\\fuga"
wslPath.to_posix(pathwin)
# -> "hoge/fuga"

## Absolute path
pathwin = "C:\\hoge\\fuga"
wslPath.to_posix(pathwin)
# -> "/mnt/c/hoge/fuga"

Posix to Windows

import wslPath

## Relative path
pathposix = "hoge/fuga"
wslPath.to_windows(pathposix)
# -> "hoge\\fuga"

## Absolute path
pathposix = "/mnt/c/hoge/fuga"
wslPath.to_windows(pathposix)
# -> "C:\\hoge\\fuga"

Automatically Convert Path Format to Match the Operating System

import wslPath

path = "hoge/fuga"
wslPath.wslpath(path) # Windows OS
# -> "hoge\\fuga"

path = "hoge\\fuga"
wslPath.wslpath(path) # POSIX OS
# -> "hoge/fuga"

Identify path type (Windows or POSIX)

import wslPath

path = "hoge/fuga"
wslPath.is_posix_path(path)
# -> True

path = "hoge\\fuga"
wslPath.is_posix_path(path)
# -> False

path = "hoge/fuga"
wslPath.is_windows_path(path)
# -> False

path = "hoge\\fuga"
wslPath.is_windows_path(path)
# -> True