-
-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* ✨ provide geturl for ReadZipFS. As a user of zipsf, I need geturl to provide FSURL string. * 🐛 on windows and python 3, fs.open_fs(osfs(~/).geturl('myfolder/subfolder')) triggers CreateFailed 🐛 osfs.geturl() cannot be opened by itself * 🔬 all test cases are in and ✨ support geturl for read tar file system * 🔥 remove unwanted comment in code * 📖 update change log and contributor md * :short: update code with black * 📖 update change log * 👕 provide type info * 💚 update unit tests * 🔥 remove dead code * 💚 update tarfs unit test * 🔥 remove unwanted change * :short: run black over osfs.py * 🐛 fix hidden exception at fs.close() when opening an absent zip/tar file URL. fix #333 * 📝 update the behavior of geturl of zipfs and tarfs * 👕 address review feedback ✨ url quote the files for proper url string * 💚 fix broken tests * ♿ add helpful exception info to help developers, who create pypifs, gitfs, fs.datalake et al. fix #340 * 🐛 fix windows path test * ✨ uniformly support fs purpose * 🔨 quote around the root path. #340 * 🚜 alternative file uri implementation * 🔬 try windows path test case where unicode characters stays as they are * 🐛 fix unit test expectation because of the difference between windows and linux file uri * 🚜 avoid Windows File URI for fs purpose * 🐛 before quote, utf8 string needs to be encoded. https://stackoverflow.com/questions/15115588/urllib-quote-throws-keyerror * 🚜 respect rfc 3986, where unicode will be quoted * 💚 🔨 code refactor and fix broken unit tests * 👕 address review feedback from @lurch * 💚 fix typo in code and 👕 update assertions * 🔥 remove unused variable * 👕 address further comments from @lurch * 💚 update windows test case. fix the typo * 🐛 colon:tmp is bad path under windows * 🐛 forward slash on Windows is a valid path separator * 💚 fix unit tests on travis-ci * 👕 address review comments * 👕 mypy compliance * 👕 dot the i and cross the t
- Loading branch information
1 parent
667d477
commit b78dad7
Showing
11 changed files
with
239 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import re | ||
import six | ||
import platform | ||
|
||
if False: # typing.TYPE_CHECKING | ||
from typing import Text, Union, BinaryIO | ||
|
||
_WINDOWS_PLATFORM = platform.system() == "Windows" | ||
|
||
|
||
def url_quote(path_snippet): | ||
# type: (Text) -> Text | ||
""" | ||
On Windows, it will separate drive letter and quote windows | ||
path alone. No magic on Unix-alie path, just pythonic | ||
`pathname2url` | ||
Arguments: | ||
path_snippet: a file path, relative or absolute. | ||
""" | ||
if _WINDOWS_PLATFORM and _has_drive_letter(path_snippet): | ||
drive_letter, path = path_snippet.split(":", 1) | ||
if six.PY2: | ||
path = path.encode("utf-8") | ||
path = six.moves.urllib.request.pathname2url(path) | ||
path_snippet = "{}:{}".format(drive_letter, path) | ||
else: | ||
if six.PY2: | ||
path_snippet = path_snippet.encode("utf-8") | ||
path_snippet = six.moves.urllib.request.pathname2url(path_snippet) | ||
return path_snippet | ||
|
||
|
||
def _has_drive_letter(path_snippet): | ||
# type: (Text) -> bool | ||
""" | ||
The following path will get True | ||
D:/Data | ||
C:\\My Dcouments\\ test | ||
And will get False | ||
/tmp/abc:test | ||
Arguments: | ||
path_snippet: a file path, relative or absolute. | ||
""" | ||
windows_drive_pattern = ".:[/\\\\].*$" | ||
return re.match(windows_drive_pattern, path_snippet) is not None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.