dycw-utilities 0.175.27__py3-none-any.whl → 0.175.28__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.175.27
3
+ Version: 0.175.28
4
4
  Summary: Miscellaneous Python utilities
5
5
  Author: Derek Wan
6
6
  Author-email: Derek Wan <d.wan@icloud.com>
@@ -1,4 +1,4 @@
1
- utilities/__init__.py,sha256=IhEmMfmycJdR031fNLaK1iuiv3mg9N-cQcLonJln-q4,61
1
+ utilities/__init__.py,sha256=k4kaN7LN6ZF6oNv47GuGm1AaLmVrNa8LJBL_8oBnlMY,61
2
2
  utilities/altair.py,sha256=TLfRFbG9HwG7SLXoJ-v0r-t49ZaGgTQZD82cpjVi4vs,9085
3
3
  utilities/asyncio.py,sha256=aJySVxBY0gqsIYnoNmH7-1r8djKuf4vSsU69VCD08t8,16772
4
4
  utilities/atomicwrites.py,sha256=tPo6r-Rypd9u99u66B9z86YBPpnLrlHtwox_8Z7T34Y,5790
@@ -80,7 +80,7 @@ utilities/sqlalchemy.py,sha256=HQYpd7LFxdTF5WYVWYtCJeEBI71EJm7ytvCGyAH9B-U,37163
80
80
  utilities/sqlalchemy_polars.py,sha256=JCGhB37raSR7fqeWV5dTsciRTMVzIdVT9YSqKT0piT0,13370
81
81
  utilities/statsmodels.py,sha256=koyiBHvpMcSiBfh99wFUfSggLNx7cuAw3rwyfAhoKpQ,3410
82
82
  utilities/string.py,sha256=shmBK87zZwzGyixuNuXCiUbqzfeZ9xlrFwz6JTaRvDk,582
83
- utilities/subprocess.py,sha256=RRDh212OgVj07cidE8SgyOvyaRfR9BFKyw48X_sIqhU,51182
83
+ utilities/subprocess.py,sha256=f-bVgM-8dGYuqmfegp7y9JtU1WP3FX4AaU2munpeD-U,52304
84
84
  utilities/tempfile.py,sha256=a3_M1QyxGZql_VcGkBOQBeWbbkItjgkfIpVyzU1UAic,3843
85
85
  utilities/testbook.py,sha256=j1KmaVbrX9VrbeMgtPh5gk55myAsn3dyRUn7jGbPbRk,1294
86
86
  utilities/text.py,sha256=7SvwcSR2l_5cOrm1samGnR4C-ZI6qyFLHLzSpO1zeHQ,13958
@@ -97,7 +97,7 @@ utilities/warnings.py,sha256=un1LvHv70PU-LLv8RxPVmugTzDJkkGXRMZTE2-fTQHw,1771
97
97
  utilities/whenever.py,sha256=F4ek0-OBWxHYrZdmoZt76N2RnNyKY5KrEHt7rqO4AQE,60183
98
98
  utilities/zipfile.py,sha256=24lQc9ATcJxHXBPc_tBDiJk48pWyRrlxO2fIsFxU0A8,699
99
99
  utilities/zoneinfo.py,sha256=tdIScrTB2-B-LH0ukb1HUXKooLknOfJNwHk10MuMYvA,3619
100
- dycw_utilities-0.175.27.dist-info/WHEEL,sha256=RRVLqVugUmFOqBedBFAmA4bsgFcROUBiSUKlERi0Hcg,79
101
- dycw_utilities-0.175.27.dist-info/entry_points.txt,sha256=cOGtKeJI0KXLSV7MJ8Dhc2G8jPgDcBDm53MVNJU4ycI,136
102
- dycw_utilities-0.175.27.dist-info/METADATA,sha256=_bP-SZHDjfjAq8A7eJxwN3gt0WHcfNSeifg3u5JWqUU,1443
103
- dycw_utilities-0.175.27.dist-info/RECORD,,
100
+ dycw_utilities-0.175.28.dist-info/WHEEL,sha256=RRVLqVugUmFOqBedBFAmA4bsgFcROUBiSUKlERi0Hcg,79
101
+ dycw_utilities-0.175.28.dist-info/entry_points.txt,sha256=cOGtKeJI0KXLSV7MJ8Dhc2G8jPgDcBDm53MVNJU4ycI,136
102
+ dycw_utilities-0.175.28.dist-info/METADATA,sha256=k8PYEVjHbdSwrVP6nAsY8ptu8MEenozvTPprPs3Pgwk,1443
103
+ dycw_utilities-0.175.28.dist-info/RECORD,,
utilities/__init__.py CHANGED
@@ -1,3 +1,3 @@
1
1
  from __future__ import annotations
2
2
 
3
- __version__ = "0.175.27"
3
+ __version__ = "0.175.28"
utilities/subprocess.py CHANGED
@@ -542,6 +542,53 @@ def git_clone_cmd(url: str, path: PathLike, /) -> list[str]:
542
542
  ##
543
543
 
544
544
 
545
+ def install(
546
+ path: PathLike,
547
+ /,
548
+ *,
549
+ directory: bool = False,
550
+ mode: PermissionsLike | None = None,
551
+ owner: str | int | None = None,
552
+ group: str | int | None = None,
553
+ sudo: bool = False,
554
+ ) -> None:
555
+ """Install a binary."""
556
+ args = maybe_sudo_cmd(
557
+ *install_cmd(path, directory=directory, mode=mode, owner=owner, group=group),
558
+ sudo=sudo,
559
+ )
560
+ run(*args)
561
+
562
+
563
+ def install_cmd(
564
+ path: PathLike,
565
+ /,
566
+ *,
567
+ directory: bool = False,
568
+ mode: PermissionsLike | None = None,
569
+ owner: str | int | None = None,
570
+ group: str | int | None = None,
571
+ ) -> list[str]:
572
+ """Command to use 'install' to install a binary."""
573
+ args: list[str] = ["install"]
574
+ if directory:
575
+ args.append("-d")
576
+ if mode is not None:
577
+ args.extend(["-m", str(ensure_perms(mode))])
578
+ if owner is not None:
579
+ args.extend(["-o", str(owner)])
580
+ if group is not None:
581
+ args.extend(["-g", str(group)])
582
+ if directory:
583
+ args.append(str(path))
584
+ else:
585
+ args.extend(["/dev/null", str(path)])
586
+ return args
587
+
588
+
589
+ ##
590
+
591
+
545
592
  def maybe_parent(path: PathLike, /, *, parent: bool = False) -> Path:
546
593
  """Get the parent of a path, if required."""
547
594
  path = Path(path)
@@ -1831,6 +1878,8 @@ __all__ = [
1831
1878
  "git_checkout_cmd",
1832
1879
  "git_clone",
1833
1880
  "git_clone_cmd",
1881
+ "install",
1882
+ "install_cmd",
1834
1883
  "maybe_parent",
1835
1884
  "maybe_sudo_cmd",
1836
1885
  "mkdir",