panpath 0.4.3__tar.gz → 0.4.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {panpath-0.4.3 → panpath-0.4.5}/PKG-INFO +1 -1
- {panpath-0.4.3 → panpath-0.4.5}/panpath/__init__.py +1 -1
- {panpath-0.4.3 → panpath-0.4.5}/panpath/base.py +1 -1
- {panpath-0.4.3 → panpath-0.4.5}/panpath/clients.py +5 -1
- {panpath-0.4.3 → panpath-0.4.5}/panpath/cloud.py +23 -7
- {panpath-0.4.3 → panpath-0.4.5}/panpath/local_path.py +5 -2
- {panpath-0.4.3 → panpath-0.4.5}/pyproject.toml +1 -1
- {panpath-0.4.3 → panpath-0.4.5}/LICENSE +0 -0
- {panpath-0.4.3 → panpath-0.4.5}/README.md +0 -0
- {panpath-0.4.3 → panpath-0.4.5}/panpath/azure_async_client.py +0 -0
- {panpath-0.4.3 → panpath-0.4.5}/panpath/azure_client.py +0 -0
- {panpath-0.4.3 → panpath-0.4.5}/panpath/azure_path.py +0 -0
- {panpath-0.4.3 → panpath-0.4.5}/panpath/exceptions.py +0 -0
- {panpath-0.4.3 → panpath-0.4.5}/panpath/gs_async_client.py +0 -0
- {panpath-0.4.3 → panpath-0.4.5}/panpath/gs_client.py +0 -0
- {panpath-0.4.3 → panpath-0.4.5}/panpath/gs_path.py +0 -0
- {panpath-0.4.3 → panpath-0.4.5}/panpath/py.typed +0 -0
- {panpath-0.4.3 → panpath-0.4.5}/panpath/registry.py +0 -0
- {panpath-0.4.3 → panpath-0.4.5}/panpath/s3_async_client.py +0 -0
- {panpath-0.4.3 → panpath-0.4.5}/panpath/s3_client.py +0 -0
- {panpath-0.4.3 → panpath-0.4.5}/panpath/s3_path.py +0 -0
|
@@ -214,7 +214,7 @@ class PanPath(PathlibPath):
|
|
|
214
214
|
"""
|
|
215
215
|
|
|
216
216
|
@abstractmethod
|
|
217
|
-
async def a_stat(self) -> os.stat_result:
|
|
217
|
+
async def a_stat(self, follow_symlinks: bool = True) -> os.stat_result:
|
|
218
218
|
"""Asynchronously get the file or directory's status information.
|
|
219
219
|
|
|
220
220
|
Returns:
|
|
@@ -449,7 +449,11 @@ class AsyncFileHandle(ABC):
|
|
|
449
449
|
# return "".join(chunks)
|
|
450
450
|
|
|
451
451
|
async def flush(self) -> None:
|
|
452
|
-
"""Flush write buffer (optional, default implementation is no-op).
|
|
452
|
+
"""Flush write buffer (optional, default implementation is no-op).
|
|
453
|
+
|
|
454
|
+
Note latter flush will overwrite previous data in cloud storage.
|
|
455
|
+
Incremental flush is not supported in this base implementation.
|
|
456
|
+
"""
|
|
453
457
|
if self._closed: # pragma: no cover
|
|
454
458
|
raise ValueError("I/O operation on closed file")
|
|
455
459
|
|
|
@@ -191,8 +191,12 @@ class CloudPath(PanPath, PurePosixPath, ABC):
|
|
|
191
191
|
"""Check if path is a file."""
|
|
192
192
|
return self.client.is_file(str(self))
|
|
193
193
|
|
|
194
|
-
def stat(self) -> Any:
|
|
194
|
+
def stat(self, follow_symlinks: bool = True) -> Any:
|
|
195
195
|
"""Get file stats."""
|
|
196
|
+
if follow_symlinks and self.is_symlink():
|
|
197
|
+
target = self.readlink()
|
|
198
|
+
return target.stat()
|
|
199
|
+
|
|
196
200
|
return self.client.stat(str(self))
|
|
197
201
|
|
|
198
202
|
def mkdir(self, mode: int = 0o777, parents: bool = False, exist_ok: bool = False) -> None:
|
|
@@ -378,7 +382,11 @@ class CloudPath(PanPath, PurePosixPath, ABC):
|
|
|
378
382
|
"""
|
|
379
383
|
target = self.client.readlink(str(self))
|
|
380
384
|
|
|
381
|
-
return PanPath(
|
|
385
|
+
return PanPath( # type: ignore
|
|
386
|
+
target,
|
|
387
|
+
client=self._client,
|
|
388
|
+
async_client=self._async_client,
|
|
389
|
+
)
|
|
382
390
|
|
|
383
391
|
def symlink_to(self, target: Union[str, "CloudPath"]) -> None: # type: ignore[override]
|
|
384
392
|
"""Create symlink pointing to target (via metadata).
|
|
@@ -558,8 +566,12 @@ class CloudPath(PanPath, PurePosixPath, ABC):
|
|
|
558
566
|
"""Check if path is a file."""
|
|
559
567
|
return await self.async_client.is_file(str(self))
|
|
560
568
|
|
|
561
|
-
async def a_stat(self) -> Any:
|
|
569
|
+
async def a_stat(self, follow_symlinks: bool = True) -> Any:
|
|
562
570
|
"""Get file stats."""
|
|
571
|
+
if follow_symlinks and await self.a_is_symlink():
|
|
572
|
+
target = await self.a_readlink()
|
|
573
|
+
return await target.a_stat()
|
|
574
|
+
|
|
563
575
|
return await self.async_client.stat(str(self))
|
|
564
576
|
|
|
565
577
|
async def a_mkdir(
|
|
@@ -735,7 +747,11 @@ class CloudPath(PanPath, PurePosixPath, ABC):
|
|
|
735
747
|
"""
|
|
736
748
|
target = await self.async_client.readlink(str(self))
|
|
737
749
|
|
|
738
|
-
return PanPath(
|
|
750
|
+
return PanPath( # type: ignore
|
|
751
|
+
target,
|
|
752
|
+
client=self._client,
|
|
753
|
+
async_client=self._async_client,
|
|
754
|
+
)
|
|
739
755
|
|
|
740
756
|
async def a_symlink_to( # type: ignore[override]
|
|
741
757
|
self,
|
|
@@ -843,9 +859,9 @@ class CloudPath(PanPath, PurePosixPath, ABC):
|
|
|
843
859
|
await dst_path.a_mkdir(parents=True, exist_ok=True)
|
|
844
860
|
|
|
845
861
|
# Walk source tree and copy all files
|
|
846
|
-
for dirpath, dirnames, filenames in
|
|
862
|
+
async for dirpath, dirnames, filenames in src_path.a_walk(): # type: ignore[attr-defined]
|
|
847
863
|
# Calculate relative path from src
|
|
848
|
-
rel_dir = dirpath[len(str(src)) :].lstrip("/")
|
|
864
|
+
rel_dir = str(dirpath)[len(str(src)) :].lstrip("/")
|
|
849
865
|
|
|
850
866
|
# Create subdirectories in destination
|
|
851
867
|
for dirname in dirnames:
|
|
@@ -854,7 +870,7 @@ class CloudPath(PanPath, PurePosixPath, ABC):
|
|
|
854
870
|
|
|
855
871
|
# Copy files
|
|
856
872
|
for filename in filenames:
|
|
857
|
-
src_file =
|
|
873
|
+
src_file = dirpath / filename
|
|
858
874
|
dst_file = dst_path / rel_dir / filename if rel_dir else dst_path / filename
|
|
859
875
|
# Handle symlinks
|
|
860
876
|
if not follow_symlinks and await src_file.a_is_symlink():
|
|
@@ -470,7 +470,7 @@ class LocalPath(_ConcretePath, PanPath): # type: ignore[valid-type, misc]
|
|
|
470
470
|
for item in await aiofiles.os.listdir(str(self)):
|
|
471
471
|
yield self / item
|
|
472
472
|
|
|
473
|
-
async def a_stat(self) -> os.stat_result:
|
|
473
|
+
async def a_stat(self, follow_symlinks: bool = True) -> os.stat_result:
|
|
474
474
|
"""Get file stats (async)."""
|
|
475
475
|
if not HAS_AIOFILES:
|
|
476
476
|
raise MissingDependencyError(
|
|
@@ -479,7 +479,10 @@ class LocalPath(_ConcretePath, PanPath): # type: ignore[valid-type, misc]
|
|
|
479
479
|
extra="all-async",
|
|
480
480
|
)
|
|
481
481
|
|
|
482
|
-
return await aiofiles.os.stat(
|
|
482
|
+
return await aiofiles.os.stat( # type: ignore[no-any-return]
|
|
483
|
+
str(self),
|
|
484
|
+
follow_symlinks=follow_symlinks,
|
|
485
|
+
)
|
|
483
486
|
|
|
484
487
|
def a_open( # type: ignore[override]
|
|
485
488
|
self,
|
|
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
|
|
|
4
4
|
|
|
5
5
|
[tool.poetry]
|
|
6
6
|
name = "panpath"
|
|
7
|
-
version = "0.4.
|
|
7
|
+
version = "0.4.5"
|
|
8
8
|
description = "Universal sync/async local/cloud path library with pathlib-compatible interface"
|
|
9
9
|
authors = ["panpath contributors"]
|
|
10
10
|
readme = "README.md"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|