daplapath 2.1.1__tar.gz → 2.1.3__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.1
2
2
  Name: daplapath
3
- Version: 2.1.1
3
+ Version: 2.1.3
4
4
  Summary: A pathlib.Path class for dapla
5
5
  License: MIT
6
6
  Author: ort
@@ -216,19 +216,13 @@ class Path(str, _PathBase):
216
216
  @staticmethod
217
217
  def _standardize_path(path: str | PurePosixPath) -> str:
218
218
  """Make sure delimiter is '/' and path ends without '/'."""
219
- return (
220
- str(path)
221
- .replace("\\", "/")
222
- .replace(r"\"", "/")
223
- .replace("//", "/")
224
- .rstrip("/")
225
- )
219
+ return str(path).replace("\\", "/").replace(r"\"", "/")
226
220
 
227
221
  def __new__(cls, gcs_path: str | PurePath | None = None, file_system=None):
228
222
  """Construct Path with '/' as delimiter."""
229
223
  gcs_path = cls._standardize_path(gcs_path or "")
230
224
  obj = super().__new__(cls, gcs_path)
231
- obj._path = pathlib.Path(obj)
225
+ obj._path = PurePosixPath(obj)
232
226
  obj._file_system = file_system
233
227
  return obj
234
228
 
@@ -729,7 +723,6 @@ class Path(str, _PathBase):
729
723
  """File size in terrabytes."""
730
724
  return self.kb / 1_000_000_000
731
725
 
732
- @property
733
726
  def partition_root(self) -> "Path":
734
727
  if not self.suffix or self.count(self.suffix) != 2:
735
728
  return self
@@ -997,15 +990,16 @@ class PathSeries(pd.Series, _PathBase):
997
990
  return self.files.apply(lambda x: x.buckets_path())
998
991
 
999
992
  def partition_root(self, keep: str | None = "last") -> "PathSeries":
1000
- return self.files.apply(lambda x: x.partition_root)[
993
+ return self.files.apply(lambda x: x.partition_root())[
1001
994
  lambda x: ~x.duplicated(keep=keep)
1002
995
  ]
1003
996
 
1004
- @property
1005
997
  def partitioned_files(self) -> "PathSeries":
1006
- return self.files.loc[
1007
- lambda x: x.str.count(r"\.parquet") == 2
1008
- ].partition_root.drop_duplicates()
998
+ return (
999
+ self.files.loc[lambda x: x.str.count(r"\.parquet") == 2]
1000
+ .partition_root()
1001
+ .drop_duplicates()
1002
+ )
1009
1003
 
1010
1004
  @property
1011
1005
  def dirs(self) -> "PathSeries":
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "daplapath"
3
- version = "2.1.1"
3
+ version = "2.1.3"
4
4
  description = "A pathlib.Path class for dapla"
5
5
  authors = ["ort <ort@ssb.no>"]
6
6
  license = "MIT"
File without changes
File without changes