dycw-utilities 0.174.17__py3-none-any.whl → 0.174.18__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.17
3
+ Version: 0.174.18
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=kcADuh_nb8xfuYrat4AkfaKqdxp3l7xyrXWoJJ5JZLk,61
1
+ utilities/__init__.py,sha256=2xupJL_-0RN3mhQDSD7NIAJegYc_Pr3NKdbT8LPHrvI,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
@@ -12,7 +12,7 @@ utilities/contextvars.py,sha256=J8OhC7jqozAGYOCe2KUWysbPXNGe5JYz3HfaY_mIs08,883
12
12
  utilities/cryptography.py,sha256=5PFrzsNUGHay91dFgYnDKwYprXxahrBqztmUqViRzBk,956
13
13
  utilities/cvxpy.py,sha256=Rv1-fD-XYerosCavRF8Pohop2DBkU3AlFaGTfD8AEAA,13776
14
14
  utilities/dataclasses.py,sha256=xbU3QN1GFy7RC6hIJRZIeUZm7YRlodrgEWmahWG6k2g,32465
15
- utilities/docker.py,sha256=l_R9Eyhc-_JbkkaYXYKGZ0PZ_oukrSj8aKtD1NyAhMM,7879
15
+ utilities/docker.py,sha256=N__PKd3cnSRsXNEMHMLdLneLdyzfbr2ESkElcwrovvQ,7940
16
16
  utilities/enum.py,sha256=5l6pwZD1cjSlVW4ss-zBPspWvrbrYrdtJWcg6f5_J5w,5781
17
17
  utilities/errors.py,sha256=mFlDGSM0LI1jZ1pbqwLAH3ttLZ2JVIxyZLojw8tGVZU,1479
18
18
  utilities/fastapi.py,sha256=TqyKvBjiMS594sXPjrz-KRTLMb3l3D3rZ1zAYV7GfOk,1454
@@ -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=FzVd1evvhaJR2U_tATJ37Y6YjF8O61XPeqYo8NLonG4,33123
84
+ utilities/subprocess.py,sha256=q0k-Fl8iRKX9UvqtNgshUcrv-tAEzJbeyoQWiWEdql8,34298
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.17.dist-info/WHEEL,sha256=RRVLqVugUmFOqBedBFAmA4bsgFcROUBiSUKlERi0Hcg,79
102
- dycw_utilities-0.174.17.dist-info/entry_points.txt,sha256=ykGI1ArwOPHqm2g5Cqh3ENdMxEej_a_FcOUov5EM5Oc,155
103
- dycw_utilities-0.174.17.dist-info/METADATA,sha256=vF_qKrCXt5r90r7OjWFLitGHfDgcAcVUDj6Y47YMvEQ,1710
104
- dycw_utilities-0.174.17.dist-info/RECORD,,
101
+ dycw_utilities-0.174.18.dist-info/WHEEL,sha256=RRVLqVugUmFOqBedBFAmA4bsgFcROUBiSUKlERi0Hcg,79
102
+ dycw_utilities-0.174.18.dist-info/entry_points.txt,sha256=ykGI1ArwOPHqm2g5Cqh3ENdMxEej_a_FcOUov5EM5Oc,155
103
+ dycw_utilities-0.174.18.dist-info/METADATA,sha256=lsjOEHDTftfTew-cUGjw81uggqGrWLEXHVN3snWSV80,1710
104
+ dycw_utilities-0.174.18.dist-info/RECORD,,
utilities/__init__.py CHANGED
@@ -1,3 +1,3 @@
1
1
  from __future__ import annotations
2
2
 
3
- __version__ = "0.174.17"
3
+ __version__ = "0.174.18"
utilities/docker.py CHANGED
@@ -269,6 +269,7 @@ def yield_docker_temp_dir(
269
269
  logger: LoggerLike | None = None,
270
270
  keep: bool = False,
271
271
  ) -> Iterator[Path]:
272
+ """Yield a temporary directory in a Docker container."""
272
273
  path = Path( # skipif-ci
273
274
  docker_exec(
274
275
  container,
utilities/subprocess.py CHANGED
@@ -221,6 +221,16 @@ def expand_path(
221
221
  ##
222
222
 
223
223
 
224
+ def git_clone(
225
+ url: str, path: PathLike, /, *, sudo: bool = False, branch: str | None = None
226
+ ) -> None:
227
+ """Clone a repository."""
228
+ rm(path, sudo=sudo)
229
+ run(*maybe_sudo_cmd(*git_clone_cmd(url, path), sudo=sudo))
230
+ if branch is not None:
231
+ run(*maybe_sudo_cmd(*git_hard_reset_cmd(branch=branch), sudo=sudo), cwd=path)
232
+
233
+
224
234
  def git_clone_cmd(url: str, path: PathLike, /) -> list[str]:
225
235
  """Command to use 'git clone' to clone a repository."""
226
236
  return ["git", "clone", "--recurse-submodules", url, str(path)]
@@ -1089,14 +1099,26 @@ def tee_cmd(path: PathLike, /, *, append: bool = False) -> list[str]:
1089
1099
  ##
1090
1100
 
1091
1101
 
1102
+ def touch(path: PathLike, /, *, sudo: bool = False) -> None:
1103
+ """Change file access and modification times."""
1104
+ run(*maybe_sudo_cmd(*touch_cmd(path), sudo=sudo))
1105
+
1106
+
1092
1107
  def touch_cmd(path: PathLike, /) -> list[str]:
1108
+ """Command to use 'touch' to change file access and modification times."""
1093
1109
  return ["touch", str(path)]
1094
1110
 
1095
1111
 
1096
1112
  ##
1097
1113
 
1098
1114
 
1115
+ def uv_run(module: str, /, *args: str) -> None:
1116
+ """Run a command or script."""
1117
+ run(*uv_run_cmd(module, *args)) # pragma: no cover
1118
+
1119
+
1099
1120
  def uv_run_cmd(module: str, /, *args: str) -> list[str]:
1121
+ """Command to use 'uv' to run a command or script."""
1100
1122
  return [
1101
1123
  "uv",
1102
1124
  "run",
@@ -1114,6 +1136,17 @@ def uv_run_cmd(module: str, /, *args: str) -> list[str]:
1114
1136
  ##
1115
1137
 
1116
1138
 
1139
+ @contextmanager
1140
+ def yield_git_repo(url: str, /, *, branch: str | None = None) -> Iterator[Path]:
1141
+ """Yield a temporary git repository."""
1142
+ with TemporaryDirectory() as temp_dir:
1143
+ git_clone(url, temp_dir, branch=branch)
1144
+ yield temp_dir
1145
+
1146
+
1147
+ ##
1148
+
1149
+
1117
1150
  @contextmanager
1118
1151
  def yield_ssh_temp_dir(
1119
1152
  user: str,
@@ -1124,6 +1157,7 @@ def yield_ssh_temp_dir(
1124
1157
  logger: LoggerLike | None = None,
1125
1158
  keep: bool = False,
1126
1159
  ) -> Iterator[Path]:
1160
+ """Yield a temporary directory on a remote machine."""
1127
1161
  path = Path( # skipif-ci
1128
1162
  ssh(user, hostname, *MKTEMP_DIR_CMD, return_=True, retry=retry, logger=logger)
1129
1163
  )
@@ -1160,6 +1194,7 @@ __all__ = [
1160
1194
  "cp_cmd",
1161
1195
  "echo_cmd",
1162
1196
  "expand_path",
1197
+ "git_clone",
1163
1198
  "git_clone_cmd",
1164
1199
  "git_hard_reset_cmd",
1165
1200
  "maybe_parent",
@@ -1183,7 +1218,10 @@ __all__ = [
1183
1218
  "symlink",
1184
1219
  "symlink_cmd",
1185
1220
  "tee_cmd",
1221
+ "touch",
1186
1222
  "touch_cmd",
1223
+ "uv_run",
1187
1224
  "uv_run_cmd",
1225
+ "yield_git_repo",
1188
1226
  "yield_ssh_temp_dir",
1189
1227
  ]