dycw-utilities 0.175.26__py3-none-any.whl → 0.175.27__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.26
3
+ Version: 0.175.27
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=HrK7xYXnuNa7NvyOEq-oZ72p1jL1hr7f0vITbrb-rNA,61
1
+ utilities/__init__.py,sha256=IhEmMfmycJdR031fNLaK1iuiv3mg9N-cQcLonJln-q4,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=uZ2HR9hJOnqhrS-uwfZZuERxO_pSLfHZZbMFfms7lQA,46604
83
+ utilities/subprocess.py,sha256=RRDh212OgVj07cidE8SgyOvyaRfR9BFKyw48X_sIqhU,51182
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.26.dist-info/WHEEL,sha256=RRVLqVugUmFOqBedBFAmA4bsgFcROUBiSUKlERi0Hcg,79
101
- dycw_utilities-0.175.26.dist-info/entry_points.txt,sha256=cOGtKeJI0KXLSV7MJ8Dhc2G8jPgDcBDm53MVNJU4ycI,136
102
- dycw_utilities-0.175.26.dist-info/METADATA,sha256=Yokzuv-jy8hF_tHUIxoSZTc9_Z17cDJwlorBmc9gSE4,1443
103
- dycw_utilities-0.175.26.dist-info/RECORD,,
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,,
utilities/__init__.py CHANGED
@@ -1,3 +1,3 @@
1
1
  from __future__ import annotations
2
2
 
3
- __version__ = "0.175.26"
3
+ __version__ = "0.175.27"
utilities/subprocess.py CHANGED
@@ -295,6 +295,185 @@ def cp_cmd(src: PathLike, dest: PathLike, /) -> list[str]:
295
295
  ##
296
296
 
297
297
 
298
+ @overload
299
+ def curl(
300
+ url: str,
301
+ /,
302
+ *,
303
+ fail: bool = True,
304
+ location: bool = True,
305
+ output: PathLike | None = None,
306
+ show_error: bool = True,
307
+ silent: bool = True,
308
+ sudo: bool = False,
309
+ print: bool = False,
310
+ print_stdout: bool = False,
311
+ print_stderr: bool = False,
312
+ return_: Literal[True],
313
+ return_stdout: Literal[False] = False,
314
+ return_stderr: Literal[False] = False,
315
+ retry: Retry | None = None,
316
+ retry_skip: Callable[[int, str, str], bool] | None = None,
317
+ logger: LoggerLike | None = None,
318
+ ) -> str: ...
319
+ @overload
320
+ def curl(
321
+ url: str,
322
+ /,
323
+ *,
324
+ fail: bool = True,
325
+ location: bool = True,
326
+ output: PathLike | None = None,
327
+ show_error: bool = True,
328
+ silent: bool = True,
329
+ sudo: bool = False,
330
+ print: bool = False,
331
+ print_stdout: bool = False,
332
+ print_stderr: bool = False,
333
+ return_: Literal[False] = False,
334
+ return_stdout: Literal[True],
335
+ return_stderr: Literal[False] = False,
336
+ retry: Retry | None = None,
337
+ retry_skip: Callable[[int, str, str], bool] | None = None,
338
+ logger: LoggerLike | None = None,
339
+ ) -> str: ...
340
+ @overload
341
+ def curl(
342
+ url: str,
343
+ /,
344
+ *,
345
+ fail: bool = True,
346
+ location: bool = True,
347
+ output: PathLike | None = None,
348
+ show_error: bool = True,
349
+ silent: bool = True,
350
+ sudo: bool = False,
351
+ print: bool = False,
352
+ print_stdout: bool = False,
353
+ print_stderr: bool = False,
354
+ return_: Literal[False] = False,
355
+ return_stdout: Literal[False] = False,
356
+ return_stderr: Literal[True],
357
+ retry: Retry | None = None,
358
+ retry_skip: Callable[[int, str, str], bool] | None = None,
359
+ logger: LoggerLike | None = None,
360
+ ) -> str: ...
361
+ @overload
362
+ def curl(
363
+ url: str,
364
+ /,
365
+ *,
366
+ fail: bool = True,
367
+ location: bool = True,
368
+ output: PathLike | None = None,
369
+ show_error: bool = True,
370
+ silent: bool = True,
371
+ sudo: bool = False,
372
+ print: bool = False,
373
+ print_stdout: bool = False,
374
+ print_stderr: bool = False,
375
+ return_: Literal[False] = False,
376
+ return_stdout: Literal[False] = False,
377
+ return_stderr: Literal[False] = False,
378
+ retry: Retry | None = None,
379
+ retry_skip: Callable[[int, str, str], bool] | None = None,
380
+ logger: LoggerLike | None = None,
381
+ ) -> None: ...
382
+ @overload
383
+ def curl(
384
+ url: str,
385
+ /,
386
+ *,
387
+ fail: bool = True,
388
+ location: bool = True,
389
+ output: PathLike | None = None,
390
+ show_error: bool = True,
391
+ silent: bool = True,
392
+ sudo: bool = False,
393
+ print: bool = False,
394
+ print_stdout: bool = False,
395
+ print_stderr: bool = False,
396
+ return_: bool = False,
397
+ return_stdout: bool = False,
398
+ return_stderr: bool = False,
399
+ retry: Retry | None = None,
400
+ retry_skip: Callable[[int, str, str], bool] | None = None,
401
+ logger: LoggerLike | None = None,
402
+ ) -> str | None: ...
403
+ def curl(
404
+ url: str,
405
+ /,
406
+ *,
407
+ fail: bool = True,
408
+ location: bool = True,
409
+ output: PathLike | None = None,
410
+ show_error: bool = True,
411
+ silent: bool = True,
412
+ sudo: bool = False,
413
+ print: bool = False, # noqa: A002
414
+ print_stdout: bool = False,
415
+ print_stderr: bool = False,
416
+ return_: bool = False,
417
+ return_stdout: bool = False,
418
+ return_stderr: bool = False,
419
+ retry: Retry | None = None,
420
+ retry_skip: Callable[[int, str, str], bool] | None = None,
421
+ logger: LoggerLike | None = None,
422
+ ) -> str | None:
423
+ """Transfer a URL."""
424
+ args = maybe_sudo_cmd(
425
+ *curl_cmd( # skipif-ci
426
+ url,
427
+ fail=fail,
428
+ location=location,
429
+ output=output,
430
+ show_error=show_error,
431
+ silent=silent,
432
+ ),
433
+ sudo=sudo,
434
+ )
435
+ return run( # skipif-ci
436
+ *args,
437
+ print=print,
438
+ print_stdout=print_stdout,
439
+ print_stderr=print_stderr,
440
+ return_=return_,
441
+ return_stdout=return_stdout,
442
+ return_stderr=return_stderr,
443
+ retry=retry,
444
+ retry_skip=retry_skip,
445
+ logger=logger,
446
+ )
447
+
448
+
449
+ def curl_cmd(
450
+ url: str,
451
+ /,
452
+ *,
453
+ fail: bool = True,
454
+ location: bool = True,
455
+ output: PathLike | None = None,
456
+ show_error: bool = True,
457
+ silent: bool = True,
458
+ ) -> list[str]:
459
+ """Command to use 'curl' to transfer a URL."""
460
+ args: list[str] = ["curl"]
461
+ if fail:
462
+ args.append("--fail")
463
+ if location:
464
+ args.append("--location")
465
+ if output is not None:
466
+ args.extend(["--create-dirs", "--output", str(output)])
467
+ if show_error:
468
+ args.append("--show-error")
469
+ if silent:
470
+ args.append("--silent")
471
+ return [*args, url]
472
+
473
+
474
+ ##
475
+
476
+
298
477
  def echo_cmd(text: str, /) -> list[str]:
299
478
  """Command to use 'echo' to write arguments to the standard output."""
300
479
  return ["echo", text]
@@ -1642,6 +1821,8 @@ __all__ = [
1642
1821
  "copy_text",
1643
1822
  "cp",
1644
1823
  "cp_cmd",
1824
+ "curl",
1825
+ "curl_cmd",
1645
1826
  "echo_cmd",
1646
1827
  "env_cmds",
1647
1828
  "expand_path",