dycw-utilities 0.175.36__py3-none-any.whl → 0.175.38__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.36
3
+ Version: 0.175.38
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=7QvekuGqm3-JdDS498qZrn1_4tah8Zape8NgpwbTKUc,61
1
+ utilities/__init__.py,sha256=0aEOfOCZ3zR_I7TUqaC_QJfWzI7LFfDdSaWhZp-3Cf8,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,10 +80,10 @@ 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=4IAEpK0z5OUQ3hsCJFZgkF2TW-osdrBJODaEhMAuQ_Q,53751
83
+ utilities/subprocess.py,sha256=AEJ5xxwNfdR_hZ-dGvHpf7Qsr-_C2iXhC-IA2dkVwV4,53827
84
84
  utilities/tempfile.py,sha256=4kRGd4hyINDX4hpcYMtwzDcd-4IKjpTWT0MnjnKD4hE,4221
85
85
  utilities/testbook.py,sha256=j1KmaVbrX9VrbeMgtPh5gk55myAsn3dyRUn7jGbPbRk,1294
86
- utilities/text.py,sha256=7SvwcSR2l_5cOrm1samGnR4C-ZI6qyFLHLzSpO1zeHQ,13958
86
+ utilities/text.py,sha256=UKW6xtF4bb0i-Gu1jctJvvQmeXk6U6UYNqoEnCLdaOo,14102
87
87
  utilities/threading.py,sha256=GvBOp4CyhHfN90wGXZuA2VKe9fGzMaEa7oCl4f3nnPU,1009
88
88
  utilities/timer.py,sha256=BGlwEVznx67scuLOUohyWJ4d5rTnwtk-IR4yLXFiNfo,2574
89
89
  utilities/traceback.py,sha256=B_sc0TRUv-mGDnF-ek05nbqjmBiHr3-wvxliAqIF5hI,9608
@@ -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.36.dist-info/WHEEL,sha256=RRVLqVugUmFOqBedBFAmA4bsgFcROUBiSUKlERi0Hcg,79
101
- dycw_utilities-0.175.36.dist-info/entry_points.txt,sha256=cOGtKeJI0KXLSV7MJ8Dhc2G8jPgDcBDm53MVNJU4ycI,136
102
- dycw_utilities-0.175.36.dist-info/METADATA,sha256=baQ9cqXdr7o8gURScaioDS4t0Cg3ODkxCO79ptarTL8,1443
103
- dycw_utilities-0.175.36.dist-info/RECORD,,
100
+ dycw_utilities-0.175.38.dist-info/WHEEL,sha256=RRVLqVugUmFOqBedBFAmA4bsgFcROUBiSUKlERi0Hcg,79
101
+ dycw_utilities-0.175.38.dist-info/entry_points.txt,sha256=cOGtKeJI0KXLSV7MJ8Dhc2G8jPgDcBDm53MVNJU4ycI,136
102
+ dycw_utilities-0.175.38.dist-info/METADATA,sha256=Z2_CY8exhKbS_PJXAi8P5KX3QAj3uug7sbbR12RvakY,1443
103
+ dycw_utilities-0.175.38.dist-info/RECORD,,
utilities/__init__.py CHANGED
@@ -1,3 +1,3 @@
1
1
  from __future__ import annotations
2
2
 
3
- __version__ = "0.175.36"
3
+ __version__ = "0.175.38"
utilities/subprocess.py CHANGED
@@ -7,7 +7,7 @@ from dataclasses import dataclass
7
7
  from io import StringIO
8
8
  from itertools import repeat
9
9
  from pathlib import Path
10
- from re import MULTILINE, search
10
+ from re import MULTILINE, escape, search
11
11
  from shlex import join
12
12
  from shutil import copyfile, copytree, move, rmtree
13
13
  from string import Template
@@ -69,9 +69,12 @@ def append_text(
69
69
  try:
70
70
  existing = cat(path, sudo=sudo)
71
71
  except (CalledProcessError, FileNotFoundError):
72
- tee(path, text, sudo=sudo, append=True)
72
+ tee(path, text, sudo=sudo)
73
73
  return
74
- if skip_if_present and (search(text, existing, flags=flags) is not None):
74
+ if existing == "":
75
+ tee(path, text, sudo=sudo)
76
+ return
77
+ if skip_if_present and (search(escape(text), existing, flags=flags) is not None):
75
78
  return
76
79
  full = "".join([*repeat("\n", times=blank_lines), text])
77
80
  tee(path, full, sudo=sudo, append=True)
utilities/text.py CHANGED
@@ -411,6 +411,14 @@ def _escape_separator(*, separator: str = _DEFAULT_SEPARATOR) -> str:
411
411
  ##
412
412
 
413
413
 
414
+ def repr_str(obj: Any, /) -> str:
415
+ """Get the representation of the string of an object."""
416
+ return repr(str(obj))
417
+
418
+
419
+ ##
420
+
421
+
414
422
  class secret_str(str): # noqa: N801
415
423
  """A string with an obfuscated representation."""
416
424
 
@@ -544,6 +552,7 @@ __all__ = [
544
552
  "pascal_case",
545
553
  "prompt_bool",
546
554
  "repr_encode",
555
+ "repr_str",
547
556
  "secret_str",
548
557
  "snake_case",
549
558
  "split_key_value_pairs",