Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .gitattributes +1 -0
- parrot/lib/libgomp.so.1 +3 -0
- parrot/lib/python3.10/site-packages/charset_normalizer-3.3.2.dist-info/entry_points.txt +2 -0
- parrot/lib/python3.10/site-packages/fsspec/__pycache__/__init__.cpython-310.pyc +0 -0
- parrot/lib/python3.10/site-packages/fsspec/__pycache__/_version.cpython-310.pyc +0 -0
- parrot/lib/python3.10/site-packages/fsspec/__pycache__/archive.cpython-310.pyc +0 -0
- parrot/lib/python3.10/site-packages/fsspec/__pycache__/asyn.cpython-310.pyc +0 -0
- parrot/lib/python3.10/site-packages/fsspec/__pycache__/caching.cpython-310.pyc +0 -0
- parrot/lib/python3.10/site-packages/fsspec/__pycache__/callbacks.cpython-310.pyc +0 -0
- parrot/lib/python3.10/site-packages/fsspec/__pycache__/compression.cpython-310.pyc +0 -0
- parrot/lib/python3.10/site-packages/fsspec/__pycache__/config.cpython-310.pyc +0 -0
- parrot/lib/python3.10/site-packages/fsspec/__pycache__/conftest.cpython-310.pyc +0 -0
- parrot/lib/python3.10/site-packages/fsspec/__pycache__/core.cpython-310.pyc +0 -0
- parrot/lib/python3.10/site-packages/fsspec/__pycache__/dircache.cpython-310.pyc +0 -0
- parrot/lib/python3.10/site-packages/fsspec/__pycache__/exceptions.cpython-310.pyc +0 -0
- parrot/lib/python3.10/site-packages/fsspec/__pycache__/fuse.cpython-310.pyc +0 -0
- parrot/lib/python3.10/site-packages/fsspec/__pycache__/generic.cpython-310.pyc +0 -0
- parrot/lib/python3.10/site-packages/fsspec/__pycache__/gui.cpython-310.pyc +0 -0
- parrot/lib/python3.10/site-packages/fsspec/__pycache__/json.cpython-310.pyc +0 -0
- parrot/lib/python3.10/site-packages/fsspec/__pycache__/mapping.cpython-310.pyc +0 -0
- parrot/lib/python3.10/site-packages/fsspec/__pycache__/parquet.cpython-310.pyc +0 -0
- parrot/lib/python3.10/site-packages/fsspec/__pycache__/registry.cpython-310.pyc +0 -0
- parrot/lib/python3.10/site-packages/fsspec/__pycache__/spec.cpython-310.pyc +0 -0
- parrot/lib/python3.10/site-packages/fsspec/__pycache__/transaction.cpython-310.pyc +0 -0
- parrot/lib/python3.10/site-packages/fsspec/__pycache__/utils.cpython-310.pyc +0 -0
- parrot/lib/python3.10/site-packages/fsspec/implementations/__pycache__/__init__.cpython-310.pyc +0 -0
- parrot/lib/python3.10/site-packages/fsspec/implementations/__pycache__/arrow.cpython-310.pyc +0 -0
- parrot/lib/python3.10/site-packages/fsspec/implementations/__pycache__/cache_mapper.cpython-310.pyc +0 -0
- parrot/lib/python3.10/site-packages/fsspec/implementations/__pycache__/cache_metadata.cpython-310.pyc +0 -0
- parrot/lib/python3.10/site-packages/fsspec/implementations/__pycache__/cached.cpython-310.pyc +0 -0
- parrot/lib/python3.10/site-packages/fsspec/implementations/__pycache__/dask.cpython-310.pyc +0 -0
- parrot/lib/python3.10/site-packages/fsspec/implementations/__pycache__/data.cpython-310.pyc +0 -0
- parrot/lib/python3.10/site-packages/fsspec/implementations/__pycache__/dbfs.cpython-310.pyc +0 -0
- parrot/lib/python3.10/site-packages/fsspec/implementations/__pycache__/dirfs.cpython-310.pyc +0 -0
- parrot/lib/python3.10/site-packages/fsspec/implementations/__pycache__/ftp.cpython-310.pyc +0 -0
- parrot/lib/python3.10/site-packages/fsspec/implementations/__pycache__/git.cpython-310.pyc +0 -0
- parrot/lib/python3.10/site-packages/fsspec/implementations/__pycache__/github.cpython-310.pyc +0 -0
- parrot/lib/python3.10/site-packages/fsspec/implementations/__pycache__/http.cpython-310.pyc +0 -0
- parrot/lib/python3.10/site-packages/fsspec/implementations/__pycache__/jupyter.cpython-310.pyc +0 -0
- parrot/lib/python3.10/site-packages/fsspec/implementations/__pycache__/libarchive.cpython-310.pyc +0 -0
- parrot/lib/python3.10/site-packages/fsspec/implementations/__pycache__/local.cpython-310.pyc +0 -0
- parrot/lib/python3.10/site-packages/fsspec/implementations/__pycache__/memory.cpython-310.pyc +0 -0
- parrot/lib/python3.10/site-packages/fsspec/implementations/__pycache__/reference.cpython-310.pyc +0 -0
- parrot/lib/python3.10/site-packages/fsspec/implementations/__pycache__/sftp.cpython-310.pyc +0 -0
- parrot/lib/python3.10/site-packages/fsspec/implementations/__pycache__/smb.cpython-310.pyc +0 -0
- parrot/lib/python3.10/site-packages/fsspec/implementations/__pycache__/tar.cpython-310.pyc +0 -0
- parrot/lib/python3.10/site-packages/fsspec/implementations/__pycache__/webhdfs.cpython-310.pyc +0 -0
- parrot/lib/python3.10/site-packages/fsspec/implementations/__pycache__/zip.cpython-310.pyc +0 -0
- parrot/lib/python3.10/site-packages/fsspec/implementations/cache_mapper.py +75 -0
- parrot/lib/python3.10/site-packages/fsspec/implementations/dirfs.py +366 -0
.gitattributes
CHANGED
|
@@ -153,3 +153,4 @@ parrot/lib/libssl.so filter=lfs diff=lfs merge=lfs -text
|
|
| 153 |
parrot/lib/libitm.so filter=lfs diff=lfs merge=lfs -text
|
| 154 |
parrot/lib/python3.10/site-packages/wandb/sdk/__pycache__/wandb_run.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
|
| 155 |
parrot/lib/python3.10/site-packages/wandb/sdk/internal/__pycache__/internal_api.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 153 |
parrot/lib/libitm.so filter=lfs diff=lfs merge=lfs -text
|
| 154 |
parrot/lib/python3.10/site-packages/wandb/sdk/__pycache__/wandb_run.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
|
| 155 |
parrot/lib/python3.10/site-packages/wandb/sdk/internal/__pycache__/internal_api.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
|
| 156 |
+
parrot/lib/libgomp.so.1 filter=lfs diff=lfs merge=lfs -text
|
parrot/lib/libgomp.so.1
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e3b68c5f37afb7b70bd12273b69706ab33a397714e8336910f0e47f8f1cf6854
|
| 3 |
+
size 1265616
|
parrot/lib/python3.10/site-packages/charset_normalizer-3.3.2.dist-info/entry_points.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[console_scripts]
|
| 2 |
+
normalizer = charset_normalizer.cli:cli_detect
|
parrot/lib/python3.10/site-packages/fsspec/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (1.44 kB). View file
|
|
|
parrot/lib/python3.10/site-packages/fsspec/__pycache__/_version.cpython-310.pyc
ADDED
|
Binary file (484 Bytes). View file
|
|
|
parrot/lib/python3.10/site-packages/fsspec/__pycache__/archive.cpython-310.pyc
ADDED
|
Binary file (2.97 kB). View file
|
|
|
parrot/lib/python3.10/site-packages/fsspec/__pycache__/asyn.cpython-310.pyc
ADDED
|
Binary file (29.3 kB). View file
|
|
|
parrot/lib/python3.10/site-packages/fsspec/__pycache__/caching.cpython-310.pyc
ADDED
|
Binary file (23.8 kB). View file
|
|
|
parrot/lib/python3.10/site-packages/fsspec/__pycache__/callbacks.cpython-310.pyc
ADDED
|
Binary file (10.9 kB). View file
|
|
|
parrot/lib/python3.10/site-packages/fsspec/__pycache__/compression.cpython-310.pyc
ADDED
|
Binary file (5.09 kB). View file
|
|
|
parrot/lib/python3.10/site-packages/fsspec/__pycache__/config.cpython-310.pyc
ADDED
|
Binary file (3.81 kB). View file
|
|
|
parrot/lib/python3.10/site-packages/fsspec/__pycache__/conftest.cpython-310.pyc
ADDED
|
Binary file (1.55 kB). View file
|
|
|
parrot/lib/python3.10/site-packages/fsspec/__pycache__/core.cpython-310.pyc
ADDED
|
Binary file (22.2 kB). View file
|
|
|
parrot/lib/python3.10/site-packages/fsspec/__pycache__/dircache.cpython-310.pyc
ADDED
|
Binary file (3.4 kB). View file
|
|
|
parrot/lib/python3.10/site-packages/fsspec/__pycache__/exceptions.cpython-310.pyc
ADDED
|
Binary file (722 Bytes). View file
|
|
|
parrot/lib/python3.10/site-packages/fsspec/__pycache__/fuse.cpython-310.pyc
ADDED
|
Binary file (10.1 kB). View file
|
|
|
parrot/lib/python3.10/site-packages/fsspec/__pycache__/generic.cpython-310.pyc
ADDED
|
Binary file (12.7 kB). View file
|
|
|
parrot/lib/python3.10/site-packages/fsspec/__pycache__/gui.cpython-310.pyc
ADDED
|
Binary file (14.6 kB). View file
|
|
|
parrot/lib/python3.10/site-packages/fsspec/__pycache__/json.cpython-310.pyc
ADDED
|
Binary file (4.58 kB). View file
|
|
|
parrot/lib/python3.10/site-packages/fsspec/__pycache__/mapping.cpython-310.pyc
ADDED
|
Binary file (8.94 kB). View file
|
|
|
parrot/lib/python3.10/site-packages/fsspec/__pycache__/parquet.cpython-310.pyc
ADDED
|
Binary file (11.2 kB). View file
|
|
|
parrot/lib/python3.10/site-packages/fsspec/__pycache__/registry.cpython-310.pyc
ADDED
|
Binary file (8.87 kB). View file
|
|
|
parrot/lib/python3.10/site-packages/fsspec/__pycache__/spec.cpython-310.pyc
ADDED
|
Binary file (61.3 kB). View file
|
|
|
parrot/lib/python3.10/site-packages/fsspec/__pycache__/transaction.cpython-310.pyc
ADDED
|
Binary file (3.19 kB). View file
|
|
|
parrot/lib/python3.10/site-packages/fsspec/__pycache__/utils.cpython-310.pyc
ADDED
|
Binary file (19.9 kB). View file
|
|
|
parrot/lib/python3.10/site-packages/fsspec/implementations/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (174 Bytes). View file
|
|
|
parrot/lib/python3.10/site-packages/fsspec/implementations/__pycache__/arrow.cpython-310.pyc
ADDED
|
Binary file (9.05 kB). View file
|
|
|
parrot/lib/python3.10/site-packages/fsspec/implementations/__pycache__/cache_mapper.cpython-310.pyc
ADDED
|
Binary file (3.26 kB). View file
|
|
|
parrot/lib/python3.10/site-packages/fsspec/implementations/__pycache__/cache_metadata.cpython-310.pyc
ADDED
|
Binary file (7.53 kB). View file
|
|
|
parrot/lib/python3.10/site-packages/fsspec/implementations/__pycache__/cached.cpython-310.pyc
ADDED
|
Binary file (28.8 kB). View file
|
|
|
parrot/lib/python3.10/site-packages/fsspec/implementations/__pycache__/dask.cpython-310.pyc
ADDED
|
Binary file (4.74 kB). View file
|
|
|
parrot/lib/python3.10/site-packages/fsspec/implementations/__pycache__/data.cpython-310.pyc
ADDED
|
Binary file (2.28 kB). View file
|
|
|
parrot/lib/python3.10/site-packages/fsspec/implementations/__pycache__/dbfs.cpython-310.pyc
ADDED
|
Binary file (13.7 kB). View file
|
|
|
parrot/lib/python3.10/site-packages/fsspec/implementations/__pycache__/dirfs.cpython-310.pyc
ADDED
|
Binary file (13.7 kB). View file
|
|
|
parrot/lib/python3.10/site-packages/fsspec/implementations/__pycache__/ftp.cpython-310.pyc
ADDED
|
Binary file (11.1 kB). View file
|
|
|
parrot/lib/python3.10/site-packages/fsspec/implementations/__pycache__/git.cpython-310.pyc
ADDED
|
Binary file (3.84 kB). View file
|
|
|
parrot/lib/python3.10/site-packages/fsspec/implementations/__pycache__/github.cpython-310.pyc
ADDED
|
Binary file (8.19 kB). View file
|
|
|
parrot/lib/python3.10/site-packages/fsspec/implementations/__pycache__/http.cpython-310.pyc
ADDED
|
Binary file (24.4 kB). View file
|
|
|
parrot/lib/python3.10/site-packages/fsspec/implementations/__pycache__/jupyter.cpython-310.pyc
ADDED
|
Binary file (4.19 kB). View file
|
|
|
parrot/lib/python3.10/site-packages/fsspec/implementations/__pycache__/libarchive.cpython-310.pyc
ADDED
|
Binary file (6.06 kB). View file
|
|
|
parrot/lib/python3.10/site-packages/fsspec/implementations/__pycache__/local.cpython-310.pyc
ADDED
|
Binary file (14.5 kB). View file
|
|
|
parrot/lib/python3.10/site-packages/fsspec/implementations/__pycache__/memory.cpython-310.pyc
ADDED
|
Binary file (8.19 kB). View file
|
|
|
parrot/lib/python3.10/site-packages/fsspec/implementations/__pycache__/reference.cpython-310.pyc
ADDED
|
Binary file (37.4 kB). View file
|
|
|
parrot/lib/python3.10/site-packages/fsspec/implementations/__pycache__/sftp.cpython-310.pyc
ADDED
|
Binary file (6.32 kB). View file
|
|
|
parrot/lib/python3.10/site-packages/fsspec/implementations/__pycache__/smb.cpython-310.pyc
ADDED
|
Binary file (11.8 kB). View file
|
|
|
parrot/lib/python3.10/site-packages/fsspec/implementations/__pycache__/tar.cpython-310.pyc
ADDED
|
Binary file (3.02 kB). View file
|
|
|
parrot/lib/python3.10/site-packages/fsspec/implementations/__pycache__/webhdfs.cpython-310.pyc
ADDED
|
Binary file (16 kB). View file
|
|
|
parrot/lib/python3.10/site-packages/fsspec/implementations/__pycache__/zip.cpython-310.pyc
ADDED
|
Binary file (4.21 kB). View file
|
|
|
parrot/lib/python3.10/site-packages/fsspec/implementations/cache_mapper.py
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
import abc
|
| 4 |
+
import hashlib
|
| 5 |
+
|
| 6 |
+
from fsspec.implementations.local import make_path_posix
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class AbstractCacheMapper(abc.ABC):
|
| 10 |
+
"""Abstract super-class for mappers from remote URLs to local cached
|
| 11 |
+
basenames.
|
| 12 |
+
"""
|
| 13 |
+
|
| 14 |
+
@abc.abstractmethod
|
| 15 |
+
def __call__(self, path: str) -> str: ...
|
| 16 |
+
|
| 17 |
+
def __eq__(self, other: object) -> bool:
|
| 18 |
+
# Identity only depends on class. When derived classes have attributes
|
| 19 |
+
# they will need to be included.
|
| 20 |
+
return isinstance(other, type(self))
|
| 21 |
+
|
| 22 |
+
def __hash__(self) -> int:
|
| 23 |
+
# Identity only depends on class. When derived classes have attributes
|
| 24 |
+
# they will need to be included.
|
| 25 |
+
return hash(type(self))
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
class BasenameCacheMapper(AbstractCacheMapper):
|
| 29 |
+
"""Cache mapper that uses the basename of the remote URL and a fixed number
|
| 30 |
+
of directory levels above this.
|
| 31 |
+
|
| 32 |
+
The default is zero directory levels, meaning different paths with the same
|
| 33 |
+
basename will have the same cached basename.
|
| 34 |
+
"""
|
| 35 |
+
|
| 36 |
+
def __init__(self, directory_levels: int = 0):
|
| 37 |
+
if directory_levels < 0:
|
| 38 |
+
raise ValueError(
|
| 39 |
+
"BasenameCacheMapper requires zero or positive directory_levels"
|
| 40 |
+
)
|
| 41 |
+
self.directory_levels = directory_levels
|
| 42 |
+
|
| 43 |
+
# Separator for directories when encoded as strings.
|
| 44 |
+
self._separator = "_@_"
|
| 45 |
+
|
| 46 |
+
def __call__(self, path: str) -> str:
|
| 47 |
+
path = make_path_posix(path)
|
| 48 |
+
prefix, *bits = path.rsplit("/", self.directory_levels + 1)
|
| 49 |
+
if bits:
|
| 50 |
+
return self._separator.join(bits)
|
| 51 |
+
else:
|
| 52 |
+
return prefix # No separator found, simple filename
|
| 53 |
+
|
| 54 |
+
def __eq__(self, other: object) -> bool:
|
| 55 |
+
return super().__eq__(other) and self.directory_levels == other.directory_levels
|
| 56 |
+
|
| 57 |
+
def __hash__(self) -> int:
|
| 58 |
+
return super().__hash__() ^ hash(self.directory_levels)
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
class HashCacheMapper(AbstractCacheMapper):
|
| 62 |
+
"""Cache mapper that uses a hash of the remote URL."""
|
| 63 |
+
|
| 64 |
+
def __call__(self, path: str) -> str:
|
| 65 |
+
return hashlib.sha256(path.encode()).hexdigest()
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
def create_cache_mapper(same_names: bool) -> AbstractCacheMapper:
|
| 69 |
+
"""Factory method to create cache mapper for backward compatibility with
|
| 70 |
+
``CachingFileSystem`` constructor using ``same_names`` kwarg.
|
| 71 |
+
"""
|
| 72 |
+
if same_names:
|
| 73 |
+
return BasenameCacheMapper()
|
| 74 |
+
else:
|
| 75 |
+
return HashCacheMapper()
|
parrot/lib/python3.10/site-packages/fsspec/implementations/dirfs.py
ADDED
|
@@ -0,0 +1,366 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from .. import filesystem
|
| 2 |
+
from ..asyn import AsyncFileSystem
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
class DirFileSystem(AsyncFileSystem):
|
| 6 |
+
"""Directory prefix filesystem
|
| 7 |
+
|
| 8 |
+
The DirFileSystem is a filesystem-wrapper. It assumes every path it is dealing with
|
| 9 |
+
is relative to the `path`. After performing the necessary paths operation it
|
| 10 |
+
delegates everything to the wrapped filesystem.
|
| 11 |
+
"""
|
| 12 |
+
|
| 13 |
+
protocol = "dir"
|
| 14 |
+
|
| 15 |
+
def __init__(
|
| 16 |
+
self,
|
| 17 |
+
path=None,
|
| 18 |
+
fs=None,
|
| 19 |
+
fo=None,
|
| 20 |
+
target_protocol=None,
|
| 21 |
+
target_options=None,
|
| 22 |
+
**storage_options,
|
| 23 |
+
):
|
| 24 |
+
"""
|
| 25 |
+
Parameters
|
| 26 |
+
----------
|
| 27 |
+
path: str
|
| 28 |
+
Path to the directory.
|
| 29 |
+
fs: AbstractFileSystem
|
| 30 |
+
An instantiated filesystem to wrap.
|
| 31 |
+
target_protocol, target_options:
|
| 32 |
+
if fs is none, construct it from these
|
| 33 |
+
fo: str
|
| 34 |
+
Alternate for path; do not provide both
|
| 35 |
+
"""
|
| 36 |
+
super().__init__(**storage_options)
|
| 37 |
+
if fs is None:
|
| 38 |
+
fs = filesystem(protocol=target_protocol, **(target_options or {}))
|
| 39 |
+
if (path is not None) ^ (fo is not None) is False:
|
| 40 |
+
raise ValueError("Provide path or fo, not both")
|
| 41 |
+
path = path or fo
|
| 42 |
+
|
| 43 |
+
if self.asynchronous and not fs.async_impl:
|
| 44 |
+
raise ValueError("can't use asynchronous with non-async fs")
|
| 45 |
+
|
| 46 |
+
if fs.async_impl and self.asynchronous != fs.asynchronous:
|
| 47 |
+
raise ValueError("both dirfs and fs should be in the same sync/async mode")
|
| 48 |
+
|
| 49 |
+
self.path = fs._strip_protocol(path)
|
| 50 |
+
self.fs = fs
|
| 51 |
+
|
| 52 |
+
def _join(self, path):
|
| 53 |
+
if isinstance(path, str):
|
| 54 |
+
if not self.path:
|
| 55 |
+
return path
|
| 56 |
+
if not path:
|
| 57 |
+
return self.path
|
| 58 |
+
return self.fs.sep.join((self.path, self._strip_protocol(path)))
|
| 59 |
+
if isinstance(path, dict):
|
| 60 |
+
return {self._join(_path): value for _path, value in path.items()}
|
| 61 |
+
return [self._join(_path) for _path in path]
|
| 62 |
+
|
| 63 |
+
def _relpath(self, path):
|
| 64 |
+
if isinstance(path, str):
|
| 65 |
+
if not self.path:
|
| 66 |
+
return path
|
| 67 |
+
if path == self.path:
|
| 68 |
+
return ""
|
| 69 |
+
prefix = self.path + self.fs.sep
|
| 70 |
+
assert path.startswith(prefix)
|
| 71 |
+
return path[len(prefix) :]
|
| 72 |
+
return [self._relpath(_path) for _path in path]
|
| 73 |
+
|
| 74 |
+
# Wrappers below
|
| 75 |
+
|
| 76 |
+
@property
|
| 77 |
+
def sep(self):
|
| 78 |
+
return self.fs.sep
|
| 79 |
+
|
| 80 |
+
async def set_session(self, *args, **kwargs):
|
| 81 |
+
return await self.fs.set_session(*args, **kwargs)
|
| 82 |
+
|
| 83 |
+
async def _rm_file(self, path, **kwargs):
|
| 84 |
+
return await self.fs._rm_file(self._join(path), **kwargs)
|
| 85 |
+
|
| 86 |
+
def rm_file(self, path, **kwargs):
|
| 87 |
+
return self.fs.rm_file(self._join(path), **kwargs)
|
| 88 |
+
|
| 89 |
+
async def _rm(self, path, *args, **kwargs):
|
| 90 |
+
return await self.fs._rm(self._join(path), *args, **kwargs)
|
| 91 |
+
|
| 92 |
+
def rm(self, path, *args, **kwargs):
|
| 93 |
+
return self.fs.rm(self._join(path), *args, **kwargs)
|
| 94 |
+
|
| 95 |
+
async def _cp_file(self, path1, path2, **kwargs):
|
| 96 |
+
return await self.fs._cp_file(self._join(path1), self._join(path2), **kwargs)
|
| 97 |
+
|
| 98 |
+
def cp_file(self, path1, path2, **kwargs):
|
| 99 |
+
return self.fs.cp_file(self._join(path1), self._join(path2), **kwargs)
|
| 100 |
+
|
| 101 |
+
async def _copy(
|
| 102 |
+
self,
|
| 103 |
+
path1,
|
| 104 |
+
path2,
|
| 105 |
+
*args,
|
| 106 |
+
**kwargs,
|
| 107 |
+
):
|
| 108 |
+
return await self.fs._copy(
|
| 109 |
+
self._join(path1),
|
| 110 |
+
self._join(path2),
|
| 111 |
+
*args,
|
| 112 |
+
**kwargs,
|
| 113 |
+
)
|
| 114 |
+
|
| 115 |
+
def copy(self, path1, path2, *args, **kwargs):
|
| 116 |
+
return self.fs.copy(
|
| 117 |
+
self._join(path1),
|
| 118 |
+
self._join(path2),
|
| 119 |
+
*args,
|
| 120 |
+
**kwargs,
|
| 121 |
+
)
|
| 122 |
+
|
| 123 |
+
async def _pipe(self, path, *args, **kwargs):
|
| 124 |
+
return await self.fs._pipe(self._join(path), *args, **kwargs)
|
| 125 |
+
|
| 126 |
+
def pipe(self, path, *args, **kwargs):
|
| 127 |
+
return self.fs.pipe(self._join(path), *args, **kwargs)
|
| 128 |
+
|
| 129 |
+
async def _pipe_file(self, path, *args, **kwargs):
|
| 130 |
+
return await self.fs._pipe_file(self._join(path), *args, **kwargs)
|
| 131 |
+
|
| 132 |
+
def pipe_file(self, path, *args, **kwargs):
|
| 133 |
+
return self.fs.pipe_file(self._join(path), *args, **kwargs)
|
| 134 |
+
|
| 135 |
+
async def _cat_file(self, path, *args, **kwargs):
|
| 136 |
+
return await self.fs._cat_file(self._join(path), *args, **kwargs)
|
| 137 |
+
|
| 138 |
+
def cat_file(self, path, *args, **kwargs):
|
| 139 |
+
return self.fs.cat_file(self._join(path), *args, **kwargs)
|
| 140 |
+
|
| 141 |
+
async def _cat(self, path, *args, **kwargs):
|
| 142 |
+
ret = await self.fs._cat(
|
| 143 |
+
self._join(path),
|
| 144 |
+
*args,
|
| 145 |
+
**kwargs,
|
| 146 |
+
)
|
| 147 |
+
|
| 148 |
+
if isinstance(ret, dict):
|
| 149 |
+
return {self._relpath(key): value for key, value in ret.items()}
|
| 150 |
+
|
| 151 |
+
return ret
|
| 152 |
+
|
| 153 |
+
def cat(self, path, *args, **kwargs):
|
| 154 |
+
ret = self.fs.cat(
|
| 155 |
+
self._join(path),
|
| 156 |
+
*args,
|
| 157 |
+
**kwargs,
|
| 158 |
+
)
|
| 159 |
+
|
| 160 |
+
if isinstance(ret, dict):
|
| 161 |
+
return {self._relpath(key): value for key, value in ret.items()}
|
| 162 |
+
|
| 163 |
+
return ret
|
| 164 |
+
|
| 165 |
+
async def _put_file(self, lpath, rpath, **kwargs):
|
| 166 |
+
return await self.fs._put_file(lpath, self._join(rpath), **kwargs)
|
| 167 |
+
|
| 168 |
+
def put_file(self, lpath, rpath, **kwargs):
|
| 169 |
+
return self.fs.put_file(lpath, self._join(rpath), **kwargs)
|
| 170 |
+
|
| 171 |
+
async def _put(
|
| 172 |
+
self,
|
| 173 |
+
lpath,
|
| 174 |
+
rpath,
|
| 175 |
+
*args,
|
| 176 |
+
**kwargs,
|
| 177 |
+
):
|
| 178 |
+
return await self.fs._put(
|
| 179 |
+
lpath,
|
| 180 |
+
self._join(rpath),
|
| 181 |
+
*args,
|
| 182 |
+
**kwargs,
|
| 183 |
+
)
|
| 184 |
+
|
| 185 |
+
def put(self, lpath, rpath, *args, **kwargs):
|
| 186 |
+
return self.fs.put(
|
| 187 |
+
lpath,
|
| 188 |
+
self._join(rpath),
|
| 189 |
+
*args,
|
| 190 |
+
**kwargs,
|
| 191 |
+
)
|
| 192 |
+
|
| 193 |
+
async def _get_file(self, rpath, lpath, **kwargs):
|
| 194 |
+
return await self.fs._get_file(self._join(rpath), lpath, **kwargs)
|
| 195 |
+
|
| 196 |
+
def get_file(self, rpath, lpath, **kwargs):
|
| 197 |
+
return self.fs.get_file(self._join(rpath), lpath, **kwargs)
|
| 198 |
+
|
| 199 |
+
async def _get(self, rpath, *args, **kwargs):
|
| 200 |
+
return await self.fs._get(self._join(rpath), *args, **kwargs)
|
| 201 |
+
|
| 202 |
+
def get(self, rpath, *args, **kwargs):
|
| 203 |
+
return self.fs.get(self._join(rpath), *args, **kwargs)
|
| 204 |
+
|
| 205 |
+
async def _isfile(self, path):
|
| 206 |
+
return await self.fs._isfile(self._join(path))
|
| 207 |
+
|
| 208 |
+
def isfile(self, path):
|
| 209 |
+
return self.fs.isfile(self._join(path))
|
| 210 |
+
|
| 211 |
+
async def _isdir(self, path):
|
| 212 |
+
return await self.fs._isdir(self._join(path))
|
| 213 |
+
|
| 214 |
+
def isdir(self, path):
|
| 215 |
+
return self.fs.isdir(self._join(path))
|
| 216 |
+
|
| 217 |
+
async def _size(self, path):
|
| 218 |
+
return await self.fs._size(self._join(path))
|
| 219 |
+
|
| 220 |
+
def size(self, path):
|
| 221 |
+
return self.fs.size(self._join(path))
|
| 222 |
+
|
| 223 |
+
async def _exists(self, path):
|
| 224 |
+
return await self.fs._exists(self._join(path))
|
| 225 |
+
|
| 226 |
+
def exists(self, path):
|
| 227 |
+
return self.fs.exists(self._join(path))
|
| 228 |
+
|
| 229 |
+
async def _info(self, path, **kwargs):
|
| 230 |
+
return await self.fs._info(self._join(path), **kwargs)
|
| 231 |
+
|
| 232 |
+
def info(self, path, **kwargs):
|
| 233 |
+
return self.fs.info(self._join(path), **kwargs)
|
| 234 |
+
|
| 235 |
+
async def _ls(self, path, detail=True, **kwargs):
|
| 236 |
+
ret = (await self.fs._ls(self._join(path), detail=detail, **kwargs)).copy()
|
| 237 |
+
if detail:
|
| 238 |
+
out = []
|
| 239 |
+
for entry in ret:
|
| 240 |
+
entry = entry.copy()
|
| 241 |
+
entry["name"] = self._relpath(entry["name"])
|
| 242 |
+
out.append(entry)
|
| 243 |
+
return out
|
| 244 |
+
|
| 245 |
+
return self._relpath(ret)
|
| 246 |
+
|
| 247 |
+
def ls(self, path, detail=True, **kwargs):
|
| 248 |
+
ret = self.fs.ls(self._join(path), detail=detail, **kwargs).copy()
|
| 249 |
+
if detail:
|
| 250 |
+
out = []
|
| 251 |
+
for entry in ret:
|
| 252 |
+
entry = entry.copy()
|
| 253 |
+
entry["name"] = self._relpath(entry["name"])
|
| 254 |
+
out.append(entry)
|
| 255 |
+
return out
|
| 256 |
+
|
| 257 |
+
return self._relpath(ret)
|
| 258 |
+
|
| 259 |
+
async def _walk(self, path, *args, **kwargs):
|
| 260 |
+
async for root, dirs, files in self.fs._walk(self._join(path), *args, **kwargs):
|
| 261 |
+
yield self._relpath(root), dirs, files
|
| 262 |
+
|
| 263 |
+
def walk(self, path, *args, **kwargs):
|
| 264 |
+
for root, dirs, files in self.fs.walk(self._join(path), *args, **kwargs):
|
| 265 |
+
yield self._relpath(root), dirs, files
|
| 266 |
+
|
| 267 |
+
async def _glob(self, path, **kwargs):
|
| 268 |
+
detail = kwargs.get("detail", False)
|
| 269 |
+
ret = await self.fs._glob(self._join(path), **kwargs)
|
| 270 |
+
if detail:
|
| 271 |
+
return {self._relpath(path): info for path, info in ret.items()}
|
| 272 |
+
return self._relpath(ret)
|
| 273 |
+
|
| 274 |
+
def glob(self, path, **kwargs):
|
| 275 |
+
detail = kwargs.get("detail", False)
|
| 276 |
+
ret = self.fs.glob(self._join(path), **kwargs)
|
| 277 |
+
if detail:
|
| 278 |
+
return {self._relpath(path): info for path, info in ret.items()}
|
| 279 |
+
return self._relpath(ret)
|
| 280 |
+
|
| 281 |
+
async def _du(self, path, *args, **kwargs):
|
| 282 |
+
total = kwargs.get("total", True)
|
| 283 |
+
ret = await self.fs._du(self._join(path), *args, **kwargs)
|
| 284 |
+
if total:
|
| 285 |
+
return ret
|
| 286 |
+
|
| 287 |
+
return {self._relpath(path): size for path, size in ret.items()}
|
| 288 |
+
|
| 289 |
+
def du(self, path, *args, **kwargs):
|
| 290 |
+
total = kwargs.get("total", True)
|
| 291 |
+
ret = self.fs.du(self._join(path), *args, **kwargs)
|
| 292 |
+
if total:
|
| 293 |
+
return ret
|
| 294 |
+
|
| 295 |
+
return {self._relpath(path): size for path, size in ret.items()}
|
| 296 |
+
|
| 297 |
+
async def _find(self, path, *args, **kwargs):
|
| 298 |
+
detail = kwargs.get("detail", False)
|
| 299 |
+
ret = await self.fs._find(self._join(path), *args, **kwargs)
|
| 300 |
+
if detail:
|
| 301 |
+
return {self._relpath(path): info for path, info in ret.items()}
|
| 302 |
+
return self._relpath(ret)
|
| 303 |
+
|
| 304 |
+
def find(self, path, *args, **kwargs):
|
| 305 |
+
detail = kwargs.get("detail", False)
|
| 306 |
+
ret = self.fs.find(self._join(path), *args, **kwargs)
|
| 307 |
+
if detail:
|
| 308 |
+
return {self._relpath(path): info for path, info in ret.items()}
|
| 309 |
+
return self._relpath(ret)
|
| 310 |
+
|
| 311 |
+
async def _expand_path(self, path, *args, **kwargs):
|
| 312 |
+
return self._relpath(
|
| 313 |
+
await self.fs._expand_path(self._join(path), *args, **kwargs)
|
| 314 |
+
)
|
| 315 |
+
|
| 316 |
+
def expand_path(self, path, *args, **kwargs):
|
| 317 |
+
return self._relpath(self.fs.expand_path(self._join(path), *args, **kwargs))
|
| 318 |
+
|
| 319 |
+
async def _mkdir(self, path, *args, **kwargs):
|
| 320 |
+
return await self.fs._mkdir(self._join(path), *args, **kwargs)
|
| 321 |
+
|
| 322 |
+
def mkdir(self, path, *args, **kwargs):
|
| 323 |
+
return self.fs.mkdir(self._join(path), *args, **kwargs)
|
| 324 |
+
|
| 325 |
+
async def _makedirs(self, path, *args, **kwargs):
|
| 326 |
+
return await self.fs._makedirs(self._join(path), *args, **kwargs)
|
| 327 |
+
|
| 328 |
+
def makedirs(self, path, *args, **kwargs):
|
| 329 |
+
return self.fs.makedirs(self._join(path), *args, **kwargs)
|
| 330 |
+
|
| 331 |
+
def rmdir(self, path):
|
| 332 |
+
return self.fs.rmdir(self._join(path))
|
| 333 |
+
|
| 334 |
+
def mv(self, path1, path2, **kwargs):
|
| 335 |
+
return self.fs.mv(
|
| 336 |
+
self._join(path1),
|
| 337 |
+
self._join(path2),
|
| 338 |
+
**kwargs,
|
| 339 |
+
)
|
| 340 |
+
|
| 341 |
+
def touch(self, path, **kwargs):
|
| 342 |
+
return self.fs.touch(self._join(path), **kwargs)
|
| 343 |
+
|
| 344 |
+
def created(self, path):
|
| 345 |
+
return self.fs.created(self._join(path))
|
| 346 |
+
|
| 347 |
+
def modified(self, path):
|
| 348 |
+
return self.fs.modified(self._join(path))
|
| 349 |
+
|
| 350 |
+
def sign(self, path, *args, **kwargs):
|
| 351 |
+
return self.fs.sign(self._join(path), *args, **kwargs)
|
| 352 |
+
|
| 353 |
+
def __repr__(self):
|
| 354 |
+
return f"{self.__class__.__qualname__}(path='{self.path}', fs={self.fs})"
|
| 355 |
+
|
| 356 |
+
def open(
|
| 357 |
+
self,
|
| 358 |
+
path,
|
| 359 |
+
*args,
|
| 360 |
+
**kwargs,
|
| 361 |
+
):
|
| 362 |
+
return self.fs.open(
|
| 363 |
+
self._join(path),
|
| 364 |
+
*args,
|
| 365 |
+
**kwargs,
|
| 366 |
+
)
|