Closed bschollnick closed 4 years ago
@bschollnick Thank you for your report.
The filepath can not start with os.sep (eg. "/users/benjamin/test.zip")
This issue had fixed at pathvalidate 2.2.2
:
>>> from pathvalidate import sanitize_filepath
>>> sanitize_filepath(r"\users\benjamin\test\test1.zip")
'/users/benjamin/test/test1.zip'
sanitize_filepath does not seem to respect the os.sep setting of the platform it is running on:
You can get your expected results if you specify the platform argument to "windows"
or "auto"
to sanitie_filepath
.
>>> sanitize_filepath(r"users\benjamin\test\test1.zip", platform="windows")
'users\\benjamin\\test\\test1.zip'
>>> sanitize_filepath(r"users\benjamin\test\test1.zip", platform="auto")
'users\\benjamin\\test\\test1.zip'
In default, sanitize_filepath
normalize a file path to be platform-independent.
As far as I can tell under the Windows platform, the following issues exist:
These are for sanitize_filepath:
Please note, the string I passed in was using os.sep. What was returned, did not use os.sep.