dycw-utilities 0.153.5__py3-none-any.whl → 0.153.7__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.153.5.dist-info → dycw_utilities-0.153.7.dist-info}/METADATA +1 -1
- {dycw_utilities-0.153.5.dist-info → dycw_utilities-0.153.7.dist-info}/RECORD +8 -8
- utilities/__init__.py +1 -1
- utilities/functions.py +16 -0
- utilities/postgres.py +31 -35
- {dycw_utilities-0.153.5.dist-info → dycw_utilities-0.153.7.dist-info}/WHEEL +0 -0
- {dycw_utilities-0.153.5.dist-info → dycw_utilities-0.153.7.dist-info}/entry_points.txt +0 -0
- {dycw_utilities-0.153.5.dist-info → dycw_utilities-0.153.7.dist-info}/licenses/LICENSE +0 -0
@@ -1,4 +1,4 @@
|
|
1
|
-
utilities/__init__.py,sha256=
|
1
|
+
utilities/__init__.py,sha256=9aK37ZvGGPt34vOfZ9frrf2lxPzuQCzBgDOTjJ48qjo,60
|
2
2
|
utilities/altair.py,sha256=92E2lCdyHY4Zb-vCw6rEJIsWdKipuu-Tu2ab1ufUfAk,9079
|
3
3
|
utilities/asyncio.py,sha256=QXkTtugXkqtYt7Do23zgYErqzdp6jwzPpV_SP9fJ1gI,16780
|
4
4
|
utilities/atomicwrites.py,sha256=tPo6r-Rypd9u99u66B9z86YBPpnLrlHtwox_8Z7T34Y,5790
|
@@ -16,7 +16,7 @@ utilities/errors.py,sha256=mFlDGSM0LI1jZ1pbqwLAH3ttLZ2JVIxyZLojw8tGVZU,1479
|
|
16
16
|
utilities/eventkit.py,sha256=ddoleSwW9zdc2tjX5Ge0pMKtYwV_JMxhHYOxnWX2AGM,12609
|
17
17
|
utilities/fastapi.py,sha256=3wpd63Tw9paSyy7STpAD7GGe8fLkLaRC6TPCwIGm1BU,1361
|
18
18
|
utilities/fpdf2.py,sha256=776PkEX5xEK-whFOzqaVaQVHPy1Xf01kCSyj7TEp80g,1886
|
19
|
-
utilities/functions.py,sha256=
|
19
|
+
utilities/functions.py,sha256=0mmeZ8op3QkAooYRAyRZhpi3TgaJCiMnqbJtZl-myug,28266
|
20
20
|
utilities/functools.py,sha256=I00ru2gQPakZw2SHVeKIKXfTv741655s6HI0lUoE0D4,1552
|
21
21
|
utilities/getpass.py,sha256=DfN5UgMAtFCqS3dSfFHUfqIMZX2shXvwphOz_6J6f6A,103
|
22
22
|
utilities/gzip.py,sha256=fkGP3KdsBfXlstodT4wtlp-PwNyUsogpbDCVVVGdsm4,781
|
@@ -47,7 +47,7 @@ utilities/pickle.py,sha256=MBT2xZCsv0pH868IXLGKnlcqNx2IRVKYNpRcqiQQqxw,653
|
|
47
47
|
utilities/platform.py,sha256=pTn7gw6N4T6LdKrf0virwarof_mze9WtoQlrGMzhGVI,2798
|
48
48
|
utilities/polars.py,sha256=jNUs038dJMZ0-r3rmHFClIzHlx3naA9klgYBvRDJi9w,77738
|
49
49
|
utilities/polars_ols.py,sha256=Uc9V5kvlWZ5cU93lKZ-cfAKdVFFw81tqwLW9PxtUvMs,5618
|
50
|
-
utilities/postgres.py,sha256=
|
50
|
+
utilities/postgres.py,sha256=ynCTTaF-bVEOSW-KEAR-dlLh_hYjeVVjm__-4pEU8Zk,12269
|
51
51
|
utilities/pottery.py,sha256=HJ96oLRarTP37Vhg0WTyB3yAu2hETeg6HgRmpDIqyUs,6581
|
52
52
|
utilities/pqdm.py,sha256=z8bSMS7QJmWun65FQZruAqT-R3wqPAzNzhWcX9Nvr0A,3087
|
53
53
|
utilities/psutil.py,sha256=KUlu4lrUw9Zg1V7ZGetpWpGb9DB8l_SSDWGbANFNCPU,2104
|
@@ -87,8 +87,8 @@ utilities/zoneinfo.py,sha256=FBMcUQ4662Aq8SsuCL1OAhDQiyANmVjtb-C30DRrWoE,1966
|
|
87
87
|
utilities/pytest_plugins/__init__.py,sha256=U4S_2y3zgLZVfMenHRaJFBW8yqh2mUBuI291LGQVOJ8,35
|
88
88
|
utilities/pytest_plugins/pytest_randomly.py,sha256=B1qYVlExGOxTywq2r1SMi5o7btHLk2PNdY_b1p98dkE,409
|
89
89
|
utilities/pytest_plugins/pytest_regressions.py,sha256=9v8kAXDM2ycIXJBimoiF4EgrwbUvxTycFWJiGR_GHhM,1466
|
90
|
-
dycw_utilities-0.153.
|
91
|
-
dycw_utilities-0.153.
|
92
|
-
dycw_utilities-0.153.
|
93
|
-
dycw_utilities-0.153.
|
94
|
-
dycw_utilities-0.153.
|
90
|
+
dycw_utilities-0.153.7.dist-info/METADATA,sha256=Fpe8vz0U4b-uAwUz5yo8RsIfTtVfWjVEiS5l3SG1aU8,1696
|
91
|
+
dycw_utilities-0.153.7.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
92
|
+
dycw_utilities-0.153.7.dist-info/entry_points.txt,sha256=BOD_SoDxwsfJYOLxhrSXhHP_T7iw-HXI9f2WVkzYxvQ,135
|
93
|
+
dycw_utilities-0.153.7.dist-info/licenses/LICENSE,sha256=gppZp16M6nSVpBbUBrNL6JuYfvKwZiKgV7XoKKsHzqo,1066
|
94
|
+
dycw_utilities-0.153.7.dist-info/RECORD,,
|
utilities/__init__.py
CHANGED
utilities/functions.py
CHANGED
@@ -935,6 +935,21 @@ def second[U](pair: tuple[Any, U], /) -> U:
|
|
935
935
|
##
|
936
936
|
|
937
937
|
|
938
|
+
def skip_if_optimize[**P](func: Callable[P, None], /) -> Callable[P, None]:
|
939
|
+
"""Skip a function if we are in the optimized mode."""
|
940
|
+
if __debug__:
|
941
|
+
return func
|
942
|
+
|
943
|
+
@wraps(func)
|
944
|
+
def wrapped(*args: P.args, **kwargs: P.kwargs) -> None:
|
945
|
+
_ = (args, kwargs)
|
946
|
+
|
947
|
+
return wrapped
|
948
|
+
|
949
|
+
|
950
|
+
##
|
951
|
+
|
952
|
+
|
938
953
|
def yield_object_attributes(
|
939
954
|
obj: Any,
|
940
955
|
/,
|
@@ -1043,6 +1058,7 @@ __all__ = [
|
|
1043
1058
|
"min_nullable",
|
1044
1059
|
"not_func",
|
1045
1060
|
"second",
|
1061
|
+
"skip_if_optimize",
|
1046
1062
|
"yield_object_attributes",
|
1047
1063
|
"yield_object_cached_properties",
|
1048
1064
|
"yield_object_properties",
|
utilities/postgres.py
CHANGED
@@ -54,7 +54,7 @@ async def pg_dump(
|
|
54
54
|
docker: str | None = None,
|
55
55
|
dry_run: bool = False,
|
56
56
|
logger: LoggerLike | None = None,
|
57
|
-
) ->
|
57
|
+
) -> bool:
|
58
58
|
"""Run `pg_dump`."""
|
59
59
|
path = _path_pg_dump(path, format_=format_)
|
60
60
|
path.parent.mkdir(parents=True, exist_ok=True)
|
@@ -80,7 +80,7 @@ async def pg_dump(
|
|
80
80
|
if dry_run:
|
81
81
|
if logger is not None:
|
82
82
|
to_logger(logger).info("Would run:\n\t%r", str(cmd))
|
83
|
-
return
|
83
|
+
return True
|
84
84
|
with temp_environ(PGPASSWORD=url.password), Timer() as timer: # pragma: no cover
|
85
85
|
try:
|
86
86
|
output = await stream_command(cmd)
|
@@ -90,22 +90,20 @@ async def pg_dump(
|
|
90
90
|
"Cancelled backup to %r after %s", str(path), timer
|
91
91
|
)
|
92
92
|
rmtree(path, ignore_errors=True)
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
)
|
108
|
-
rmtree(path, ignore_errors=True)
|
93
|
+
return False
|
94
|
+
if output.return_code != 0:
|
95
|
+
if logger is not None:
|
96
|
+
to_logger(logger).exception(
|
97
|
+
"Backup to %r failed after %s\nstderr:\n%s",
|
98
|
+
str(path),
|
99
|
+
timer,
|
100
|
+
output.stderr,
|
101
|
+
)
|
102
|
+
rmtree(path, ignore_errors=True)
|
103
|
+
return False
|
104
|
+
if logger is not None: # pragma: no cover
|
105
|
+
to_logger(logger).info("Backup to %r finished after %s", str(path), timer)
|
106
|
+
return True # pragma: no cover
|
109
107
|
|
110
108
|
|
111
109
|
def _build_pg_dump(
|
@@ -218,7 +216,7 @@ async def restore(
|
|
218
216
|
docker: str | None = None,
|
219
217
|
dry_run: bool = False,
|
220
218
|
logger: LoggerLike | None = None,
|
221
|
-
) ->
|
219
|
+
) -> bool:
|
222
220
|
"""Run `pg_restore`/`psql`."""
|
223
221
|
cmd = _build_pg_restore_or_psql(
|
224
222
|
url,
|
@@ -237,7 +235,7 @@ async def restore(
|
|
237
235
|
if dry_run:
|
238
236
|
if logger is not None:
|
239
237
|
to_logger(logger).info("Would run:\n\t%r", str(cmd))
|
240
|
-
return
|
238
|
+
return True
|
241
239
|
with temp_environ(PGPASSWORD=url.password), Timer() as timer: # pragma: no cover
|
242
240
|
try:
|
243
241
|
output = await stream_command(cmd)
|
@@ -246,21 +244,19 @@ async def restore(
|
|
246
244
|
to_logger(logger).info(
|
247
245
|
"Cancelled restore from %r after %s", str(path), timer
|
248
246
|
)
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
output.stderr,
|
263
|
-
)
|
247
|
+
return False
|
248
|
+
if output.return_code != 0:
|
249
|
+
if logger is not None:
|
250
|
+
to_logger(logger).exception(
|
251
|
+
"Restore from %r failed after %s\nstderr:\n%s",
|
252
|
+
str(path),
|
253
|
+
timer,
|
254
|
+
output.stderr,
|
255
|
+
)
|
256
|
+
return False
|
257
|
+
if logger is not None: # pragma: no cover
|
258
|
+
to_logger(logger).info("Restore from %r finished after %s", str(path), timer)
|
259
|
+
return True # pragma: no cover
|
264
260
|
|
265
261
|
|
266
262
|
##
|
File without changes
|
File without changes
|
File without changes
|