panpath 0.4.0__tar.gz → 0.4.1__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.0 → panpath-0.4.1}/PKG-INFO +1 -1
- {panpath-0.4.0 → panpath-0.4.1}/panpath/__init__.py +1 -1
- {panpath-0.4.0 → panpath-0.4.1}/panpath/base.py +6 -2
- {panpath-0.4.0 → panpath-0.4.1}/panpath/gs_client.py +13 -13
- {panpath-0.4.0 → panpath-0.4.1}/panpath/s3_client.py +11 -17
- {panpath-0.4.0 → panpath-0.4.1}/pyproject.toml +1 -1
- {panpath-0.4.0 → panpath-0.4.1}/LICENSE +0 -0
- {panpath-0.4.0 → panpath-0.4.1}/README.md +0 -0
- {panpath-0.4.0 → panpath-0.4.1}/panpath/azure_async_client.py +0 -0
- {panpath-0.4.0 → panpath-0.4.1}/panpath/azure_client.py +0 -0
- {panpath-0.4.0 → panpath-0.4.1}/panpath/azure_path.py +0 -0
- {panpath-0.4.0 → panpath-0.4.1}/panpath/clients.py +0 -0
- {panpath-0.4.0 → panpath-0.4.1}/panpath/cloud.py +0 -0
- {panpath-0.4.0 → panpath-0.4.1}/panpath/exceptions.py +0 -0
- {panpath-0.4.0 → panpath-0.4.1}/panpath/gs_async_client.py +0 -0
- {panpath-0.4.0 → panpath-0.4.1}/panpath/gs_path.py +0 -0
- {panpath-0.4.0 → panpath-0.4.1}/panpath/local_path.py +0 -0
- {panpath-0.4.0 → panpath-0.4.1}/panpath/py.typed +0 -0
- {panpath-0.4.0 → panpath-0.4.1}/panpath/registry.py +0 -0
- {panpath-0.4.0 → panpath-0.4.1}/panpath/s3_async_client.py +0 -0
- {panpath-0.4.0 → panpath-0.4.1}/panpath/s3_path.py +0 -0
|
@@ -194,8 +194,12 @@ class PanPath(PathlibPath):
|
|
|
194
194
|
"""
|
|
195
195
|
|
|
196
196
|
@abstractmethod
|
|
197
|
-
async def a_unlink(self) -> None:
|
|
198
|
-
"""Asynchronously remove (delete) the file or empty directory.
|
|
197
|
+
async def a_unlink(self, missing_ok: bool = False) -> None:
|
|
198
|
+
"""Asynchronously remove (delete) the file or empty directory.
|
|
199
|
+
|
|
200
|
+
Args:
|
|
201
|
+
missing_ok: If True, does not raise an error if the file does not exist.
|
|
202
|
+
"""
|
|
199
203
|
|
|
200
204
|
@abstractmethod
|
|
201
205
|
async def a_iterdir(self) -> AsyncGenerator["PanPath", None]:
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import warnings
|
|
4
4
|
import os
|
|
5
5
|
import sys
|
|
6
|
-
from typing import TYPE_CHECKING, Any, Optional, Union
|
|
6
|
+
from typing import TYPE_CHECKING, Any, Optional, Union, Iterator
|
|
7
7
|
|
|
8
8
|
from panpath.clients import SyncClient, SyncFileHandle
|
|
9
9
|
from panpath.exceptions import MissingDependencyError, NoStatError
|
|
@@ -11,6 +11,7 @@ from panpath.exceptions import MissingDependencyError, NoStatError
|
|
|
11
11
|
if TYPE_CHECKING:
|
|
12
12
|
from google.cloud import storage # type: ignore[import-untyped, unused-ignore]
|
|
13
13
|
from google.api_core.exceptions import NotFound
|
|
14
|
+
from panpath.base import PanPath
|
|
14
15
|
|
|
15
16
|
try:
|
|
16
17
|
with warnings.catch_warnings():
|
|
@@ -317,7 +318,7 @@ class GSClient(SyncClient):
|
|
|
317
318
|
path: str,
|
|
318
319
|
pattern: str,
|
|
319
320
|
_return_panpath: bool = False,
|
|
320
|
-
) ->
|
|
321
|
+
) -> Iterator[Union[str, "PanPath"]]:
|
|
321
322
|
"""Glob for files matching pattern.
|
|
322
323
|
|
|
323
324
|
Args:
|
|
@@ -347,15 +348,13 @@ class GSClient(SyncClient):
|
|
|
347
348
|
else:
|
|
348
349
|
file_pattern = "*"
|
|
349
350
|
|
|
350
|
-
results = []
|
|
351
351
|
for blob in blobs:
|
|
352
352
|
if fnmatch(blob.name, f"*{file_pattern}"):
|
|
353
353
|
path_str = f"{self.prefix[0]}://{bucket_name}/{blob.name}"
|
|
354
354
|
if _return_panpath:
|
|
355
|
-
|
|
355
|
+
yield PanPath(path_str)
|
|
356
356
|
else: # pragma: no cover
|
|
357
|
-
|
|
358
|
-
return results
|
|
357
|
+
yield path_str
|
|
359
358
|
else:
|
|
360
359
|
# Non-recursive - list blobs with delimiter
|
|
361
360
|
prefix = (
|
|
@@ -363,17 +362,18 @@ class GSClient(SyncClient):
|
|
|
363
362
|
)
|
|
364
363
|
blobs = bucket.list_blobs(prefix=prefix, delimiter="/")
|
|
365
364
|
|
|
366
|
-
results = []
|
|
367
365
|
for blob in blobs:
|
|
368
366
|
if fnmatch(blob.name, f"{prefix}{pattern}"):
|
|
369
367
|
path_str = f"{self.prefix[0]}://{bucket_name}/{blob.name}"
|
|
370
368
|
if _return_panpath:
|
|
371
|
-
|
|
369
|
+
yield PanPath(path_str)
|
|
372
370
|
else: # pragma: no cover
|
|
373
|
-
|
|
374
|
-
return results
|
|
371
|
+
yield path_str
|
|
375
372
|
|
|
376
|
-
def walk(
|
|
373
|
+
def walk( # type: ignore[override]
|
|
374
|
+
self,
|
|
375
|
+
path: str,
|
|
376
|
+
) -> Iterator[tuple[str, list[str], list[str]]]:
|
|
377
377
|
"""Walk directory tree.
|
|
378
378
|
|
|
379
379
|
Args:
|
|
@@ -425,8 +425,8 @@ class GSClient(SyncClient):
|
|
|
425
425
|
dirs[parent_dir] = (set(), set())
|
|
426
426
|
dirs[parent_dir][1].add(parts[-1])
|
|
427
427
|
|
|
428
|
-
|
|
429
|
-
|
|
428
|
+
for d, (subdirs, files) in dirs.items():
|
|
429
|
+
yield d, sorted(subdirs), sorted(files)
|
|
430
430
|
|
|
431
431
|
def touch(self, path: str, exist_ok: bool = True) -> None:
|
|
432
432
|
"""Create empty file.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import os
|
|
4
4
|
import re
|
|
5
|
-
from typing import TYPE_CHECKING, Any, Optional, Union
|
|
5
|
+
from typing import TYPE_CHECKING, Any, Iterator, Optional, Union
|
|
6
6
|
|
|
7
7
|
from panpath.clients import SyncClient, SyncFileHandle
|
|
8
8
|
from panpath.exceptions import MissingDependencyError
|
|
@@ -10,6 +10,7 @@ from panpath.exceptions import MissingDependencyError
|
|
|
10
10
|
if TYPE_CHECKING:
|
|
11
11
|
import boto3 # type: ignore[import-untyped]
|
|
12
12
|
from botocore.exceptions import ClientError # type: ignore[import-untyped]
|
|
13
|
+
from panpath.base import PanPath
|
|
13
14
|
|
|
14
15
|
try:
|
|
15
16
|
import boto3
|
|
@@ -336,7 +337,7 @@ class S3Client(SyncClient):
|
|
|
336
337
|
|
|
337
338
|
def glob( # type: ignore[override]
|
|
338
339
|
self, path: str, pattern: str, _return_panpath: bool = False
|
|
339
|
-
) ->
|
|
340
|
+
) -> Iterator[Union[str, "PanPath"]]:
|
|
340
341
|
"""Glob for files matching pattern.
|
|
341
342
|
|
|
342
343
|
Args:
|
|
@@ -348,6 +349,7 @@ class S3Client(SyncClient):
|
|
|
348
349
|
List of matching paths (as PanPath objects or strings)
|
|
349
350
|
"""
|
|
350
351
|
from fnmatch import fnmatch
|
|
352
|
+
from panpath.base import PanPath
|
|
351
353
|
|
|
352
354
|
bucket, prefix = self.__class__._parse_path(path)
|
|
353
355
|
|
|
@@ -364,19 +366,15 @@ class S3Client(SyncClient):
|
|
|
364
366
|
else:
|
|
365
367
|
file_pattern = "*"
|
|
366
368
|
|
|
367
|
-
results = []
|
|
368
369
|
for page in pages:
|
|
369
370
|
for obj in page.get("Contents", []):
|
|
370
371
|
key = obj["Key"]
|
|
371
372
|
if fnmatch(key, f"*{file_pattern}"):
|
|
372
373
|
path_str = f"{self.prefix[0]}://{bucket}/{key}"
|
|
373
374
|
if _return_panpath:
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
results.append(PanPath(path_str))
|
|
375
|
+
yield PanPath(path_str)
|
|
377
376
|
else: # pragma: no cover
|
|
378
|
-
|
|
379
|
-
return results
|
|
377
|
+
yield path_str
|
|
380
378
|
else:
|
|
381
379
|
# Non-recursive - list objects with delimiter
|
|
382
380
|
prefix_with_slash = f"{prefix}/" if prefix and not prefix.endswith("/") else prefix
|
|
@@ -384,22 +382,18 @@ class S3Client(SyncClient):
|
|
|
384
382
|
Bucket=bucket, Prefix=prefix_with_slash, Delimiter="/"
|
|
385
383
|
)
|
|
386
384
|
|
|
387
|
-
results = []
|
|
388
385
|
for obj in response.get("Contents", []):
|
|
389
386
|
key = obj["Key"]
|
|
390
387
|
if fnmatch(key, f"{prefix_with_slash}{pattern}"):
|
|
391
388
|
path_str = f"{self.prefix[0]}://{bucket}/{key}"
|
|
392
389
|
if _return_panpath:
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
results.append(PanPath(path_str))
|
|
390
|
+
yield PanPath(path_str)
|
|
396
391
|
else: # pragma: no cover
|
|
397
|
-
|
|
398
|
-
return results
|
|
392
|
+
yield path_str
|
|
399
393
|
|
|
400
394
|
def walk( # type: ignore[override]
|
|
401
395
|
self, path: str
|
|
402
|
-
) ->
|
|
396
|
+
) -> Iterator[tuple[str, list[str], list[str]]]:
|
|
403
397
|
"""Walk directory tree.
|
|
404
398
|
|
|
405
399
|
Args:
|
|
@@ -462,8 +456,8 @@ class S3Client(SyncClient):
|
|
|
462
456
|
if parts[-1]: # Skip empty strings
|
|
463
457
|
dirs[parent_dir][1].add(parts[-1])
|
|
464
458
|
|
|
465
|
-
|
|
466
|
-
|
|
459
|
+
for d, (subdirs, files) in dirs.items():
|
|
460
|
+
yield d, sorted(subdirs), sorted(files)
|
|
467
461
|
|
|
468
462
|
def touch(self, path: str, exist_ok: bool = True) -> None:
|
|
469
463
|
"""Create empty file.
|
|
@@ -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.1"
|
|
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
|
|
File without changes
|