Skip to content

Commit 46193b0

Browse files
committed
Merging workflow
2 parents 54d6d5d + 6859e25 commit 46193b0

File tree

4 files changed

+48
-8
lines changed

4 files changed

+48
-8
lines changed

completion.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from functools import cache
33
from pathlib import Path
44
from tempfile import TemporaryDirectory
5+
from typing import Literal
56

67
import git
78
from potodo import potodo
@@ -18,7 +19,9 @@ def branches_from_devguide(devguide_dir: Path) -> list[str]:
1819
]
1920

2021

21-
def get_completion(clones_dir: str, repo: str) -> tuple[float, int]:
22+
def get_completion(
23+
clones_dir: str, repo: str
24+
) -> tuple[float, int, str | Literal[False]]:
2225
clone_path = Path(clones_dir, repo)
2326
for branch in branches_from_devguide(Path(clones_dir, 'devguide')) + ['master']:
2427
try:
@@ -28,9 +31,11 @@ def get_completion(clones_dir: str, repo: str) -> tuple[float, int]:
2831
except git.GitCommandError:
2932
print(f'failed to clone {repo} {branch}')
3033
translators_number = 0
34+
translators_link: str | Literal[False] = False
3135
continue
3236
else:
3337
translators_number = translators.get_number(clone_path)
38+
translators_link = translators.get_link(clone_path, repo, branch)
3439
break
3540
with TemporaryDirectory() as tmpdir:
3641
completion = potodo.merge_and_scan_path(
@@ -40,4 +45,4 @@ def get_completion(clones_dir: str, repo: str) -> tuple[float, int]:
4045
hide_reserved=False,
4146
api_url='',
4247
).completion
43-
return completion, translators_number
48+
return completion, translators_number, translators_link

generate.py

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,18 @@
2929

3030
def get_completion_progress() -> (
3131
Iterator[
32-
tuple[str, str, float, int, int, bool, bool | None, bool, str | Literal[False]]
32+
tuple[
33+
str,
34+
str,
35+
float,
36+
int,
37+
str | Literal[False],
38+
int,
39+
bool,
40+
bool | None,
41+
bool,
42+
str | Literal[False],
43+
]
3344
]
3445
):
3546
with TemporaryDirectory() as clones_dir:
@@ -58,15 +69,27 @@ def get_completion_progress() -> (
5869
tx = lang in contribute.pulling_from_transifex
5970
contrib_link = contribute.get_contrib_link(lang)
6071
if not repo:
61-
yield lang, cast(str, repo), 0.0, 0, 0, built, in_switcher, False, False
72+
yield (
73+
lang,
74+
cast(str, repo),
75+
0.0,
76+
0,
77+
False,
78+
0,
79+
built,
80+
in_switcher,
81+
False,
82+
False,
83+
)
6284
continue
63-
completion, translators = get_completion(clones_dir, repo)
85+
completion, translators, translators_link = get_completion(clones_dir, repo)
6486
visitors_num = visitors.get_number_of_visitors(lang) if built else 0
6587
yield (
6688
lang,
6789
repo,
6890
completion,
6991
translators,
92+
translators_link,
7093
visitors_num,
7194
built,
7295
in_switcher,

template.html.jinja

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
</tr>
1818
</thead>
1919
<tbody>
20-
{% for language, repo, completion, translators, visitors, build, in_switcher, on_platform, contrib_link in completion_progress | sort(attribute='2,3') | reverse %}
20+
{% for language, repo, completion, translators, translators_link, visitors, build, in_switcher, on_platform, contrib_link in completion_progress | sort(attribute='2,3') | reverse %}
2121
<tr>
2222
{% if repo %}
2323
<td data-label="language">
@@ -46,10 +46,14 @@
4646
{{ '{:,}'.format(visitors) }}
4747
</a>
4848
{% else %}
49-
0
49+
{{ '{:,}'.format(visitors) }}
5050
{% endif %}
5151
</td>
52-
<td data-label="translators">{{ translators }}</td>
52+
<td data-label="translators">
53+
{% if translators_link %}<a href="{{ translators_link }}" target="_blank">{% endif %}
54+
{{ translators }}
55+
{% if translators_link %}</a>{% endif %}
56+
</td>
5357
<td data-label="completion">
5458
<div class="progress-bar" style="width: {{ completion | round(2) }}%;">{{ completion | round(2) }}%</div>
5559
</td>

translators.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from collections.abc import Iterator
22
from pathlib import Path
3+
from typing import Literal
34

45
from git import Repo
56
from polib import pofile
@@ -30,3 +31,10 @@ def yield_from_headers(path: Path) -> Iterator[str]:
3031
yield translator_record
3132
else:
3233
yield translator
34+
35+
36+
def get_link(clone_path: Path, repo: str, branch: str) -> str | Literal[False]:
37+
return (
38+
clone_path.joinpath('TRANSLATORS').exists()
39+
and f'https://github.com/{repo}/blob/{branch}/TRANSLATORS'
40+
)

0 commit comments

Comments
 (0)