-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
52 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
""" | ||
GitHub implementation of UPath | ||
""" | ||
|
||
import upath.core | ||
|
||
|
||
class _GitHubAccessor(upath.core._FSSpecAccessor): | ||
""" | ||
FSSpecAccessor for GitHub | ||
""" | ||
|
||
def _format_path(self, path: upath.core.UPath) -> str: | ||
""" | ||
Remove the leading slash from the path | ||
""" | ||
return path._path.lstrip("/") | ||
|
||
|
||
class GitHubPath(upath.core.UPath): | ||
""" | ||
GitHubPath supporting the fsspec.GitHubFileSystem | ||
""" | ||
|
||
_default_accessor = _GitHubAccessor |
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,25 @@ | ||
import pytest | ||
|
||
from upath import UPath | ||
from upath.implementations.github import GitHubPath | ||
from upath.tests.cases import BaseTests | ||
|
||
|
||
class TestUPathGitHubPath(BaseTests): | ||
""" | ||
Unit-tests for the GitHubPath implementation of UPath. | ||
""" | ||
|
||
@pytest.fixture(autouse=True) | ||
def path(self): | ||
""" | ||
Fixture for the UPath instance to be tested. | ||
""" | ||
path = "github://fsspec:universal_pathlib@main" | ||
self.path = UPath(path) | ||
|
||
def test_is_GitHubPath(self): | ||
""" | ||
Test that the path is a GitHubPath instance. | ||
""" | ||
assert isinstance(self.path, GitHubPath) |
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 |
---|---|---|
|
@@ -22,6 +22,7 @@ | |
"s3a", | ||
"webdav+http", | ||
"webdav+https", | ||
"github", | ||
} | ||
|
||
|
||
|