daplapath 2.0.10__py3-none-any.whl → 2.0.11__py3-none-any.whl
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.
- daplapath/path.py +34 -11
- {daplapath-2.0.10.dist-info → daplapath-2.0.11.dist-info}/METADATA +1 -1
- daplapath-2.0.11.dist-info/RECORD +6 -0
- daplapath-2.0.10.dist-info/RECORD +0 -6
- {daplapath-2.0.10.dist-info → daplapath-2.0.11.dist-info}/LICENSE.md +0 -0
- {daplapath-2.0.10.dist-info → daplapath-2.0.11.dist-info}/WHEEL +0 -0
daplapath/path.py
CHANGED
|
@@ -416,7 +416,9 @@ class Path(str, _PathBase):
|
|
|
416
416
|
if timeout:
|
|
417
417
|
timestamp: datetime.datetime = highest_numbered.timestamp
|
|
418
418
|
|
|
419
|
-
time_should_be_at_least = pd.Timestamp.now()
|
|
419
|
+
time_should_be_at_least = pd.Timestamp.now(tz="Europe/Oslo").replace(
|
|
420
|
+
tzinfo=None
|
|
421
|
+
).round("s") - pd.Timedelta(minutes=timeout)
|
|
420
422
|
if timestamp > time_should_be_at_least:
|
|
421
423
|
raise ValueError(
|
|
422
424
|
f"Latest version of the file was updated {timestamp[0]}, which "
|
|
@@ -506,6 +508,8 @@ class Path(str, _PathBase):
|
|
|
506
508
|
"""
|
|
507
509
|
if not isinstance(period, (str, int)):
|
|
508
510
|
raise TypeError(f"'period' should be string or int. Got {type(period)}")
|
|
511
|
+
if not self.period:
|
|
512
|
+
raise ValueError(f"Cannot set period to path without period. {self}")
|
|
509
513
|
if str(period) == self.period:
|
|
510
514
|
return self
|
|
511
515
|
return self.with_periods(period)
|
|
@@ -529,6 +533,8 @@ class Path(str, _PathBase):
|
|
|
529
533
|
raise TypeError(
|
|
530
534
|
f"'to_period' should be string or int. Got {type(to_period)}"
|
|
531
535
|
)
|
|
536
|
+
if not self.periods:
|
|
537
|
+
raise ValueError(f"Cannot set period to path without period. {self}")
|
|
532
538
|
|
|
533
539
|
periods: tuple[str] = (
|
|
534
540
|
(str(from_period), str(to_period)) if to_period else (str(from_period),)
|
|
@@ -719,14 +725,19 @@ class Path(str, _PathBase):
|
|
|
719
725
|
|
|
720
726
|
@property
|
|
721
727
|
def partition_root(self) -> "Path":
|
|
722
|
-
if
|
|
728
|
+
if not self.suffix or self.count(self.suffix) != 2:
|
|
723
729
|
return self
|
|
724
|
-
return self._new(self.split(
|
|
730
|
+
return self._new(self.split(self.suffix)[0] + self.suffix)
|
|
725
731
|
|
|
726
732
|
def is_partitioned(self) -> bool:
|
|
727
|
-
if
|
|
733
|
+
if (
|
|
734
|
+
not self.suffix
|
|
735
|
+
or self.suffix not in self
|
|
736
|
+
or self.isfile()
|
|
737
|
+
and self.count(self.suffix) != 2
|
|
738
|
+
):
|
|
728
739
|
return False
|
|
729
|
-
return bool(len(self.glob("
|
|
740
|
+
return bool(len(self.glob(f"**/*{self.suffix}")))
|
|
730
741
|
|
|
731
742
|
def isfile(self) -> bool:
|
|
732
743
|
return not self.isdir()
|
|
@@ -999,32 +1010,44 @@ class PathSeries(pd.Series, _PathBase):
|
|
|
999
1010
|
|
|
1000
1011
|
def within_minutes(self, minutes: int):
|
|
1001
1012
|
"""Select files with a timestamp within the given number of minutes."""
|
|
1002
|
-
time_then = pd.Timestamp.now()
|
|
1013
|
+
time_then = pd.Timestamp.now(tz="Europe/Oslo").replace(tzinfo=None).round(
|
|
1014
|
+
"s"
|
|
1015
|
+
) - pd.Timedelta(minutes=minutes)
|
|
1003
1016
|
return self.files[lambda x: x.timestamp > time_then]
|
|
1004
1017
|
|
|
1005
1018
|
def within_hours(self, hours: int):
|
|
1006
1019
|
"""Select files with a timestamp within the given number of hours."""
|
|
1007
|
-
time_then = pd.Timestamp.now()
|
|
1020
|
+
time_then = pd.Timestamp.now(tz="Europe/Oslo").replace(tzinfo=None).round(
|
|
1021
|
+
"s"
|
|
1022
|
+
) - pd.Timedelta(hours=hours)
|
|
1008
1023
|
return self.files[lambda x: x.timestamp > time_then]
|
|
1009
1024
|
|
|
1010
1025
|
def within_days(self, days: int):
|
|
1011
1026
|
"""Select files with a timestamp within the given number of days."""
|
|
1012
|
-
time_then = pd.Timestamp.now()
|
|
1027
|
+
time_then = pd.Timestamp.now(tz="Europe/Oslo").replace(tzinfo=None).round(
|
|
1028
|
+
"s"
|
|
1029
|
+
) - pd.Timedelta(days=days)
|
|
1013
1030
|
return self.files[lambda x: x.timestamp > time_then]
|
|
1014
1031
|
|
|
1015
1032
|
def not_within_minutes(self, minutes: int):
|
|
1016
1033
|
"""Select files with a timestamp within the given number of minutes."""
|
|
1017
|
-
time_then = pd.Timestamp.now()
|
|
1034
|
+
time_then = pd.Timestamp.now(tz="Europe/Oslo").replace(tzinfo=None).round(
|
|
1035
|
+
"s"
|
|
1036
|
+
) - pd.Timedelta(minutes=minutes)
|
|
1018
1037
|
return self.files[lambda x: x.timestamp < time_then]
|
|
1019
1038
|
|
|
1020
1039
|
def not_within_hours(self, hours: int):
|
|
1021
1040
|
"""Select files with a timestamp within the given number of hours."""
|
|
1022
|
-
time_then = pd.Timestamp.now()
|
|
1041
|
+
time_then = pd.Timestamp.now(tz="Europe/Oslo").replace(tzinfo=None).round(
|
|
1042
|
+
"s"
|
|
1043
|
+
) - pd.Timedelta(hours=hours)
|
|
1023
1044
|
return self.files[lambda x: x.timestamp < time_then]
|
|
1024
1045
|
|
|
1025
1046
|
def not_within_days(self, days: int):
|
|
1026
1047
|
"""Select files with a timestamp within the given number of days."""
|
|
1027
|
-
time_then = pd.Timestamp.now()
|
|
1048
|
+
time_then = pd.Timestamp.now(tz="Europe/Oslo").replace(tzinfo=None).round(
|
|
1049
|
+
"s"
|
|
1050
|
+
) - pd.Timedelta(days=days)
|
|
1028
1051
|
return self.files[lambda x: x.timestamp < time_then]
|
|
1029
1052
|
|
|
1030
1053
|
@property
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
daplapath/__init__.py,sha256=Qdpwhl8y3-i_42-4-KVT-sPQtJqwWRENLFxROZ_rfbU,86
|
|
2
|
+
daplapath/path.py,sha256=kGfYhBgA0eZLq26wWpM7XUbh1-xsN-KdamXsevXwbu8,56058
|
|
3
|
+
daplapath-2.0.11.dist-info/LICENSE.md,sha256=hxspefYgWP3U6OZFhCifqWMI5ksnKzgFxNKgQnG7Ozc,1074
|
|
4
|
+
daplapath-2.0.11.dist-info/METADATA,sha256=NRXrbquGmzccuj6XsFbvPZfyJZrt-ANfG-BsjO8Mb7U,14698
|
|
5
|
+
daplapath-2.0.11.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
6
|
+
daplapath-2.0.11.dist-info/RECORD,,
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
daplapath/__init__.py,sha256=Qdpwhl8y3-i_42-4-KVT-sPQtJqwWRENLFxROZ_rfbU,86
|
|
2
|
-
daplapath/path.py,sha256=2E09TCBAuxFNwfEmS-Utip9e1YXup4wFOSon4VAAGfs,55225
|
|
3
|
-
daplapath-2.0.10.dist-info/LICENSE.md,sha256=hxspefYgWP3U6OZFhCifqWMI5ksnKzgFxNKgQnG7Ozc,1074
|
|
4
|
-
daplapath-2.0.10.dist-info/METADATA,sha256=D20P6jlzE4vGpCnzaILe0pU8fpul8si7r2eEWiIE1tw,14698
|
|
5
|
-
daplapath-2.0.10.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
6
|
-
daplapath-2.0.10.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|