dycw-utilities 0.174.18__py3-none-any.whl → 0.174.19__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.18
3
+ Version: 0.174.19
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=2xupJL_-0RN3mhQDSD7NIAJegYc_Pr3NKdbT8LPHrvI,61
1
+ utilities/__init__.py,sha256=nyJKpGIkfnetD4-kNA4ZJixn2uq8SdQrflZtDYf_k2Q,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
@@ -49,8 +49,8 @@ utilities/parse.py,sha256=g7Qm9eBOIeDId2tGA021CIaeF6jp1TI8rx4srdvlyoo,17937
49
49
  utilities/pathlib.py,sha256=N4Ip8R9eCM-6GfvxUJ3T9oQIle2C2P52F-13BCFRdTg,9345
50
50
  utilities/permissions.py,sha256=vLXlWztSVYffbrxptne7ksj6dU1HLekm4fEvS4ny_4Q,8944
51
51
  utilities/pickle.py,sha256=MBT2xZCsv0pH868IXLGKnlcqNx2IRVKYNpRcqiQQqxw,653
52
- utilities/platform.py,sha256=Grov52WxNOViJEZyRcm-b2m_Dp1T0waPjDCusR_9oqs,2791
53
- utilities/polars.py,sha256=cNFBLWgOMUAp_Sz4xtlto17uZswZRrcfQYC95QKyaY4,87483
52
+ utilities/platform.py,sha256=R3ldt2-DlI7la9ng6Rxt1CThd2lL0Ai2tC0TbabtCC0,2800
53
+ utilities/polars.py,sha256=JPzN4UqQDC7R4IXsIuXEIXRiwHSrkiSZcD8UOfwGPuE,87535
54
54
  utilities/polars_ols.py,sha256=LNTFNLPuYW7fcAHymlbnams_DhitToblYvib3mhKbwI,5615
55
55
  utilities/postgres.py,sha256=g3tEwTI8TdmiCbRME61ffQ0xaibdpXPu8mJOOHvjPKc,12532
56
56
  utilities/pottery.py,sha256=nA0SsF9irvfC0tk68YAr08tuL9lGRSlBKihSx7Ibk84,3963
@@ -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=q0k-Fl8iRKX9UvqtNgshUcrv-tAEzJbeyoQWiWEdql8,34298
84
+ utilities/subprocess.py,sha256=7GEv6T9F7z9nacPymzOUUAF6r6ChPjGgKlL64Zrh-AU,34909
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.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,,
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,,
utilities/__init__.py CHANGED
@@ -1,3 +1,3 @@
1
1
  from __future__ import annotations
2
2
 
3
- __version__ = "0.174.18"
3
+ __version__ = "0.174.19"
utilities/platform.py CHANGED
@@ -16,7 +16,7 @@ System = Literal["windows", "mac", "linux"]
16
16
  def get_system() -> System:
17
17
  """Get the system/OS name."""
18
18
  sys = system()
19
- if sys == "Windows": # skipif-ci
19
+ if sys == "Windows": # skipif-not-windows
20
20
  return "windows"
21
21
  if sys == "Darwin": # skipif-not-macos
22
22
  return "mac"
utilities/polars.py CHANGED
@@ -2639,6 +2639,8 @@ def search_period(
2639
2639
  return None
2640
2640
  item: dt.datetime = series[index]["start"]
2641
2641
  return index if py_date_time > item else None
2642
+ case never:
2643
+ assert_never(never)
2642
2644
 
2643
2645
 
2644
2646
  ##
utilities/subprocess.py CHANGED
@@ -40,6 +40,7 @@ _HOST_KEY_ALGORITHMS = ["ssh-ed25519"]
40
40
  APT_UPDATE = ["apt", "update", "-y"]
41
41
  BASH_LC = ["bash", "-lc"]
42
42
  BASH_LS = ["bash", "-ls"]
43
+ GIT_BRANCH_SHOW_CURRENT = ["git", "branch", "--show-current"]
43
44
  MKTEMP_DIR_CMD = ["mktemp", "-d"]
44
45
  RESTART_SSHD = ["systemctl", "restart", "sshd"]
45
46
  UPDATE_CA_CERTIFICATES: str = "update-ca-certificates"
@@ -221,6 +222,27 @@ def expand_path(
221
222
  ##
222
223
 
223
224
 
225
+ def git_branch_current(path: PathLike, /) -> str:
226
+ """Show the current a branch."""
227
+ return run(*GIT_BRANCH_SHOW_CURRENT, cwd=path, return_=True)
228
+
229
+
230
+ ##
231
+
232
+
233
+ def git_checkout(branch: str, path: PathLike, /) -> None:
234
+ """Switch a branch."""
235
+ run(*git_checkout_cmd(branch), cwd=path)
236
+
237
+
238
+ def git_checkout_cmd(branch: str, /) -> list[str]:
239
+ """Command to use 'git checkout' to switch a branch."""
240
+ return ["git", "checkout", branch]
241
+
242
+
243
+ ##
244
+
245
+
224
246
  def git_clone(
225
247
  url: str, path: PathLike, /, *, sudo: bool = False, branch: str | None = None
226
248
  ) -> None:
@@ -1175,6 +1197,7 @@ __all__ = [
1175
1197
  "APT_UPDATE",
1176
1198
  "BASH_LC",
1177
1199
  "BASH_LS",
1200
+ "GIT_BRANCH_SHOW_CURRENT",
1178
1201
  "MKTEMP_DIR_CMD",
1179
1202
  "RESTART_SSHD",
1180
1203
  "UPDATE_CA_CERTIFICATES",
@@ -1194,6 +1217,9 @@ __all__ = [
1194
1217
  "cp_cmd",
1195
1218
  "echo_cmd",
1196
1219
  "expand_path",
1220
+ "git_branch_current",
1221
+ "git_checkout",
1222
+ "git_checkout_cmd",
1197
1223
  "git_clone",
1198
1224
  "git_clone_cmd",
1199
1225
  "git_hard_reset_cmd",