dycw-actions 0.6.4__py3-none-any.whl → 0.7.7__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.
Files changed (73) hide show
  1. actions/__init__.py +1 -1
  2. actions/action_dicts/lib.py +8 -8
  3. actions/clean_dir/cli.py +0 -12
  4. actions/clean_dir/constants.py +7 -0
  5. actions/clean_dir/lib.py +1 -0
  6. actions/cli.py +90 -29
  7. actions/constants.py +5 -1
  8. actions/pre_commit/click.py +15 -0
  9. actions/{conformalize_repo → pre_commit/conformalize_repo}/cli.py +2 -14
  10. actions/{conformalize_repo → pre_commit/conformalize_repo}/constants.py +8 -2
  11. actions/{conformalize_repo → pre_commit/conformalize_repo}/lib.py +97 -313
  12. actions/{conformalize_repo → pre_commit/conformalize_repo}/settings.py +1 -1
  13. actions/pre_commit/constants.py +8 -0
  14. actions/pre_commit/format_requirements/cli.py +24 -0
  15. actions/pre_commit/format_requirements/constants.py +7 -0
  16. actions/pre_commit/format_requirements/lib.py +52 -0
  17. actions/pre_commit/replace_sequence_strs/__init__.py +1 -0
  18. actions/pre_commit/replace_sequence_strs/cli.py +24 -0
  19. actions/pre_commit/replace_sequence_strs/constants.py +7 -0
  20. actions/{replace_sequence_strs → pre_commit/replace_sequence_strs}/lib.py +16 -22
  21. actions/pre_commit/touch_empty_py/__init__.py +1 -0
  22. actions/pre_commit/touch_empty_py/cli.py +24 -0
  23. actions/pre_commit/touch_empty_py/constants.py +7 -0
  24. actions/pre_commit/touch_empty_py/lib.py +62 -0
  25. actions/pre_commit/touch_py_typed/__init__.py +1 -0
  26. actions/pre_commit/touch_py_typed/cli.py +24 -0
  27. actions/pre_commit/touch_py_typed/constants.py +7 -0
  28. actions/pre_commit/touch_py_typed/lib.py +72 -0
  29. actions/pre_commit/update_requirements/__init__.py +1 -0
  30. actions/pre_commit/update_requirements/classes.py +130 -0
  31. actions/pre_commit/update_requirements/cli.py +24 -0
  32. actions/pre_commit/update_requirements/constants.py +7 -0
  33. actions/pre_commit/update_requirements/lib.py +140 -0
  34. actions/pre_commit/utilities.py +386 -0
  35. actions/publish_package/cli.py +7 -19
  36. actions/publish_package/constants.py +7 -0
  37. actions/publish_package/lib.py +3 -3
  38. actions/py.typed +0 -0
  39. actions/random_sleep/cli.py +6 -15
  40. actions/random_sleep/constants.py +7 -0
  41. actions/register_gitea_runner/__init__.py +1 -0
  42. actions/register_gitea_runner/cli.py +32 -0
  43. actions/register_gitea_runner/configs/config.yml +110 -0
  44. actions/register_gitea_runner/configs/entrypoint.sh +23 -0
  45. actions/register_gitea_runner/constants.py +23 -0
  46. actions/register_gitea_runner/lib.py +289 -0
  47. actions/register_gitea_runner/settings.py +33 -0
  48. actions/run_hooks/cli.py +3 -15
  49. actions/run_hooks/constants.py +7 -0
  50. actions/run_hooks/lib.py +2 -2
  51. actions/setup_cronjob/cli.py +0 -12
  52. actions/setup_cronjob/constants.py +5 -1
  53. actions/tag_commit/cli.py +7 -19
  54. actions/tag_commit/constants.py +7 -0
  55. actions/tag_commit/lib.py +8 -8
  56. actions/types.py +4 -1
  57. actions/utilities.py +68 -14
  58. {dycw_actions-0.6.4.dist-info → dycw_actions-0.7.7.dist-info}/METADATA +5 -3
  59. dycw_actions-0.7.7.dist-info/RECORD +84 -0
  60. actions/format_requirements/cli.py +0 -37
  61. actions/format_requirements/lib.py +0 -121
  62. actions/publish_package/doc.py +0 -6
  63. actions/random_sleep/doc.py +0 -6
  64. actions/replace_sequence_strs/cli.py +0 -37
  65. actions/run_hooks/doc.py +0 -6
  66. actions/tag_commit/doc.py +0 -6
  67. dycw_actions-0.6.4.dist-info/RECORD +0 -56
  68. /actions/{conformalize_repo → pre_commit}/__init__.py +0 -0
  69. /actions/{format_requirements → pre_commit/conformalize_repo}/__init__.py +0 -0
  70. /actions/{conformalize_repo → pre_commit/conformalize_repo}/configs/gitignore +0 -0
  71. /actions/{replace_sequence_strs → pre_commit/format_requirements}/__init__.py +0 -0
  72. {dycw_actions-0.6.4.dist-info → dycw_actions-0.7.7.dist-info}/WHEEL +0 -0
  73. {dycw_actions-0.6.4.dist-info → dycw_actions-0.7.7.dist-info}/entry_points.txt +0 -0
actions/utilities.py CHANGED
@@ -1,14 +1,20 @@
1
1
  from __future__ import annotations
2
2
 
3
- from typing import TYPE_CHECKING, Literal, assert_never, overload
3
+ from io import StringIO
4
+ from pathlib import Path
5
+ from typing import TYPE_CHECKING, Any, Literal, assert_never, overload
4
6
 
5
7
  from typed_settings import EnvLoader, Secret
8
+ from utilities.atomicwrites import writer
6
9
  from utilities.subprocess import run
7
10
 
11
+ from actions.constants import YAML_INSTANCE
8
12
  from actions.logging import LOGGER
9
13
 
10
14
  if TYPE_CHECKING:
11
- from utilities.types import StrStrMapping
15
+ from collections.abc import MutableSet
16
+
17
+ from utilities.types import PathLike, StrStrMapping
12
18
 
13
19
  from actions.types import SecretLike
14
20
 
@@ -16,6 +22,10 @@ if TYPE_CHECKING:
16
22
  LOADER = EnvLoader("")
17
23
 
18
24
 
25
+ def are_equal_modulo_new_line(x: str, y: str, /) -> bool:
26
+ return ensure_new_line(x) == ensure_new_line(y)
27
+
28
+
19
29
  def convert_list_strs(
20
30
  x: str | list[str] | tuple[str, ...] | None, /
21
31
  ) -> list[str] | None:
@@ -60,51 +70,95 @@ def convert_str(x: str | None, /) -> str | None:
60
70
  assert_never(never)
61
71
 
62
72
 
73
+ def copy_text(
74
+ src: PathLike, dest: PathLike, /, *, modifications: MutableSet[Path] | None = None
75
+ ) -> None:
76
+ LOGGER.info("Copying '%s' -> '%s'...", str(src), str(dest))
77
+ text = Path(src).read_text()
78
+ write_text(dest, text, modifications=modifications)
79
+
80
+
81
+ def ensure_new_line(text: str, /) -> str:
82
+ return text.strip("\n") + "\n"
83
+
84
+
63
85
  @overload
64
- def log_run(
86
+ def logged_run(
65
87
  cmd: SecretLike,
66
88
  /,
67
- *cmds: SecretLike,
89
+ *cmds_or_args: SecretLike,
68
90
  env: StrStrMapping | None = None,
69
91
  print: bool = False,
70
92
  return_: Literal[True],
71
93
  ) -> str: ...
72
94
  @overload
73
- def log_run(
95
+ def logged_run(
74
96
  cmd: SecretLike,
75
97
  /,
76
- *cmds: SecretLike,
98
+ *cmds_or_args: SecretLike,
77
99
  env: StrStrMapping | None = None,
78
100
  print: bool = False,
79
101
  return_: Literal[False] = False,
80
102
  ) -> None: ...
81
103
  @overload
82
- def log_run(
104
+ def logged_run(
83
105
  cmd: SecretLike,
84
106
  /,
85
- *cmds: SecretLike,
107
+ *cmds_or_args: SecretLike,
86
108
  env: StrStrMapping | None = None,
87
109
  print: bool = False,
88
110
  return_: bool = False,
89
111
  ) -> str | None: ...
90
- def log_run(
112
+ def logged_run(
91
113
  cmd: SecretLike,
92
114
  /,
93
- *cmds: SecretLike,
115
+ *cmds_or_args: SecretLike,
94
116
  env: StrStrMapping | None = None,
95
117
  print: bool = False, # noqa: A002
96
118
  return_: bool = False,
97
119
  ) -> str | None:
98
- all_cmds = [cmd, *cmds]
99
- LOGGER.info("Running '%s'...", " ".join(map(str, all_cmds)))
100
- unwrapped = [c if isinstance(c, str) else c.get_secret_value() for c in all_cmds]
120
+ cmds_and_args = [cmd, *cmds_or_args]
121
+ LOGGER.info("Running '%s'...", " ".join(map(str, cmds_and_args)))
122
+ unwrapped: list[str] = []
123
+ for ca in cmds_and_args:
124
+ match ca:
125
+ case Secret():
126
+ unwrapped.append(ca.get_secret_value())
127
+ case str():
128
+ unwrapped.append(ca)
129
+ case never:
130
+ assert_never(never)
101
131
  return run(*unwrapped, env=env, print=print, return_=return_, logger=LOGGER)
102
132
 
103
133
 
134
+ def write_text(
135
+ path: PathLike, text: str, /, *, modifications: MutableSet[Path] | None = None
136
+ ) -> None:
137
+ LOGGER.info("Writing '%s'...", str(path))
138
+ with writer(path, overwrite=True) as temp:
139
+ _ = temp.write_text(ensure_new_line(text))
140
+ if modifications is not None:
141
+ modifications.add(Path(path))
142
+
143
+
144
+ def yaml_dump(obj: Any, /) -> str:
145
+ stream = StringIO()
146
+ YAML_INSTANCE.dump(obj, stream)
147
+ return stream.getvalue()
148
+
149
+
150
+ ##
151
+
152
+
104
153
  __all__ = [
105
154
  "LOADER",
155
+ "are_equal_modulo_new_line",
106
156
  "convert_list_strs",
107
157
  "convert_secret_str",
108
158
  "convert_str",
109
- "log_run",
159
+ "copy_text",
160
+ "ensure_new_line",
161
+ "logged_run",
162
+ "write_text",
163
+ "yaml_dump",
110
164
  ]
@@ -1,15 +1,17 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: dycw-actions
3
- Version: 0.6.4
3
+ Version: 0.7.7
4
4
  Summary: Library of actions
5
5
  Requires-Dist: click>=8.3.1,<9
6
- Requires-Dist: dycw-utilities>=0.176.3,<1
6
+ Requires-Dist: dycw-utilities>=0.178.0,<1
7
7
  Requires-Dist: inflect>=7.5.0,<8
8
8
  Requires-Dist: libcst>=1.8.6,<2
9
9
  Requires-Dist: packaging>=25.0,<26
10
+ Requires-Dist: pydantic>=2.12.5,<3
10
11
  Requires-Dist: pyyaml>=6.0.3,<7
12
+ Requires-Dist: requests>=2.32.5,<3
11
13
  Requires-Dist: rich>=14.2.0,<15
12
- Requires-Dist: ruamel-yaml>=0.19.0,<1
14
+ Requires-Dist: ruamel-yaml>=0.19.1,<1
13
15
  Requires-Dist: tomlkit>=0.13.3,<1
14
16
  Requires-Dist: typed-settings[attrs,click]>=25.3.0,<26
15
17
  Requires-Dist: xdg-base-dirs>=6.0.2,<7
@@ -0,0 +1,84 @@
1
+ actions/__init__.py,sha256=trsIPKwrk3xNHIWvYXX9uhHoJTOvGbfIIBQNFcFa_Js,58
2
+ actions/action_dicts/__init__.py,sha256=U4S_2y3zgLZVfMenHRaJFBW8yqh2mUBuI291LGQVOJ8,35
3
+ actions/action_dicts/constants.py,sha256=tYYLr3aRRRvnR6NSADOJMN-B6gtqg2A9gBuheEPyGy4,189
4
+ actions/action_dicts/lib.py,sha256=MpK_y5Jao0-3p6bWeYX5QQy3-JjMxwyzXRU5LjO25Iw,5547
5
+ actions/clean_dir/__init__.py,sha256=U4S_2y3zgLZVfMenHRaJFBW8yqh2mUBuI291LGQVOJ8,35
6
+ actions/clean_dir/cli.py,sha256=OrFA2nEN2LyGF22mhTNEBr7KSuKgX54sGy9RyE73qUc,569
7
+ actions/clean_dir/constants.py,sha256=aDNaYtemEv3lcMXo96Oh4pw_HASMby1GZC1D_gbjPAc,167
8
+ actions/clean_dir/lib.py,sha256=7_-QbvB9Bq2veEl4eYWkBBWN0jSNrjGVlx1gLWS1PwU,1606
9
+ actions/clean_dir/settings.py,sha256=mqM0Oq-yz4dXKcUi3JmOCvDhoeBNQm_Qe70cGmhdcQE,345
10
+ actions/cli.py,sha256=J9k7_BQzgDHdgzkTqwXVzncRMHm0eAT0WW_c_gAUFlE,4441
11
+ actions/constants.py,sha256=DgcgYPL3l2lAMIVRi7LzB_YsD0H8WDhaMphh5ztRD54,445
12
+ actions/logging.py,sha256=rMTcQMGndUHTCaXXtyOHt_VXUMhQGRHoN7okpoX0y5I,120
13
+ actions/pre_commit/__init__.py,sha256=U4S_2y3zgLZVfMenHRaJFBW8yqh2mUBuI291LGQVOJ8,35
14
+ actions/pre_commit/click.py,sha256=BLHjkO0gIW7rgLabuWnszwXmI4yb8Li5D8gt81GR-FQ,270
15
+ actions/pre_commit/conformalize_repo/__init__.py,sha256=U4S_2y3zgLZVfMenHRaJFBW8yqh2mUBuI291LGQVOJ8,35
16
+ actions/pre_commit/conformalize_repo/cli.py,sha256=rPrxobdo4sKnq0de_UWDtrHqlhF6GTAabRhw_1XBeZY,3063
17
+ actions/pre_commit/conformalize_repo/configs/gitignore,sha256=8YCRPwysCD8-67yFXaTg6O8TTl4xeNIh7_DVmaU5Ix0,5063
18
+ actions/pre_commit/conformalize_repo/constants.py,sha256=7WMbc1BwkVPJIf3eh3MaCoWj5A7pSPvNic28nrFTcoA,2148
19
+ actions/pre_commit/conformalize_repo/lib.py,sha256=cdEggEXiDTt2QHbzP0rIViFriPoaApf3XcGeAo-hiHY,48020
20
+ actions/pre_commit/conformalize_repo/settings.py,sha256=Oz2AeStS64DFzT1HKJ888_7tiU1TdJIGBarvyKYfp4E,4985
21
+ actions/pre_commit/constants.py,sha256=NBJ5GBMg5qhMAhAfxx1FKw0CdPwW_wG2cUJJ0dkF5HE,158
22
+ actions/pre_commit/format_requirements/__init__.py,sha256=U4S_2y3zgLZVfMenHRaJFBW8yqh2mUBuI291LGQVOJ8,35
23
+ actions/pre_commit/format_requirements/cli.py,sha256=c9UdOFDLEei5AEzrVvo6FopIEOf2EqyOliA-bOR5a2o,584
24
+ actions/pre_commit/format_requirements/constants.py,sha256=ly41jgwq0VVyHQqHaIXRc5ZmbWrNY_C3ET4G9gtE7rI,228
25
+ actions/pre_commit/format_requirements/lib.py,sha256=AGgtJ-4fBesv-BSFYExLu5rcLV6hfElVk1IxNtCXIAs,1399
26
+ actions/pre_commit/replace_sequence_strs/__init__.py,sha256=U4S_2y3zgLZVfMenHRaJFBW8yqh2mUBuI291LGQVOJ8,35
27
+ actions/pre_commit/replace_sequence_strs/cli.py,sha256=S8T-p0ex5lLmJz-5G7xDwPYnrwV82mf8UtwWtLIr36E,594
28
+ actions/pre_commit/replace_sequence_strs/constants.py,sha256=yEEgJUpw3URzv8Cb4nIgBY2xAzEfJIF6yzyUy6K55J4,250
29
+ actions/pre_commit/replace_sequence_strs/lib.py,sha256=FzfwYeL3bhTCYbb1T-Yk1NtdH3SFNKFC2x0JgdT4bXA,2166
30
+ actions/pre_commit/touch_empty_py/__init__.py,sha256=U4S_2y3zgLZVfMenHRaJFBW8yqh2mUBuI291LGQVOJ8,35
31
+ actions/pre_commit/touch_empty_py/cli.py,sha256=s2S5OfAGcSLtd2aGm1ooa1k20oNK-LQ1PZWz6T30vO8,559
32
+ actions/pre_commit/touch_empty_py/constants.py,sha256=zSwH60zfn9RhIAbBFnXjHrm2s1nFpPUskX3CZuJpQLk,198
33
+ actions/pre_commit/touch_empty_py/lib.py,sha256=jxT6CRZ3rrBatk3o-D0xDXon3a-G02sCvdMSNuRvCv0,1706
34
+ actions/pre_commit/touch_py_typed/__init__.py,sha256=U4S_2y3zgLZVfMenHRaJFBW8yqh2mUBuI291LGQVOJ8,35
35
+ actions/pre_commit/touch_py_typed/cli.py,sha256=CDJV4NuUHJlSdJ84dY0XvdwYHMdqygZ7C6x07B-iN3E,559
36
+ actions/pre_commit/touch_py_typed/constants.py,sha256=kLZOm_wgypp7MaXRYq-6AZqVE4OttOMKmUqt11V2zn0,191
37
+ actions/pre_commit/touch_py_typed/lib.py,sha256=8crPXxI6CwudW13RIJrn3YtrFcZsspyJnTmNRHz4TaU,2020
38
+ actions/pre_commit/update_requirements/__init__.py,sha256=U4S_2y3zgLZVfMenHRaJFBW8yqh2mUBuI291LGQVOJ8,35
39
+ actions/pre_commit/update_requirements/classes.py,sha256=ERC70c1CxQ3rOsQaEtp6FGbK_VaJ4K0jAV5XTB5-L30,3486
40
+ actions/pre_commit/update_requirements/cli.py,sha256=CBfm8M7hwSRw8KS6ttiNE86IFHJ52V42AxlfakqTDN0,584
41
+ actions/pre_commit/update_requirements/constants.py,sha256=ve44_RYed_41ckgQNPkb08u7Y1cpLpzutGSL9FdGBF8,228
42
+ actions/pre_commit/update_requirements/lib.py,sha256=akSmdqFpDS8ETsdGs4-8lfoKOp_8bBlKyKUXhUlrzpg,4619
43
+ actions/pre_commit/utilities.py,sha256=L1HCi3l778REPfomMuYbxrrnCn0FDRFaWAfmFR0lsTY,11422
44
+ actions/publish_package/__init__.py,sha256=U4S_2y3zgLZVfMenHRaJFBW8yqh2mUBuI291LGQVOJ8,35
45
+ actions/publish_package/cli.py,sha256=nAPHCq67mxUb3yHepVGcoQ69qgaQahM1-cxdbHfxQg0,803
46
+ actions/publish_package/constants.py,sha256=C68ZCVL_jVlYdLGpOK6saZccWoFy5AmC_NMBIWYdYOE,209
47
+ actions/publish_package/lib.py,sha256=WSGpXtZsTWL5tkoih4VTKLvtX6B8KmsO1jolT83S22A,1754
48
+ actions/publish_package/settings.py,sha256=UucS_yb-es9bDz0EPeWTIql6B1Dr4kcaEMdXpt23BNQ,935
49
+ actions/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
50
+ actions/random_sleep/__init__.py,sha256=U4S_2y3zgLZVfMenHRaJFBW8yqh2mUBuI291LGQVOJ8,35
51
+ actions/random_sleep/cli.py,sha256=-d9y63oWgvQtNp9j_8v3zt5gKl-GrUq8-b3Ky52R42c,693
52
+ actions/random_sleep/constants.py,sha256=5GMqCD1f12uyKDVTZBbnDDn6TQa99mUYZb9p-crg5BA,190
53
+ actions/random_sleep/lib.py,sha256=JzgpeEONdKXSBeNc3ex9goVyJR3bsa76lB_tkH1Ggc0,1762
54
+ actions/random_sleep/settings.py,sha256=F8gO2j2EEX8moemwhWWCPdRuOpZ_qLtqzSfWhjIy3P8,529
55
+ actions/register_gitea_runner/__init__.py,sha256=U4S_2y3zgLZVfMenHRaJFBW8yqh2mUBuI291LGQVOJ8,35
56
+ actions/register_gitea_runner/cli.py,sha256=70RUyzKCZHxyDRMFwCAwDC0LDsUZxBi2T6ctzbFlpc8,1129
57
+ actions/register_gitea_runner/configs/config.yml,sha256=0kpaqAjMRDqdSxkSK8ydOk2IsrlkB4cUkYmbkHAurrg,5683
58
+ actions/register_gitea_runner/configs/entrypoint.sh,sha256=IN40hAu8ufyyFWPIgsX_hWp0ZZZ0c36czCaqmECjBrw,476
59
+ actions/register_gitea_runner/constants.py,sha256=wX1f5qvhIXngBVWbIQRoIaXIdPaUByvG8HS8P0WcCGM,694
60
+ actions/register_gitea_runner/lib.py,sha256=V_K6UHmZOD9V-DF6ZNA2QakNyuyuyjgJZ6AJQFf37lQ,8832
61
+ actions/register_gitea_runner/settings.py,sha256=0UQm8M3qDiBE3jiE333M4FdLjikNAzpc9gk_VlzI0s8,1149
62
+ actions/run_hooks/__init__.py,sha256=U4S_2y3zgLZVfMenHRaJFBW8yqh2mUBuI291LGQVOJ8,35
63
+ actions/run_hooks/cli.py,sha256=xKBw6iIlHpUlHl6-QWQLSL6KKVjnsihBeJ7h58Rl8P4,616
64
+ actions/run_hooks/constants.py,sha256=JRhDk08qbzo5C-zwHdXZV5ajvNSKh4GcOcBvOIY6IGU,172
65
+ actions/run_hooks/lib.py,sha256=a-eUOtgTouxJYCsLRjsPIXl6nP58T2RB4jhr-Hhz0Sg,2850
66
+ actions/run_hooks/settings.py,sha256=XbQe1j1oEvDnbl4H6B-YEY6Ms6qlsj-N2XSJhdVHCWA,606
67
+ actions/setup_cronjob/__init__.py,sha256=U4S_2y3zgLZVfMenHRaJFBW8yqh2mUBuI291LGQVOJ8,35
68
+ actions/setup_cronjob/cli.py,sha256=l6t2WjCUprACV0rY8kHvpHLt3LgMI4q2XY4AEOiutkk,891
69
+ actions/setup_cronjob/configs/cron.tmpl,sha256=UD_d0LYlB6tbkXAcUTzpGDWVNgIhCR45Jgky91iSCP8,412
70
+ actions/setup_cronjob/configs/logrotate.tmpl,sha256=kkMuCRe4l03er6cFmRI0CXerHYmDumnMXLGKBjXLVxo,137
71
+ actions/setup_cronjob/constants.py,sha256=CNebyWFymrXBx3X9X7XXpU9PSd5wzUN6XkUVomSBnWQ,301
72
+ actions/setup_cronjob/lib.py,sha256=p6ndCc4e01pS-aLK_Qqn26qSto9krt26cOR23m4YiYg,3411
73
+ actions/setup_cronjob/settings.py,sha256=SxSe25f0sHUgq2-xdJN6rbbaSVFQE7FuEisiO_fmZNw,990
74
+ actions/tag_commit/__init__.py,sha256=U4S_2y3zgLZVfMenHRaJFBW8yqh2mUBuI291LGQVOJ8,35
75
+ actions/tag_commit/cli.py,sha256=1E6cM0XKTCt_Ukb7pxqOojHpJjoa63dVBO6DXoESe9Q,745
76
+ actions/tag_commit/constants.py,sha256=ceOvQpY4dgtJSd7v_jI1V00S0SjRq2ToGeZu41-DL7M,176
77
+ actions/tag_commit/lib.py,sha256=rq1SqAkNp98cPsNOsFY4F1D6nNi7N3wqVbFPno8lsuI,1849
78
+ actions/tag_commit/settings.py,sha256=TOeKG_GODP--2lBSyGzH_M32jDIfh4vk_Ts06R3_ak4,629
79
+ actions/types.py,sha256=GRXLoJtYWmRjgfatDDRMcXKZkN9ZtK1Fi2MEyAZ84uk,591
80
+ actions/utilities.py,sha256=VpFLBiAezgSRlm9dvnyPyQohreaV2Lv7cJ9HAxqZ4WI,4086
81
+ dycw_actions-0.7.7.dist-info/WHEEL,sha256=KSLUh82mDPEPk0Bx0ScXlWL64bc8KmzIPNcpQZFV-6E,79
82
+ dycw_actions-0.7.7.dist-info/entry_points.txt,sha256=2Uu7wAZOm0mmcsGBEsGB370HAWgVWECRFJ9rKgfC3-I,46
83
+ dycw_actions-0.7.7.dist-info/METADATA,sha256=CORF-XquPdSrUKd4Doo9mV0OA8RmDHzyWwZUMXgtC8E,654
84
+ dycw_actions-0.7.7.dist-info/RECORD,,
@@ -1,37 +0,0 @@
1
- from __future__ import annotations
2
-
3
- from pathlib import Path
4
-
5
- import click
6
- from click import argument
7
- from utilities.logging import basic_config
8
- from utilities.os import is_pytest
9
- from utilities.text import strip_and_dedent
10
-
11
- from actions import __version__
12
- from actions.format_requirements.lib import format_requirements
13
- from actions.logging import LOGGER
14
-
15
-
16
- @argument(
17
- "paths",
18
- nargs=-1,
19
- type=click.Path(exists=True, file_okay=True, dir_okay=False, path_type=Path),
20
- )
21
- def format_requirements_sub_cmd(*, paths: tuple[Path, ...]) -> None:
22
- if is_pytest():
23
- return
24
- basic_config(obj=LOGGER)
25
- LOGGER.info(
26
- strip_and_dedent("""
27
- Running '%s' (version %s) with settings:
28
- - paths = %s
29
- """),
30
- format_requirements.__name__,
31
- __version__,
32
- paths,
33
- )
34
- format_requirements(*paths)
35
-
36
-
37
- __all__ = ["format_requirements_sub_cmd"]
@@ -1,121 +0,0 @@
1
- from __future__ import annotations
2
-
3
- import sys
4
- from pathlib import Path
5
- from typing import TYPE_CHECKING, Any, override
6
-
7
- from packaging._tokenizer import ParserSyntaxError
8
- from packaging.requirements import InvalidRequirement, Requirement, _parse_requirement
9
- from packaging.specifiers import Specifier, SpecifierSet
10
- from tomlkit import TOMLDocument, array, dumps, loads, string
11
- from tomlkit.items import Array, Table
12
- from utilities.text import repr_str, strip_and_dedent
13
-
14
- from actions import __version__
15
- from actions.logging import LOGGER
16
-
17
- if TYPE_CHECKING:
18
- from collections.abc import Iterator
19
-
20
- from utilities.types import PathLike
21
-
22
-
23
- _MODIFICATIONS: set[Path] = set()
24
-
25
-
26
- def format_requirements(*paths: PathLike) -> None:
27
- LOGGER.info(
28
- strip_and_dedent("""
29
- Running '%s' (version %s) with settings:
30
- - paths = %s
31
- """),
32
- format_requirements.__name__,
33
- __version__,
34
- paths,
35
- )
36
- for path in paths:
37
- _format_path(path)
38
- if len(_MODIFICATIONS) >= 1:
39
- LOGGER.info(
40
- "Exiting due to modifications: %s",
41
- ", ".join(map(repr_str, sorted(_MODIFICATIONS))),
42
- )
43
- sys.exit(1)
44
-
45
-
46
- def _format_path(path: PathLike, /) -> None:
47
- path = Path(path)
48
- current = loads(path.read_text())
49
- expected = _get_formatted(path)
50
- is_equal = current == expected # tomlkit cannot handle !=
51
- if not is_equal:
52
- _ = path.write_text(dumps(expected).rstrip("\n") + "\n")
53
- _MODIFICATIONS.add(path)
54
-
55
-
56
- def _get_formatted(path: PathLike, /) -> TOMLDocument:
57
- path = Path(path)
58
- doc = loads(path.read_text())
59
- if isinstance(dep_grps := doc.get("dependency-groups"), Table):
60
- for key, value in dep_grps.items():
61
- if isinstance(value, Array):
62
- dep_grps[key] = _format_array(value)
63
- if isinstance(project := doc["project"], Table):
64
- if isinstance(deps := project["dependencies"], Array):
65
- project["dependencies"] = _format_array(deps)
66
- if isinstance(optional := project.get("optional-dependencies"), Table):
67
- for key, value in optional.items():
68
- if isinstance(value, Array):
69
- optional[key] = _format_array(value)
70
- return doc
71
-
72
-
73
- def _format_array(dependencies: Array, /) -> Array:
74
- new = array().multiline(multiline=True)
75
- new.extend(map(_format_item, dependencies))
76
- return new
77
-
78
-
79
- def _format_item(item: Any, /) -> Any:
80
- if not isinstance(item, str):
81
- return item
82
- return string(str(_CustomRequirement(item)))
83
-
84
-
85
- class _CustomRequirement(Requirement):
86
- @override
87
- def __init__(self, requirement_string: str) -> None:
88
- super().__init__(requirement_string)
89
- try:
90
- parsed = _parse_requirement(requirement_string)
91
- except ParserSyntaxError as e:
92
- raise InvalidRequirement(str(e)) from e
93
- self.specifier = _CustomSpecifierSet(parsed.specifier)
94
-
95
- @override
96
- def _iter_parts(self, name: str) -> Iterator[str]:
97
- yield name
98
- if self.extras:
99
- formatted_extras = ",".join(sorted(self.extras))
100
- yield f"[{formatted_extras}]"
101
- if self.specifier:
102
- yield f" {self.specifier}"
103
- if self.url:
104
- yield f"@ {self.url}"
105
- if self.marker:
106
- yield " "
107
- if self.marker:
108
- yield f"; {self.marker}"
109
-
110
-
111
- class _CustomSpecifierSet(SpecifierSet):
112
- @override
113
- def __str__(self) -> str:
114
- specs = sorted(self._specs, key=self._key)
115
- return ", ".join(map(str, specs))
116
-
117
- def _key(self, spec: Specifier, /) -> int:
118
- return [">=", "<"].index(spec.operator)
119
-
120
-
121
- __all__ = ["format_requirements"]
@@ -1,6 +0,0 @@
1
- from __future__ import annotations
2
-
3
- DOCSTRING = "Build and publish the package"
4
-
5
-
6
- __all__ = ["DOCSTRING"]
@@ -1,6 +0,0 @@
1
- from __future__ import annotations
2
-
3
- DOCSTRING = "Random sleep with logging"
4
-
5
-
6
- __all__ = ["DOCSTRING"]
@@ -1,37 +0,0 @@
1
- from __future__ import annotations
2
-
3
- from pathlib import Path
4
-
5
- import click
6
- from click import argument
7
- from utilities.logging import basic_config
8
- from utilities.os import is_pytest
9
- from utilities.text import strip_and_dedent
10
-
11
- from actions import __version__
12
- from actions.logging import LOGGER
13
- from actions.replace_sequence_strs.lib import replace_sequence_strs
14
-
15
-
16
- @argument(
17
- "paths",
18
- nargs=-1,
19
- type=click.Path(exists=True, file_okay=True, dir_okay=False, path_type=Path),
20
- )
21
- def sequence_strs_sub_cmd(*, paths: tuple[Path, ...]) -> None:
22
- if is_pytest():
23
- return
24
- basic_config(obj=LOGGER)
25
- LOGGER.info(
26
- strip_and_dedent("""
27
- Running '%s' (version %s) with settings:
28
- - paths = %s
29
- """),
30
- replace_sequence_strs.__name__,
31
- __version__,
32
- paths,
33
- )
34
- replace_sequence_strs(*paths)
35
-
36
-
37
- __all__ = ["sequence_strs_sub_cmd"]
actions/run_hooks/doc.py DELETED
@@ -1,6 +0,0 @@
1
- from __future__ import annotations
2
-
3
- DOCSTRING = "Run 'pre-commit' hooks"
4
-
5
-
6
- __all__ = ["DOCSTRING"]
actions/tag_commit/doc.py DELETED
@@ -1,6 +0,0 @@
1
- from __future__ import annotations
2
-
3
- DOCSTRING = "Tag the latest commit"
4
-
5
-
6
- __all__ = ["DOCSTRING"]
@@ -1,56 +0,0 @@
1
- actions/__init__.py,sha256=mcL5eixWYUyfOx2GXC_AEe0GPlGaIobkG5nOgff8q_8,58
2
- actions/action_dicts/__init__.py,sha256=U4S_2y3zgLZVfMenHRaJFBW8yqh2mUBuI291LGQVOJ8,35
3
- actions/action_dicts/constants.py,sha256=tYYLr3aRRRvnR6NSADOJMN-B6gtqg2A9gBuheEPyGy4,189
4
- actions/action_dicts/lib.py,sha256=5qtDFe3yuYkCKBbGMDTiljzmptB41D7SbZxQjxngTqg,5461
5
- actions/clean_dir/__init__.py,sha256=U4S_2y3zgLZVfMenHRaJFBW8yqh2mUBuI291LGQVOJ8,35
6
- actions/clean_dir/cli.py,sha256=rLD6s_xND4gI3SunDv0x0O26aD7r29sZox9BzTLOFls,895
7
- actions/clean_dir/lib.py,sha256=s8FdQBd9-PVmPixWFRmpcK6oOHrdutIxtsCSf1N1Tws,1577
8
- actions/clean_dir/settings.py,sha256=mqM0Oq-yz4dXKcUi3JmOCvDhoeBNQm_Qe70cGmhdcQE,345
9
- actions/cli.py,sha256=PG3ZptwRUlO986dEZVDkgnkyoKxYtj0uzF0eVnNu8sI,2030
10
- actions/conformalize_repo/__init__.py,sha256=U4S_2y3zgLZVfMenHRaJFBW8yqh2mUBuI291LGQVOJ8,35
11
- actions/conformalize_repo/cli.py,sha256=gyEq22d8yCh_1LjGrcVV036s6--3G521aRLuruTmYUw,3375
12
- actions/conformalize_repo/configs/gitignore,sha256=8YCRPwysCD8-67yFXaTg6O8TTl4xeNIh7_DVmaU5Ix0,5063
13
- actions/conformalize_repo/constants.py,sha256=r8bi7QQckhzd-uJgHoAy04x_qTPt0ocSFXsEVxxmrcg,1961
14
- actions/conformalize_repo/lib.py,sha256=Txob9thmmeqJz1eH7W3f8f-4x4LZ_5mwA11FlKTsurk,53140
15
- actions/conformalize_repo/settings.py,sha256=uCCIrDEdPpP_SvVgQlJ-1KtQmB3T_CTsVykYx898328,4974
16
- actions/constants.py,sha256=SO0SBwEW8Wn5Uzt95OvlwTctyH0K7uvXMnNf1uCkrxk,212
17
- actions/format_requirements/__init__.py,sha256=U4S_2y3zgLZVfMenHRaJFBW8yqh2mUBuI291LGQVOJ8,35
18
- actions/format_requirements/cli.py,sha256=AyG-J2udPO92hH7-p_M2tInSllxM74WrR2ttz7iODbo,908
19
- actions/format_requirements/lib.py,sha256=ovZAolTQQAAMVabBxyWNuY13ENp8-vRnRt1ymFurVhQ,3709
20
- actions/logging.py,sha256=rMTcQMGndUHTCaXXtyOHt_VXUMhQGRHoN7okpoX0y5I,120
21
- actions/publish_package/__init__.py,sha256=U4S_2y3zgLZVfMenHRaJFBW8yqh2mUBuI291LGQVOJ8,35
22
- actions/publish_package/cli.py,sha256=J4RWGM6jYLCFJ38eLkzf0w_dmH5VFUS2zQi3P0Qf62M,1147
23
- actions/publish_package/doc.py,sha256=wQ4Dktc78r5CTlqHi-LycXTKdyJqUPpI5r-YYabNCMw,106
24
- actions/publish_package/lib.py,sha256=gZBbeCE45hCIvjaV5Pg7LBscBAYj2feoH4cz5TFg2wA,1745
25
- actions/publish_package/settings.py,sha256=UucS_yb-es9bDz0EPeWTIql6B1Dr4kcaEMdXpt23BNQ,935
26
- actions/random_sleep/__init__.py,sha256=U4S_2y3zgLZVfMenHRaJFBW8yqh2mUBuI291LGQVOJ8,35
27
- actions/random_sleep/cli.py,sha256=z8ZrB8bKbxZ6JI7ypG1Ob3yVr0nNvU9T_XkM5u3XHUI,996
28
- actions/random_sleep/doc.py,sha256=mmMYy8XbeiuyMACzq8uYru7FqlDZToMTdubblM2cKAY,102
29
- actions/random_sleep/lib.py,sha256=JzgpeEONdKXSBeNc3ex9goVyJR3bsa76lB_tkH1Ggc0,1762
30
- actions/random_sleep/settings.py,sha256=F8gO2j2EEX8moemwhWWCPdRuOpZ_qLtqzSfWhjIy3P8,529
31
- actions/replace_sequence_strs/__init__.py,sha256=U4S_2y3zgLZVfMenHRaJFBW8yqh2mUBuI291LGQVOJ8,35
32
- actions/replace_sequence_strs/cli.py,sha256=XSGTTLBOpbwtfFZLTv31pUlD07yoEJfNXRrptiTOs84,904
33
- actions/replace_sequence_strs/lib.py,sha256=F1YFX9nrcMWnfvDtnx4jEXIHiX7LgB3vQGfjOQsjKXA,2260
34
- actions/run_hooks/__init__.py,sha256=U4S_2y3zgLZVfMenHRaJFBW8yqh2mUBuI291LGQVOJ8,35
35
- actions/run_hooks/cli.py,sha256=mDbUBC1BEwfbyJ-vp-7vBqjtQ2AjPioYSaAi3FAL9Fk,944
36
- actions/run_hooks/doc.py,sha256=DPE1g-sJ_7jhffHZA6sIsCRUvkVPpTxRm4UM42XK8hU,99
37
- actions/run_hooks/lib.py,sha256=8brWxMn333eVzjHn2-hCTm6ca8tnyD_dQQqPc7rFqTY,2844
38
- actions/run_hooks/settings.py,sha256=XbQe1j1oEvDnbl4H6B-YEY6Ms6qlsj-N2XSJhdVHCWA,606
39
- actions/setup_cronjob/__init__.py,sha256=U4S_2y3zgLZVfMenHRaJFBW8yqh2mUBuI291LGQVOJ8,35
40
- actions/setup_cronjob/cli.py,sha256=Hb-4SiWGV5S18YAOK7_rc1SmHEM-z-Zg0qNSPlCmh4U,1221
41
- actions/setup_cronjob/configs/cron.tmpl,sha256=UD_d0LYlB6tbkXAcUTzpGDWVNgIhCR45Jgky91iSCP8,412
42
- actions/setup_cronjob/configs/logrotate.tmpl,sha256=kkMuCRe4l03er6cFmRI0CXerHYmDumnMXLGKBjXLVxo,137
43
- actions/setup_cronjob/constants.py,sha256=lq3snzPD7HPGqo0j7Mdjz-Di9sHCaWOslZjZptM6UC0,163
44
- actions/setup_cronjob/lib.py,sha256=p6ndCc4e01pS-aLK_Qqn26qSto9krt26cOR23m4YiYg,3411
45
- actions/setup_cronjob/settings.py,sha256=SxSe25f0sHUgq2-xdJN6rbbaSVFQE7FuEisiO_fmZNw,990
46
- actions/tag_commit/__init__.py,sha256=U4S_2y3zgLZVfMenHRaJFBW8yqh2mUBuI291LGQVOJ8,35
47
- actions/tag_commit/cli.py,sha256=IB3xE-eS6lX41zL4lr8hdIU6KMp1rO0b4OQuleiGtEc,1052
48
- actions/tag_commit/doc.py,sha256=sY4orbkesFLTdfW4xJIE2bU1wQU-mWAYGU7k1nwMgec,98
49
- actions/tag_commit/lib.py,sha256=MklNv3A3yy5RrOABhJQQJVi_rIbM_R3gVPf1ULMDTKQ,1825
50
- actions/tag_commit/settings.py,sha256=TOeKG_GODP--2lBSyGzH_M32jDIfh4vk_Ts06R3_ak4,629
51
- actions/types.py,sha256=sCMcl4ukOD9ct6hf-m6KAM6ZypdVZ32K1s_W6NxKdyQ,431
52
- actions/utilities.py,sha256=lzfDRBwhGYsLAN__r6vnxSkpUINdQVf6Hclz6Q-jCGM,2606
53
- dycw_actions-0.6.4.dist-info/WHEEL,sha256=KSLUh82mDPEPk0Bx0ScXlWL64bc8KmzIPNcpQZFV-6E,79
54
- dycw_actions-0.6.4.dist-info/entry_points.txt,sha256=2Uu7wAZOm0mmcsGBEsGB370HAWgVWECRFJ9rKgfC3-I,46
55
- dycw_actions-0.6.4.dist-info/METADATA,sha256=pjDIBgx3QZwt2Pg5LLUmos1ZlrmG1hswxcqdY_9uC68,584
56
- dycw_actions-0.6.4.dist-info/RECORD,,
File without changes