Skip to content

Publish JSON format #54

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- uses: actions/checkout@v4
- run: sudo apt-get install -y gettext
- run: uv run generate.py # generates "index.html"
- run: mkdir -p build && cp index.html style.css build
- run: mkdir -p build && cp index.* style.css build
- name: Deploy 🚀
if: github.event_name != 'pull_request'
uses: JamesIves/github-pages-deploy-action@v4
Expand Down
4 changes: 2 additions & 2 deletions completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def branches_from_devguide(devguide_dir: Path) -> list[str]:
]


def get_completion(clones_dir: str, repo: str) -> tuple[float, 'TranslatorsData']:
def get_completion(clones_dir: str, repo: str) -> tuple[float, 'TranslatorsData', str]:
clone_path = Path(clones_dir, repo)
for branch in branches_from_devguide(Path(clones_dir, 'devguide')) + ['master']:
try:
Expand All @@ -44,7 +44,7 @@ def get_completion(clones_dir: str, repo: str) -> tuple[float, 'TranslatorsData'
hide_reserved=False,
api_url='',
).completion
return completion, translators_data
return completion, translators_data, branch


@dataclass(frozen=True)
Expand Down
13 changes: 10 additions & 3 deletions generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
# "docutils",
# ]
# ///
import json
import concurrent.futures
import itertools
import logging
import subprocess
from collections.abc import Iterator
from dataclasses import dataclass
from dataclasses import dataclass, asdict
from datetime import datetime, timezone
from pathlib import Path
from tempfile import TemporaryDirectory
Expand Down Expand Up @@ -48,6 +49,7 @@ def get_completion_progress() -> Iterator['LanguageProjectData']:
subprocess.run(['make', '-C', cpython_dir / 'Doc', 'venv'], check=True)
subprocess.run(['make', '-C', cpython_dir / 'Doc', 'gettext'], check=True)
languages_built = dict(build_status.get_languages(http := PoolManager()))

with concurrent.futures.ThreadPoolExecutor() as executor:
return executor.map(
get_project_data,
Expand All @@ -67,7 +69,7 @@ def get_project_data(
) -> 'LanguageProjectData':
built = language.code in languages_built
if repo:
completion, translators_data = get_completion(clones_dir, repo)
completion, translators_data, branch = get_completion(clones_dir, repo)
visitors_num = get_number_of_visitors(language.code, http) if built else 0
else:
completion = 0.0
Expand All @@ -76,6 +78,7 @@ def get_project_data(
return LanguageProjectData(
language,
repo,
branch,
completion,
translators_data,
visitors_num,
Expand All @@ -90,6 +93,7 @@ def get_project_data(
class LanguageProjectData:
language: Language
repository: str | None
branch: str
completion: float
translators: TranslatorsData
visitors: int
Expand All @@ -105,9 +109,12 @@ class LanguageProjectData:
template = Template(Path('template.html.jinja').read_text())

output = template.render(
completion_progress=list(get_completion_progress()),
completion_progress=(completion_progress := list(get_completion_progress())),
generation_time=generation_time,
duration=(datetime.now(timezone.utc) - generation_time).seconds,
)

Path('index.html').write_text(output)
Path('index.json').write_text(
json.dumps(completion_progress, indent=2, default=asdict)
)
Loading