-
-
Notifications
You must be signed in to change notification settings - Fork 177
Implement TarFS.geturl and ZipFS.geturl and Fix #329, #333, #340 #330
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
b0fd465
:sparkles: provide geturl for ReadZipFS. As a user of zipsf, I need g…
chfw 3edc314
:bug: on windows and python 3, fs.open_fs(osfs(~/).geturl('myfolder/s…
chfw a0d4c94
:microscope: all test cases are in and :sparkles: support geturl for …
chfw a854233
:fire: remove unwanted comment in code
chfw a01f07e
Merge remote-tracking branch 'upstream/master'
chfw ab4e2d5
:book: update change log and contributor md
chfw 6a0f885
:short: update code with black
chfw a153367
:book: update change log
chfw 065d753
:shirt: provide type info
chfw 6a83318
:green_heart: update unit tests
chfw 397e807
:fire: remove dead code
chfw d9d1490
:green_heart: update tarfs unit test
chfw 9d1b0a0
:fire: remove unwanted change
chfw c9c6bcb
:short: run black over osfs.py
chfw f4290b8
:bug: fix hidden exception at fs.close() when opening an absent zip/…
chfw d236278
:pencil: update the behavior of geturl of zipfs and tarfs
chfw 76e6566
:handshake: merge with latest master
chfw 07617d2
:shirt: address review feedback
chfw ed9c2fa
:green_heart: fix broken tests
chfw e1ac859
:wheelchair: add helpful exception info to help developers, who creat…
chfw 0387d5b
:bug: fix windows path test
chfw f29ed55
:sparkles: uniformly support fs purpose
chfw 8dcfe4d
:hammer: quote around the root path. #340
chfw ab7ec66
:tractor: alternative file uri implementation
chfw a979470
:microscope: try windows path test case where unicode characters stay…
chfw 7911bdf
:bug: fix unit test expectation because of the difference between win…
chfw 7a5402b
:tractor: avoid Windows File URI for fs purpose
chfw eab400f
:bug: before quote, utf8 string needs to be encoded. https://stackove…
chfw 7f222a4
:tractor: respect rfc 3986, where unicode will be quoted
chfw 72ce8f4
:green_heart: :hammer: code refactor and fix broken unit tests
chfw 5771586
:shirt: address review feedback from @lurch
chfw 7656846
:green_heart: fix typo in code and :shirt: update assertions
chfw 5d1efd7
:fire: remove unused variable
chfw 29a394e
:shirt: address further comments from @lurch
chfw 4243a59
:green_heart: update windows test case. fix the typo
chfw 896e717
:bug: colon:tmp is bad path under windows
chfw f2fe735
:bug: forward slash on Windows is a valid path separator
chfw 88a0b3a
:green_heart: fix unit tests on travis-ci
chfw c8685f6
:shirt: address review comments
chfw 53f597a
:shirt: mypy compliance
chfw 15c43d9
:shirt: dot the i and cross the t
chfw 6f33be3
:handshake: merge with remote master
chfw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.