|
12 | 12 | # /// |
13 | 13 | import subprocess |
14 | 14 | from collections.abc import Iterator |
| 15 | +from concurrent.futures import ThreadPoolExecutor |
15 | 16 | from dataclasses import dataclass |
16 | 17 | from datetime import datetime, timezone |
| 18 | +from itertools import repeat |
17 | 19 | from logging import info |
18 | 20 | from pathlib import Path |
19 | 21 | from tempfile import TemporaryDirectory |
@@ -48,31 +50,42 @@ def get_completion_progress() -> Iterator['LanguageProjectData']: |
48 | 50 | subprocess.run(['make', '-C', cpython_dir / 'Doc', 'venv'], check=True) |
49 | 51 | subprocess.run(['make', '-C', cpython_dir / 'Doc', 'gettext'], check=True) |
50 | 52 | languages_built = dict(build_status.get_languages()) |
51 | | - for language, repo in get_languages_and_repos(devguide_dir): |
52 | | - built = language.code in languages_built |
53 | | - if repo: |
54 | | - completion, translators_data = get_completion(clones_dir, repo) |
55 | | - visitors_num = get_number_of_visitors(language.code) if built else 0 |
56 | | - issues = build_warnings.number(clones_dir, repo, language.code) |
57 | | - else: |
58 | | - completion = 0.0 |
59 | | - translators_data = TranslatorsData(0, False) |
60 | | - visitors_num = 0 |
61 | | - issues = 0 |
62 | | - yield LanguageProjectData( |
63 | | - language, |
64 | | - repo, |
65 | | - completion, |
66 | | - translators_data, |
67 | | - visitors_num, |
68 | | - issues, |
69 | | - built, |
70 | | - in_switcher=languages_built.get(language.code), |
71 | | - uses_platform=language.code in contribute.pulling_from_transifex, |
72 | | - contribution_link=contribute.get_contrib_link(language.code, repo), |
| 53 | + with ThreadPoolExecutor() as executor: |
| 54 | + return executor.map( |
| 55 | + get_data, |
| 56 | + *zip(*get_languages_and_repos(devguide_dir)), |
| 57 | + repeat(languages_built), |
| 58 | + repeat(clones_dir), |
73 | 59 | ) |
74 | 60 |
|
75 | 61 |
|
| 62 | +def get_data( |
| 63 | + language: Language, repo: str, languages_built: dict[str, bool], clones_dir: str |
| 64 | +) -> 'LanguageProjectData': |
| 65 | + built = language.code in languages_built |
| 66 | + if repo: |
| 67 | + completion, translators_data = get_completion(clones_dir, repo) |
| 68 | + visitors_num = get_number_of_visitors(language.code) if built else 0 |
| 69 | + issues = build_warnings.number(clones_dir, repo, language.code) |
| 70 | + else: |
| 71 | + completion = 0.0 |
| 72 | + translators_data = TranslatorsData(0, False) |
| 73 | + visitors_num = 0 |
| 74 | + issues = 0 |
| 75 | + return LanguageProjectData( |
| 76 | + language, |
| 77 | + repo, |
| 78 | + completion, |
| 79 | + translators_data, |
| 80 | + visitors_num, |
| 81 | + issues, |
| 82 | + built, |
| 83 | + in_switcher=languages_built.get(language.code), |
| 84 | + uses_platform=language.code in contribute.pulling_from_transifex, |
| 85 | + contribution_link=contribute.get_contrib_link(language.code, repo), |
| 86 | + ) |
| 87 | + |
| 88 | + |
76 | 89 | @dataclass(frozen=True) |
77 | 90 | class LanguageProjectData: |
78 | 91 | language: Language |
|
0 commit comments