dycw-utilities 0.175.8__py3-none-any.whl → 0.175.10__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.8
3
+ Version: 0.175.10
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=dimB-KrpXPSsTkYAwl65rxlG9Nzm6WifRy3eE9oX204,60
1
+ utilities/__init__.py,sha256=RX0rYH1LtPcQcpJwGiFLxVeus-YJQ8zpeq1Xzwe2t44,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,8 +80,8 @@ 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=pTmRcfsIraSfsM182R0gzqvDrBS7-_dRmwOABU1ZB14,41018
84
- utilities/tempfile.py,sha256=Lx6qa16lL1XVH6WdmD_G9vlN6gLI8nrIurxmsFkPKvg,3022
83
+ utilities/subprocess.py,sha256=FUAEv0iG7PbBkVOdkoHNSpPhAWWda6xwZf-FcwXn7f4,41099
84
+ utilities/tempfile.py,sha256=QyvIdfV4r4YZ0NeNYsg0tCijThLKa7Z32u5Kxy6ZsGo,3619
85
85
  utilities/testbook.py,sha256=j1KmaVbrX9VrbeMgtPh5gk55myAsn3dyRUn7jGbPbRk,1294
86
86
  utilities/text.py,sha256=7SvwcSR2l_5cOrm1samGnR4C-ZI6qyFLHLzSpO1zeHQ,13958
87
87
  utilities/threading.py,sha256=GvBOp4CyhHfN90wGXZuA2VKe9fGzMaEa7oCl4f3nnPU,1009
@@ -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.8.dist-info/WHEEL,sha256=RRVLqVugUmFOqBedBFAmA4bsgFcROUBiSUKlERi0Hcg,79
101
- dycw_utilities-0.175.8.dist-info/entry_points.txt,sha256=cOGtKeJI0KXLSV7MJ8Dhc2G8jPgDcBDm53MVNJU4ycI,136
102
- dycw_utilities-0.175.8.dist-info/METADATA,sha256=TDN7UfHY1ZozsYJ6mk0G27Ll3p6Kgc61Kk0SgnI5Lno,1442
103
- dycw_utilities-0.175.8.dist-info/RECORD,,
100
+ dycw_utilities-0.175.10.dist-info/WHEEL,sha256=RRVLqVugUmFOqBedBFAmA4bsgFcROUBiSUKlERi0Hcg,79
101
+ dycw_utilities-0.175.10.dist-info/entry_points.txt,sha256=cOGtKeJI0KXLSV7MJ8Dhc2G8jPgDcBDm53MVNJU4ycI,136
102
+ dycw_utilities-0.175.10.dist-info/METADATA,sha256=raQt1Obi3Hw65qcpx8dnCzCCi8KaaMr2bLkPeCRPB8M,1443
103
+ dycw_utilities-0.175.10.dist-info/RECORD,,
utilities/__init__.py CHANGED
@@ -1,3 +1,3 @@
1
1
  from __future__ import annotations
2
2
 
3
- __version__ = "0.175.8"
3
+ __version__ = "0.175.10"
utilities/subprocess.py CHANGED
@@ -349,21 +349,21 @@ def mv_cmd(src: PathLike, dest: PathLike, /) -> list[str]:
349
349
  ##
350
350
 
351
351
 
352
- def rm(path: PathLike, /, *, sudo: bool = False) -> None:
352
+ def rm(path: PathLike, /, *paths: PathLike, sudo: bool = False) -> None:
353
353
  """Remove a file/directory."""
354
354
  if sudo: # pragma: no cover
355
- run(*sudo_cmd(*rm_cmd(path)))
355
+ run(*sudo_cmd(*rm_cmd(path, *paths)))
356
356
  else:
357
- path = Path(path)
358
- if path.is_file():
359
- path.unlink(missing_ok=True)
360
- elif path.is_dir():
361
- rmtree(path, ignore_errors=True)
357
+ for p in map(Path, [path, *paths]):
358
+ if p.is_file():
359
+ p.unlink(missing_ok=True)
360
+ elif p.is_dir():
361
+ rmtree(p, ignore_errors=True)
362
362
 
363
363
 
364
- def rm_cmd(path: PathLike, /) -> list[str]:
364
+ def rm_cmd(path: PathLike, /, *paths: PathLike) -> list[str]:
365
365
  """Command to use 'rm' to remove a file/directory."""
366
- return ["rm", "-rf", str(path)]
366
+ return ["rm", "-rf", str(path), *map(str, paths)]
367
367
 
368
368
 
369
369
  ##
utilities/tempfile.py CHANGED
@@ -79,8 +79,32 @@ def TemporaryFile( # noqa: N802
79
79
  ignore_cleanup_errors: bool = False,
80
80
  delete: bool = True,
81
81
  name: str | None = None,
82
+ text: str | None = None,
82
83
  ) -> Iterator[Path]:
83
84
  """Yield a temporary file."""
85
+ with _temporary_file_inner(
86
+ suffix=suffix,
87
+ prefix=prefix,
88
+ dir=dir,
89
+ ignore_cleanup_errors=ignore_cleanup_errors,
90
+ delete=delete,
91
+ name=name,
92
+ ) as temp:
93
+ if text is not None:
94
+ _ = temp.write_text(text)
95
+ yield temp
96
+
97
+
98
+ @contextmanager
99
+ def _temporary_file_inner(
100
+ *,
101
+ suffix: str | None = None,
102
+ prefix: str | None = None,
103
+ dir: PathLike | None = None, # noqa: A002
104
+ ignore_cleanup_errors: bool = False,
105
+ delete: bool = True,
106
+ name: str | None = None,
107
+ ) -> Iterator[Path]:
84
108
  with TemporaryDirectory(
85
109
  suffix=suffix,
86
110
  prefix=prefix,