panpath 0.4.4__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: panpath
3
- Version: 0.4.4
3
+ Version: 0.4.5
4
4
  Summary: Universal sync/async local/cloud path library with pathlib-compatible interface
5
5
  License: MIT
6
6
  License-File: LICENSE
@@ -56,7 +56,7 @@ except ImportError:
56
56
  # Azure dependencies not installed
57
57
  pass
58
58
 
59
- __version__ = "0.4.4"
59
+ __version__ = "0.4.5"
60
60
 
61
61
  __all__ = [
62
62
  "PanPath",
@@ -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(target) # type: ignore
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(target) # type: ignore
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,
@@ -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(str(self)) # type: ignore[no-any-return]
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.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