Skip to content

Commit 3cd64c9

Browse files
Fix json gen and minor improvements
1 parent 737b24d commit 3cd64c9

File tree

5 files changed

+28
-26
lines changed

5 files changed

+28
-26
lines changed

completion.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from functools import cache
44
from pathlib import Path
55
from tempfile import TemporaryDirectory
6-
from typing import Literal
6+
from typing import Literal, List
77

88
import git
99
from potodo import potodo
@@ -36,7 +36,7 @@ def get_completion(
3636
)
3737
except git.GitCommandError:
3838
print(f'failed to clone {repo} {branch}')
39-
translators_data = TranslatorsData(0, set(), False)
39+
translators_data = TranslatorsData(0, [], False)
4040
branch = ''
4141
continue
4242
else:
@@ -85,5 +85,5 @@ def get_completion(
8585
@dataclass(frozen=True)
8686
class TranslatorsData:
8787
number: int
88-
list: set
88+
list: List
8989
link: str | Literal[False]

generate.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def get_project_data(
6666
completion, translators_data, branch, change = get_completion(clones_dir, repo)
6767
else:
6868
completion = 0.0
69-
translators_data = TranslatorsData(0, set(), False)
69+
translators_data = TranslatorsData(0, [], False)
7070
change = 0.0
7171
branch = ''
7272

@@ -137,6 +137,7 @@ class LanguageProjectData:
137137
Path('build/logo.png').write_bytes(Path('src/logo.png').read_bytes())
138138
Path('build/index.html').write_text(index)
139139
Path('build/chart.html').write_text(chart)
140+
140141
Path('build/index.json').write_text(
141-
json.dumps(completion_progress, indent=2, default=asdict)
142+
json.dumps([asdict(project) for project in completion_progress], indent=2)
142143
)

templates/index.html.jinja

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,6 @@
2626
{% endfor %}
2727
</div>
2828
</div>
29+
30+
<p style="text-align: center;">Last updated at {{ generation_time.strftime('%A, %-d %B %Y, %-H:%M:%S %Z') }} (in {{ duration // 60 }}:{{ "{:02}".format(duration % 60) }} minutes).</p>
2931
{% endblock %}

templates/language.html.jinja

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,27 @@
1717
<h6 style="text-align: center;">This project is not built yet.</h6>
1818
{% endif %}
1919

20-
<h4 style="text-align: center;">
21-
{% if project.translators.link %}
22-
<a href="{{ project.translators.link }}" style="color: #1595fe;">Contribute!</a>
23-
{% elif project.uses_platform %}
24-
<a href="https://app.transifex.com/join/?o=python-doc&p=python-newest&t=opensource" style="color: #1595fe;">Contribute!</a>
25-
{% else %}
26-
<a href="https://devguide.python.org/documentation/translations/translating/" style="color: #1595fe;">Contribute!</a>
27-
{% endif %}
28-
29-
<a href="https://github.com/{{ project.repository }}" style="color: #1595fe;">Repository</a>
30-
</h4>
20+
<h4 style="text-align: center;">
21+
{% if project.translators.link %}
22+
<a href="{{ project.translators.link }}" style="color: #1595fe;">Contribute!</a>
23+
{% elif project.uses_platform %}
24+
<a href="https://app.transifex.com/join/?o=python-doc&p=python-newest&t=opensource" style="color: #1595fe;">Contribute!</a>
25+
{% else %}
26+
<a href="https://devguide.python.org/documentation/translations/translating/" style="color: #1595fe;">Contribute!</a>
27+
{% endif %}
28+
29+
<a href="https://github.com/{{ project.repository }}" style="color: #1595fe;">Repository</a>
30+
</h4>
3131

32-
<div class="row">
33-
<div class="card-container w-100">
34-
<div class="card">
35-
<div class="card-body">
36-
<h3 class="card-title">Translators ({{ project.translators.number }})</h3>
37-
<h4 class="card-subtitle mb-2 text-muted">{{ project.translators.list | join(', ') }}</h4>
32+
<div class="row">
33+
<div class="card-container w-100">
34+
<div class="card">
35+
<div class="card-body">
36+
<h3 class="card-title">Translators ({{ project.translators.number }})</h3>
37+
<h4 class="card-subtitle mb-2 text-muted">{{ project.translators.list | join(', ') }}</h4>
38+
</div>
3839
</div>
3940
</div>
4041
</div>
4142
</div>
42-
43-
</div>
4443
{% endblock %}

translators.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ def _format_translator(translator: str) -> str:
1313
return sub(r'<.*?>', '', translator).strip()
1414

1515

16-
def get_number(path: Path) -> tuple[set, int]:
16+
def get_number(path: Path) -> tuple[list, int]:
1717
from_po_headers = set(yield_from_headers(path))
1818
from_git_history = set(get_from_git_history(path))
1919
from_translators_file = set(get_from_translators_file(path))
2020
largest_set = max(from_po_headers, from_git_history, from_translators_file)
21-
return largest_set, len(largest_set)
21+
return list(largest_set), len(largest_set)
2222

2323

2424
def get_from_git_history(path: Path) -> list[str]:

0 commit comments

Comments
 (0)