dycw-utilities 0.138.9__py3-none-any.whl → 0.138.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.
- {dycw_utilities-0.138.9.dist-info → dycw_utilities-0.138.11.dist-info}/METADATA +2 -2
- {dycw_utilities-0.138.9.dist-info → dycw_utilities-0.138.11.dist-info}/RECORD +7 -7
- utilities/__init__.py +1 -1
- utilities/whenever.py +38 -3
- {dycw_utilities-0.138.9.dist-info → dycw_utilities-0.138.11.dist-info}/WHEEL +0 -0
- {dycw_utilities-0.138.9.dist-info → dycw_utilities-0.138.11.dist-info}/entry_points.txt +0 -0
- {dycw_utilities-0.138.9.dist-info → dycw_utilities-0.138.11.dist-info}/licenses/LICENSE +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: dycw-utilities
|
3
|
-
Version: 0.138.
|
3
|
+
Version: 0.138.11
|
4
4
|
Author-email: Derek Wan <d.wan@icloud.com>
|
5
5
|
License-File: LICENSE
|
6
6
|
Requires-Python: >=3.12
|
@@ -12,7 +12,7 @@ Provides-Extra: logging
|
|
12
12
|
Requires-Dist: coloredlogs<15.1,>=15.0.1; extra == 'logging'
|
13
13
|
Provides-Extra: test
|
14
14
|
Requires-Dist: dycw-pytest-only<2.2,>=2.1.1; extra == 'test'
|
15
|
-
Requires-Dist: hypothesis<6.136,>=6.135.
|
15
|
+
Requires-Dist: hypothesis<6.136,>=6.135.15; extra == 'test'
|
16
16
|
Requires-Dist: pudb<2025.2,>=2025.1; extra == 'test'
|
17
17
|
Requires-Dist: pytest-asyncio<1.1,>=1.0.0; extra == 'test'
|
18
18
|
Requires-Dist: pytest-cov<6.2,>=6.1.1; extra == 'test'
|
@@ -1,4 +1,4 @@
|
|
1
|
-
utilities/__init__.py,sha256=
|
1
|
+
utilities/__init__.py,sha256=9DDGgjkFp3Cdp4zOiMFXaf33e9pvjf8ShhgobV8p2Bk,61
|
2
2
|
utilities/aiolimiter.py,sha256=mD0wEiqMgwpty4XTbawFpnkkmJS6R4JRsVXFUaoitSU,628
|
3
3
|
utilities/altair.py,sha256=HeZBVUocjkrTNwwKrClppsIqgNFF-ykv05HfZSoHYno,9104
|
4
4
|
utilities/asyncio.py,sha256=dcGeKQzjLBXxKzZkVIk5oZsFXEcynVbRB9iNB5XEDZk,38526
|
@@ -85,11 +85,11 @@ utilities/tzlocal.py,sha256=KyCXEgCTjqGFx-389JdTuhMRUaT06U1RCMdWoED-qro,728
|
|
85
85
|
utilities/uuid.py,sha256=32p7DGHGM2Btx6PcBvCZvERSWbpupMXqx6FppPoSoTU,612
|
86
86
|
utilities/version.py,sha256=ufhJMmI6KPs1-3wBI71aj5wCukd3sP_m11usLe88DNA,5117
|
87
87
|
utilities/warnings.py,sha256=un1LvHv70PU-LLv8RxPVmugTzDJkkGXRMZTE2-fTQHw,1771
|
88
|
-
utilities/whenever.py,sha256=
|
88
|
+
utilities/whenever.py,sha256=sUAOQ2sJTRGC1kacGTnMbfQdkypuSiqhTZWZVo21OT8,21545
|
89
89
|
utilities/zipfile.py,sha256=24lQc9ATcJxHXBPc_tBDiJk48pWyRrlxO2fIsFxU0A8,699
|
90
90
|
utilities/zoneinfo.py,sha256=oEH-nL3t4h9uawyZqWDtNtDAl6M-CLpLYGI_nI6DulM,1971
|
91
|
-
dycw_utilities-0.138.
|
92
|
-
dycw_utilities-0.138.
|
93
|
-
dycw_utilities-0.138.
|
94
|
-
dycw_utilities-0.138.
|
95
|
-
dycw_utilities-0.138.
|
91
|
+
dycw_utilities-0.138.11.dist-info/METADATA,sha256=NXtP-npkCEdbiEx08y3ODmOG-iu7H52TpybdMScFZJM,1639
|
92
|
+
dycw_utilities-0.138.11.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
93
|
+
dycw_utilities-0.138.11.dist-info/entry_points.txt,sha256=uLj5QWWVXv8tnMaRX3ZGYpt7w1xzLWU6LxbFhELEpkc,68
|
94
|
+
dycw_utilities-0.138.11.dist-info/licenses/LICENSE,sha256=gppZp16M6nSVpBbUBrNL6JuYfvKwZiKgV7XoKKsHzqo,1066
|
95
|
+
dycw_utilities-0.138.11.dist-info/RECORD,,
|
utilities/__init__.py
CHANGED
utilities/whenever.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
|
3
|
+
import datetime as dt
|
3
4
|
from collections.abc import Callable, Iterable, Mapping
|
4
5
|
from dataclasses import dataclass
|
5
6
|
from functools import cache
|
@@ -553,9 +554,10 @@ def to_local_plain(date_time: ZonedDateTime, /) -> PlainDateTime:
|
|
553
554
|
|
554
555
|
def to_nanos(delta: DateTimeDelta, /) -> int:
|
555
556
|
"""Compute the number of nanoseconds in a date-time delta."""
|
556
|
-
|
557
|
-
|
558
|
-
|
557
|
+
try:
|
558
|
+
days = to_days(delta.date_part())
|
559
|
+
except ToDaysError as error:
|
560
|
+
raise ToNanosError(months=error.months) from None
|
559
561
|
return 24 * 60 * 60 * int(1e9) * days + delta.time_part().in_nanoseconds()
|
560
562
|
|
561
563
|
|
@@ -571,6 +573,37 @@ class ToNanosError(Exception):
|
|
571
573
|
##
|
572
574
|
|
573
575
|
|
576
|
+
def to_py_time_delta(delta: DateDelta | TimeDelta | DateTimeDelta, /) -> dt.timedelta:
|
577
|
+
"""Try convert a DateDelta to a standard library timedelta."""
|
578
|
+
match delta:
|
579
|
+
case DateDelta():
|
580
|
+
return dt.timedelta(days=to_days(delta))
|
581
|
+
case TimeDelta():
|
582
|
+
nanos = delta.in_nanoseconds()
|
583
|
+
micros, remainder = divmod(nanos, 1000)
|
584
|
+
if remainder != 0:
|
585
|
+
raise ToPyTimeDeltaError(nanoseconds=remainder)
|
586
|
+
return dt.timedelta(microseconds=micros)
|
587
|
+
case DateTimeDelta():
|
588
|
+
return to_py_time_delta(delta.date_part()) + to_py_time_delta(
|
589
|
+
delta.time_part()
|
590
|
+
)
|
591
|
+
case _ as never:
|
592
|
+
assert_never(never)
|
593
|
+
|
594
|
+
|
595
|
+
@dataclass(kw_only=True, slots=True)
|
596
|
+
class ToPyTimeDeltaError(Exception):
|
597
|
+
nanoseconds: int
|
598
|
+
|
599
|
+
@override
|
600
|
+
def __str__(self) -> str:
|
601
|
+
return f"Time delta must not contain nanoseconds; got {self.nanoseconds}"
|
602
|
+
|
603
|
+
|
604
|
+
##
|
605
|
+
|
606
|
+
|
574
607
|
def to_time_delta(nanos: int, /) -> TimeDelta:
|
575
608
|
"""Construct a time delta."""
|
576
609
|
components = _to_time_delta_components(nanos)
|
@@ -769,6 +802,7 @@ __all__ = [
|
|
769
802
|
"MinMaxDateError",
|
770
803
|
"ToDaysError",
|
771
804
|
"ToNanosError",
|
805
|
+
"ToPyTimeDeltaError",
|
772
806
|
"WheneverLogRecord",
|
773
807
|
"datetime_utc",
|
774
808
|
"format_compact",
|
@@ -786,6 +820,7 @@ __all__ = [
|
|
786
820
|
"to_days",
|
787
821
|
"to_local_plain",
|
788
822
|
"to_nanos",
|
823
|
+
"to_py_time_delta",
|
789
824
|
"to_zoned_date_time",
|
790
825
|
"two_digit_year_month",
|
791
826
|
]
|
File without changes
|
File without changes
|
File without changes
|