dycw-utilities 0.174.19__py3-none-any.whl → 0.174.20__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.3
2
2
  Name: dycw-utilities
3
- Version: 0.174.19
3
+ Version: 0.174.20
4
4
  Author: Derek Wan
5
5
  Author-email: Derek Wan <d.wan@icloud.com>
6
6
  Requires-Dist: atomicwrites>=1.4.1,<1.5
@@ -1,4 +1,4 @@
1
- utilities/__init__.py,sha256=nyJKpGIkfnetD4-kNA4ZJixn2uq8SdQrflZtDYf_k2Q,61
1
+ utilities/__init__.py,sha256=SXnJCLALsdKuftonx3Xk6nl9lsUbY1lII9DJii26lms,61
2
2
  utilities/aeventkit.py,sha256=OmDBhYGgbsKrB7cdC5FFpJHUatX9O76eTeKVVTksp2Y,12673
3
3
  utilities/altair.py,sha256=rUK99g9x6CYDDfiZrf-aTx5fSRbL1Q8ctgKORowzXHg,9060
4
4
  utilities/asyncio.py,sha256=aJySVxBY0gqsIYnoNmH7-1r8djKuf4vSsU69VCD08t8,16772
@@ -81,7 +81,7 @@ utilities/sqlalchemy.py,sha256=HQYpd7LFxdTF5WYVWYtCJeEBI71EJm7ytvCGyAH9B-U,37163
81
81
  utilities/sqlalchemy_polars.py,sha256=JCGhB37raSR7fqeWV5dTsciRTMVzIdVT9YSqKT0piT0,13370
82
82
  utilities/statsmodels.py,sha256=koyiBHvpMcSiBfh99wFUfSggLNx7cuAw3rwyfAhoKpQ,3410
83
83
  utilities/string.py,sha256=shmBK87zZwzGyixuNuXCiUbqzfeZ9xlrFwz6JTaRvDk,582
84
- utilities/subprocess.py,sha256=7GEv6T9F7z9nacPymzOUUAF6r6ChPjGgKlL64Zrh-AU,34909
84
+ utilities/subprocess.py,sha256=f8amdrbh48Y_3ETcIU_vthKMqAi7ehq3xmwMbAcldc8,34875
85
85
  utilities/tempfile.py,sha256=Lx6qa16lL1XVH6WdmD_G9vlN6gLI8nrIurxmsFkPKvg,3022
86
86
  utilities/testbook.py,sha256=j1KmaVbrX9VrbeMgtPh5gk55myAsn3dyRUn7jGbPbRk,1294
87
87
  utilities/text.py,sha256=7SvwcSR2l_5cOrm1samGnR4C-ZI6qyFLHLzSpO1zeHQ,13958
@@ -98,7 +98,7 @@ utilities/warnings.py,sha256=un1LvHv70PU-LLv8RxPVmugTzDJkkGXRMZTE2-fTQHw,1771
98
98
  utilities/whenever.py,sha256=F4ek0-OBWxHYrZdmoZt76N2RnNyKY5KrEHt7rqO4AQE,60183
99
99
  utilities/zipfile.py,sha256=24lQc9ATcJxHXBPc_tBDiJk48pWyRrlxO2fIsFxU0A8,699
100
100
  utilities/zoneinfo.py,sha256=tdIScrTB2-B-LH0ukb1HUXKooLknOfJNwHk10MuMYvA,3619
101
- dycw_utilities-0.174.19.dist-info/WHEEL,sha256=RRVLqVugUmFOqBedBFAmA4bsgFcROUBiSUKlERi0Hcg,79
102
- dycw_utilities-0.174.19.dist-info/entry_points.txt,sha256=ykGI1ArwOPHqm2g5Cqh3ENdMxEej_a_FcOUov5EM5Oc,155
103
- dycw_utilities-0.174.19.dist-info/METADATA,sha256=g_N5AxOBCGnPuLyOGvWEVdKj0mdu7pSyW2R6FBaPCmE,1710
104
- dycw_utilities-0.174.19.dist-info/RECORD,,
101
+ dycw_utilities-0.174.20.dist-info/WHEEL,sha256=RRVLqVugUmFOqBedBFAmA4bsgFcROUBiSUKlERi0Hcg,79
102
+ dycw_utilities-0.174.20.dist-info/entry_points.txt,sha256=ykGI1ArwOPHqm2g5Cqh3ENdMxEej_a_FcOUov5EM5Oc,155
103
+ dycw_utilities-0.174.20.dist-info/METADATA,sha256=j2YRKAirmAe5WDN_hR-Nm9lV3oHLNWg_42bMAAPUTqE,1710
104
+ dycw_utilities-0.174.20.dist-info/RECORD,,
utilities/__init__.py CHANGED
@@ -1,3 +1,3 @@
1
1
  from __future__ import annotations
2
2
 
3
- __version__ = "0.174.19"
3
+ __version__ = "0.174.20"
utilities/subprocess.py CHANGED
@@ -49,6 +49,13 @@ UPDATE_CA_CERTIFICATES: str = "update-ca-certificates"
49
49
  ##
50
50
 
51
51
 
52
+ def apt_install(package: str, /, *, update: bool = False, sudo: bool = False) -> None:
53
+ """Install a package."""
54
+ if update: # pragma: no cover
55
+ run(*maybe_sudo_cmd(*APT_UPDATE, sudo=sudo))
56
+ run(*maybe_sudo_cmd(*apt_install_cmd(package), sudo=sudo))
57
+
58
+
52
59
  def apt_install_cmd(package: str, /) -> list[str]:
53
60
  """Command to use 'apt' to install a package."""
54
61
  return ["apt", "install", "-y", package]
@@ -250,7 +257,7 @@ def git_clone(
250
257
  rm(path, sudo=sudo)
251
258
  run(*maybe_sudo_cmd(*git_clone_cmd(url, path), sudo=sudo))
252
259
  if branch is not None:
253
- run(*maybe_sudo_cmd(*git_hard_reset_cmd(branch=branch), sudo=sudo), cwd=path)
260
+ git_checkout(branch, path)
254
261
 
255
262
 
256
263
  def git_clone_cmd(url: str, path: PathLike, /) -> list[str]:
@@ -261,15 +268,6 @@ def git_clone_cmd(url: str, path: PathLike, /) -> list[str]:
261
268
  ##
262
269
 
263
270
 
264
- def git_hard_reset_cmd(*, branch: str | None = None) -> list[str]:
265
- """Command to use 'git hard-reset' to hard reset a repository."""
266
- branch_use = "master" if branch is None else branch
267
- return ["git", "hard-reset", branch_use]
268
-
269
-
270
- ##
271
-
272
-
273
271
  def maybe_parent(path: PathLike, /, *, parent: bool = False) -> Path:
274
272
  """Get the parent of a path, if required."""
275
273
  path = Path(path)
@@ -1207,6 +1205,7 @@ __all__ = [
1207
1205
  "RsyncCmdError",
1208
1206
  "RsyncCmdNoSourcesError",
1209
1207
  "RsyncCmdSourcesNotFoundError",
1208
+ "apt_install",
1210
1209
  "apt_install_cmd",
1211
1210
  "cd_cmd",
1212
1211
  "chmod",
@@ -1222,7 +1221,6 @@ __all__ = [
1222
1221
  "git_checkout_cmd",
1223
1222
  "git_clone",
1224
1223
  "git_clone_cmd",
1225
- "git_hard_reset_cmd",
1226
1224
  "maybe_parent",
1227
1225
  "maybe_sudo_cmd",
1228
1226
  "mkdir",