winipedia-utils 0.4.46__py3-none-any.whl → 0.4.53__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.
Potentially problematic release.
This version of winipedia-utils might be problematic. Click here for more details.
- winipedia_utils/git/github/workflows/base/base.py +49 -2
- winipedia_utils/git/github/workflows/health_check.py +1 -0
- winipedia_utils/modules/package.py +15 -4
- {winipedia_utils-0.4.46.dist-info → winipedia_utils-0.4.53.dist-info}/METADATA +3 -2
- {winipedia_utils-0.4.46.dist-info → winipedia_utils-0.4.53.dist-info}/RECORD +7 -7
- {winipedia_utils-0.4.46.dist-info → winipedia_utils-0.4.53.dist-info}/WHEEL +0 -0
- {winipedia_utils-0.4.46.dist-info → winipedia_utils-0.4.53.dist-info}/licenses/LICENSE +0 -0
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
from abc import abstractmethod
|
|
4
4
|
from pathlib import Path
|
|
5
|
-
from typing import Any
|
|
5
|
+
from typing import Any, ClassVar
|
|
6
6
|
|
|
7
7
|
import winipedia_utils
|
|
8
8
|
from winipedia_utils.modules.module import make_obj_importpath
|
|
@@ -15,6 +15,37 @@ from winipedia_utils.text.string import split_on_uppercase
|
|
|
15
15
|
class Workflow(YamlConfigFile):
|
|
16
16
|
"""Base class for workflows."""
|
|
17
17
|
|
|
18
|
+
EMPTY_CONFIG: ClassVar[dict[str, Any]] = {
|
|
19
|
+
"on": {
|
|
20
|
+
"workflow_dispatch": {},
|
|
21
|
+
},
|
|
22
|
+
"jobs": {
|
|
23
|
+
"empty": {
|
|
24
|
+
"runs-on": "ubuntu-latest",
|
|
25
|
+
"steps": [
|
|
26
|
+
{
|
|
27
|
+
"name": "Empty Step",
|
|
28
|
+
"run": "echo 'Empty Step'",
|
|
29
|
+
}
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@classmethod
|
|
36
|
+
def is_correct(cls) -> bool:
|
|
37
|
+
"""Check if the config is correct.
|
|
38
|
+
|
|
39
|
+
Needs some special handling since workflow files cannot be empty.
|
|
40
|
+
We need a workflow that will never trigger and even if doesnt do anything.
|
|
41
|
+
"""
|
|
42
|
+
correct = super().is_correct()
|
|
43
|
+
if cls.get_path().read_text() == "":
|
|
44
|
+
# dump a dispatch in there for on and an empty job for jobs
|
|
45
|
+
cls.dump(cls.EMPTY_CONFIG)
|
|
46
|
+
|
|
47
|
+
return correct or cls.load() == cls.EMPTY_CONFIG
|
|
48
|
+
|
|
18
49
|
@classmethod
|
|
19
50
|
@abstractmethod
|
|
20
51
|
def get_workflow_triggers(cls) -> dict[str, Any]:
|
|
@@ -113,7 +144,7 @@ class Workflow(YamlConfigFile):
|
|
|
113
144
|
return step
|
|
114
145
|
|
|
115
146
|
@classmethod
|
|
116
|
-
def get_poetry_setup_steps(
|
|
147
|
+
def get_poetry_setup_steps( # noqa: PLR0913
|
|
117
148
|
cls,
|
|
118
149
|
*,
|
|
119
150
|
install_dependencies: bool = False,
|
|
@@ -121,6 +152,7 @@ class Workflow(YamlConfigFile):
|
|
|
121
152
|
configure_pipy_token: bool = False,
|
|
122
153
|
force_main_head: bool = False,
|
|
123
154
|
token: bool = False,
|
|
155
|
+
with_keyring: bool = False,
|
|
124
156
|
) -> list[dict[str, Any]]:
|
|
125
157
|
"""Get the poetry steps.
|
|
126
158
|
|
|
@@ -132,6 +164,7 @@ class Workflow(YamlConfigFile):
|
|
|
132
164
|
equal to the most recent commit on main. This is useful for workflows that
|
|
133
165
|
should only run on main.
|
|
134
166
|
token: Whether to use the repository token.
|
|
167
|
+
with_keyring: Whether to setup the keyring.
|
|
135
168
|
|
|
136
169
|
Returns:
|
|
137
170
|
The poetry steps.
|
|
@@ -161,6 +194,7 @@ class Workflow(YamlConfigFile):
|
|
|
161
194
|
"run": "curl -sSL https://install.python-poetry.org | python3 -",
|
|
162
195
|
}
|
|
163
196
|
)
|
|
197
|
+
|
|
164
198
|
if configure_pipy_token:
|
|
165
199
|
steps.append(
|
|
166
200
|
{
|
|
@@ -168,8 +202,13 @@ class Workflow(YamlConfigFile):
|
|
|
168
202
|
"run": "poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }}",
|
|
169
203
|
}
|
|
170
204
|
)
|
|
205
|
+
|
|
171
206
|
if install_dependencies:
|
|
172
207
|
steps.append({"name": "Install Dependencies", "run": "poetry install"})
|
|
208
|
+
|
|
209
|
+
if with_keyring:
|
|
210
|
+
steps.append(cls.get_setup_keyring_step())
|
|
211
|
+
|
|
173
212
|
return steps
|
|
174
213
|
|
|
175
214
|
@classmethod
|
|
@@ -243,6 +282,14 @@ class Workflow(YamlConfigFile):
|
|
|
243
282
|
"run": "git commit --no-verify -m '[skip ci] CI/CD: Committing possible added changes (e.g.: pyproject.toml and poetry.lock)'", # noqa: E501
|
|
244
283
|
}
|
|
245
284
|
|
|
285
|
+
@classmethod
|
|
286
|
+
def get_setup_keyring_step(cls) -> dict[str, Any]:
|
|
287
|
+
"""Get the setup keyring step."""
|
|
288
|
+
return {
|
|
289
|
+
"name": "Setup CI keyring",
|
|
290
|
+
"run": """poetry run pip install keyrings.alt && poetry run python -c "import keyring; from keyrings.alt.file import PlaintextKeyring; keyring.set_keyring(PlaintextKeyring()); keyring.set_password('video_vault','ci_user','ci-secret-token'); print('Keyring OK:', keyring.get_password('video_vault','ci_user'))" """, # noqa: E501
|
|
291
|
+
}
|
|
292
|
+
|
|
246
293
|
@classmethod
|
|
247
294
|
def get_protect_repository_step(cls) -> dict[str, Any]:
|
|
248
295
|
"""Get the protect repository step."""
|
|
@@ -447,7 +447,7 @@ class DependencyGraph(nx.DiGraph): # type: ignore [type-arg]
|
|
|
447
447
|
def build(self) -> None:
|
|
448
448
|
"""Build the graph from installed Python distributions."""
|
|
449
449
|
for dist in importlib.metadata.distributions():
|
|
450
|
-
name =
|
|
450
|
+
name = self.parse_distname_from_metadata(dist)
|
|
451
451
|
self.add_node(name)
|
|
452
452
|
|
|
453
453
|
requires = dist.requires or []
|
|
@@ -456,14 +456,24 @@ class DependencyGraph(nx.DiGraph): # type: ignore [type-arg]
|
|
|
456
456
|
if dep:
|
|
457
457
|
self.add_edge(name, dep) # package → dependency
|
|
458
458
|
|
|
459
|
+
@staticmethod
|
|
460
|
+
def parse_distname_from_metadata(dist: importlib.metadata.Distribution) -> str:
|
|
461
|
+
"""Extract the distribution name from its metadata."""
|
|
462
|
+
# replace - with _ to handle packages like winipedia-utils
|
|
463
|
+
name: str = dist.metadata["Name"]
|
|
464
|
+
return DependencyGraph.normalize_package_name(name)
|
|
465
|
+
|
|
466
|
+
@staticmethod
|
|
467
|
+
def normalize_package_name(name: str) -> str:
|
|
468
|
+
"""Normalize a package name."""
|
|
469
|
+
return name.lower().replace("-", "_").strip()
|
|
470
|
+
|
|
459
471
|
@staticmethod
|
|
460
472
|
def parse_pkg_name_from_req(req: str) -> str | None:
|
|
461
473
|
"""Extract the bare dependency name from a requirement string."""
|
|
462
|
-
if not req:
|
|
463
|
-
return None
|
|
464
474
|
# split on the first non alphanumeric character like >, <, =, etc.
|
|
465
475
|
dep = re.split(r"[^a-zA-Z0-9]", req.strip())[0].strip()
|
|
466
|
-
return
|
|
476
|
+
return DependencyGraph.normalize_package_name(dep) if dep else None
|
|
467
477
|
|
|
468
478
|
def get_all_depending_on(
|
|
469
479
|
self, package: ModuleType, *, include_self: bool = False
|
|
@@ -477,6 +487,7 @@ class DependencyGraph(nx.DiGraph): # type: ignore [type-arg]
|
|
|
477
487
|
Returns:
|
|
478
488
|
A set of imported module objects representing dependents.
|
|
479
489
|
"""
|
|
490
|
+
# replace - with _ to handle packages like winipedia-utils
|
|
480
491
|
target = package.__name__.lower()
|
|
481
492
|
if target not in self:
|
|
482
493
|
msg = f"Package '{target}' not found in dependency graph"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: winipedia-utils
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.53
|
|
4
4
|
Summary: A package with many utility functions
|
|
5
5
|
License-Expression: MIT
|
|
6
6
|
License-File: LICENSE
|
|
@@ -79,7 +79,8 @@ git clone https://github.com/owner/repo.git
|
|
|
79
79
|
poetry init # or poetry new
|
|
80
80
|
# 4: Poetry will ask you some stuff when you run poetry init.
|
|
81
81
|
# First author name must be equal to the GitHub repository owner (username).
|
|
82
|
-
# The repository name must be equal to the package/project name.
|
|
82
|
+
# The repository name must be equal to the package/project name.
|
|
83
|
+
# (- instead of _ is fine, but only as the project name in pyproject.toml, folder names should all be _)
|
|
83
84
|
|
|
84
85
|
# 5: Add winipedia-utils to your project
|
|
85
86
|
poetry add winipedia-utils
|
|
@@ -16,8 +16,8 @@ winipedia_utils/git/github/repo/protect.py,sha256=nOVjb5GVinGIClp7k9_qqgKnAl_gk1
|
|
|
16
16
|
winipedia_utils/git/github/repo/repo.py,sha256=OqoOfqDhe_Iik71dNqi4h3fGrMno33hSjk0bpNg3eZk,7865
|
|
17
17
|
winipedia_utils/git/github/workflows/__init__.py,sha256=BPdntTwFEyBMJ6MyT7gddPHswvRdH9tsRtfK72VSV7Y,57
|
|
18
18
|
winipedia_utils/git/github/workflows/base/__init__.py,sha256=XHsbmjiaGom-KX-S3leCY9cJD3aP9p_0X6xYMcdkHBU,23
|
|
19
|
-
winipedia_utils/git/github/workflows/base/base.py,sha256=
|
|
20
|
-
winipedia_utils/git/github/workflows/health_check.py,sha256=
|
|
19
|
+
winipedia_utils/git/github/workflows/base/base.py,sha256=4MAHU_oPqicwO7tZE0B99RK9ZKRMFIZhUYkWr1NrYqo,11405
|
|
20
|
+
winipedia_utils/git/github/workflows/health_check.py,sha256=pjGZckvfPHuR6QepHia6_FKcwUQAXuhGGVaVCpLQNaY,1614
|
|
21
21
|
winipedia_utils/git/github/workflows/publish.py,sha256=TPbSp5QH2vVl55UdqE_kjf1HIkdubcgqWlkLjWFX5EA,1378
|
|
22
22
|
winipedia_utils/git/github/workflows/release.py,sha256=hnMT12J17LmFpPCTzva-lW95MOFDQ-1bAOrTVCxeaR8,1301
|
|
23
23
|
winipedia_utils/git/gitignore/__init__.py,sha256=k-2E26JaZPkF69UUOJkpQl8T_PudrC7EYCIOxwgIQVU,57
|
|
@@ -37,7 +37,7 @@ winipedia_utils/modules/__init__.py,sha256=e3CFaC3FhK4ibknFOv1bqOZxA7XeVwmLqWX7o
|
|
|
37
37
|
winipedia_utils/modules/class_.py,sha256=908MgZZzcJBPmlVmMPZCFssHnRzbQYOQlrF3GQhpWm4,5411
|
|
38
38
|
winipedia_utils/modules/function.py,sha256=cjD6dXkZzhtCClUs4uiOLaDOURVASp64iwTwXmI3ICo,3217
|
|
39
39
|
winipedia_utils/modules/module.py,sha256=s48epfMHKjEgEHRO7rGICIX0JaXppOfst2uT-jLQM6M,13766
|
|
40
|
-
winipedia_utils/modules/package.py,sha256=
|
|
40
|
+
winipedia_utils/modules/package.py,sha256=9PMCsUzOAaJBGtqeMIYRTUyFG2DWdT_obg8a4FfCahI,17983
|
|
41
41
|
winipedia_utils/oop/__init__.py,sha256=wGjsVwLbTVEQWOfDJvN9nlvC-3NmAi8Doc2xIrm6e78,47
|
|
42
42
|
winipedia_utils/oop/mixins/__init__.py,sha256=PDK-cJcdRUfDUCz36qQ5pmMW07G133WtN49OpmILGNI,54
|
|
43
43
|
winipedia_utils/oop/mixins/meta.py,sha256=0G4CzzzCoeP1Eas3vWe-uxvB5n5ncyw7Wc-sI9zmEBc,11150
|
|
@@ -88,7 +88,7 @@ winipedia_utils/testing/tests/conftest.py,sha256=BLgUJtLecOwuEsIyJ__0buqovd5AhiG
|
|
|
88
88
|
winipedia_utils/text/__init__.py,sha256=j2bwtK6kyeHI6SnoBjpRju0C1W2n2paXBDlNjNtaUxA,48
|
|
89
89
|
winipedia_utils/text/config.py,sha256=BPpuD4ywzzzt6Jz2M5Eln5d1NLlDp4r7CPwQOgHkxcg,7782
|
|
90
90
|
winipedia_utils/text/string.py,sha256=yXmwOab5hXyVQG1NwlWDpy2prj0U7Vb2F5HKLT2Y77Q,3382
|
|
91
|
-
winipedia_utils-0.4.
|
|
92
|
-
winipedia_utils-0.4.
|
|
93
|
-
winipedia_utils-0.4.
|
|
94
|
-
winipedia_utils-0.4.
|
|
91
|
+
winipedia_utils-0.4.53.dist-info/METADATA,sha256=dHVCIWf2JB02S9ZNLS0WWKMjr_oH6kgudHrU682IrZo,14694
|
|
92
|
+
winipedia_utils-0.4.53.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
|
|
93
|
+
winipedia_utils-0.4.53.dist-info/licenses/LICENSE,sha256=o316mE2gGzd__JT69p7S_zlOmKiHh8YjpImCCcWyTvM,1066
|
|
94
|
+
winipedia_utils-0.4.53.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|