kwutil.util_windows module¶
Microsoft Windows related helpers.
- kwutil.util_windows.fix_msys_path(path)[source]¶
Windows is so special. When using msys bash if you pass a path on the CLI it resolves /c to C:/, but if you have you path as part of a config string, it doesnt know how to do that, and at that point Python doesn’t handle the msys style /c paths. This is a hack detects and fixes this in this location.
Example
>>> from kwutil.util_windows import * # NOQA >>> print(fix_msys_path('/c/Users/foobar')) C:/Users/foobar >>> print(fix_msys_path(r'\c\Users\foobar')) C:/Users\foobar >>> print(fix_msys_path(r'\d\Users\foobar')) D:/Users\foobar >>> print(fix_msys_path(r'\z')) Z:/ >>> import pathlib >>> assert fix_msys_path(pathlib.Path(r'\z')) == pathlib.Path('Z:/')
- kwutil.util_windows.is_windows_path(path)[source]¶
Example
>>> from kwutil.util_windows import * # NOQA >>> assert is_windows_path('C:') >>> assert is_windows_path('C:/') >>> assert is_windows_path('C:\\') >>> assert is_windows_path('C:/foo') >>> assert is_windows_path('C:\\foo') >>> assert not is_windows_path('/foo')