dycw-utilities 0.153.5__py3-none-any.whl → 0.153.6__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dycw-utilities
3
- Version: 0.153.5
3
+ Version: 0.153.6
4
4
  Author-email: Derek Wan <d.wan@icloud.com>
5
5
  License-File: LICENSE
6
6
  Requires-Python: >=3.12
@@ -1,4 +1,4 @@
1
- utilities/__init__.py,sha256=UKnoBPsvjUBIqzHxpYFxmj-sB445m7ZiCPW-H1lVF5k,60
1
+ utilities/__init__.py,sha256=gelDBvNPti9WhOMyN_KBRYuYlRRQPEiso1hUP-4cRqk,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
@@ -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=70BPcb_Na0LqDXJfqu0JwkHkGrwyuKpIVooSm6NlRn8,12467
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.5.dist-info/METADATA,sha256=fdVY9p8qoujQ4PkOgQ_lgFeSkK-HItBHJYsi-nd_4Bo,1696
91
- dycw_utilities-0.153.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
92
- dycw_utilities-0.153.5.dist-info/entry_points.txt,sha256=BOD_SoDxwsfJYOLxhrSXhHP_T7iw-HXI9f2WVkzYxvQ,135
93
- dycw_utilities-0.153.5.dist-info/licenses/LICENSE,sha256=gppZp16M6nSVpBbUBrNL6JuYfvKwZiKgV7XoKKsHzqo,1066
94
- dycw_utilities-0.153.5.dist-info/RECORD,,
90
+ dycw_utilities-0.153.6.dist-info/METADATA,sha256=AGj_Bwrc6MkIwihO_NZQdNmOwEWLp1tNiN5Voz2g3So,1696
91
+ dycw_utilities-0.153.6.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
92
+ dycw_utilities-0.153.6.dist-info/entry_points.txt,sha256=BOD_SoDxwsfJYOLxhrSXhHP_T7iw-HXI9f2WVkzYxvQ,135
93
+ dycw_utilities-0.153.6.dist-info/licenses/LICENSE,sha256=gppZp16M6nSVpBbUBrNL6JuYfvKwZiKgV7XoKKsHzqo,1066
94
+ dycw_utilities-0.153.6.dist-info/RECORD,,
utilities/__init__.py CHANGED
@@ -1,3 +1,3 @@
1
1
  from __future__ import annotations
2
2
 
3
- __version__ = "0.153.5"
3
+ __version__ = "0.153.6"
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
- ) -> None:
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
- else:
94
- match output.return_code:
95
- case 0:
96
- if logger is not None:
97
- to_logger(logger).info(
98
- "Backup to %r finished after %s", str(path), timer
99
- )
100
- case _:
101
- if logger is not None:
102
- to_logger(logger).exception(
103
- "Backup to %r failed after %s\nstderr:\n%s",
104
- str(path),
105
- timer,
106
- output.stderr,
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
- ) -> None:
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
- else:
250
- match output.return_code:
251
- case 0:
252
- if logger is not None:
253
- to_logger(logger).info(
254
- "Restore from %r finished after %s", str(path), timer
255
- )
256
- case _:
257
- if logger is not None:
258
- to_logger(logger).exception(
259
- "Restore from %r failed after %s\nstderr:\n%s",
260
- str(path),
261
- timer,
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
  ##