|
8 | 8 | # "docutils",
|
9 | 9 | # ]
|
10 | 10 | # ///
|
| 11 | +import concurrent.futures |
| 12 | +import itertools |
11 | 13 | import subprocess
|
12 | 14 | from collections.abc import Iterator
|
13 | 15 | from dataclasses import dataclass
|
@@ -46,30 +48,44 @@ def get_completion_progress() -> Iterator['LanguageProjectData']:
|
46 | 48 | subprocess.run(['make', '-C', cpython_dir / 'Doc', 'venv'], check=True)
|
47 | 49 | subprocess.run(['make', '-C', cpython_dir / 'Doc', 'gettext'], check=True)
|
48 | 50 | languages_built = dict(build_status.get_languages(session := Session()))
|
49 |
| - for language, repo in get_languages_and_repos(devguide_dir): |
50 |
| - built = language.code in languages_built |
51 |
| - if repo: |
52 |
| - completion, translators_data = get_completion(clones_dir, repo) |
53 |
| - visitors_num = ( |
54 |
| - get_number_of_visitors(language.code, session) if built else 0 |
55 |
| - ) |
56 |
| - else: |
57 |
| - completion = 0.0 |
58 |
| - translators_data = TranslatorsData(0, False) |
59 |
| - visitors_num = 0 |
60 |
| - yield LanguageProjectData( |
61 |
| - language, |
62 |
| - repo, |
63 |
| - completion, |
64 |
| - translators_data, |
65 |
| - visitors_num, |
66 |
| - built, |
67 |
| - in_switcher=languages_built.get(language.code), |
68 |
| - uses_platform=language.code in contribute.pulling_from_transifex, |
69 |
| - contribution_link=contribute.get_contrib_link(language.code, repo), |
| 51 | + with concurrent.futures.ThreadPoolExecutor() as executor: |
| 52 | + return executor.map( |
| 53 | + get_project_data, |
| 54 | + *zip(*get_languages_and_repos(devguide_dir)), |
| 55 | + itertools.repeat(languages_built), |
| 56 | + itertools.repeat(clones_dir), |
| 57 | + itertools.repeat(session), |
70 | 58 | )
|
71 | 59 |
|
72 | 60 |
|
| 61 | +def get_project_data( |
| 62 | + language: Language, |
| 63 | + repo: str, |
| 64 | + languages_built: dict[str, bool], |
| 65 | + clones_dir: str, |
| 66 | + session: Session, |
| 67 | +) -> 'LanguageProjectData': |
| 68 | + built = language.code in languages_built |
| 69 | + if repo: |
| 70 | + completion, translators_data = get_completion(clones_dir, repo) |
| 71 | + visitors_num = get_number_of_visitors(language.code, session) if built else 0 |
| 72 | + else: |
| 73 | + completion = 0.0 |
| 74 | + translators_data = TranslatorsData(0, False) |
| 75 | + visitors_num = 0 |
| 76 | + return LanguageProjectData( |
| 77 | + language, |
| 78 | + repo, |
| 79 | + completion, |
| 80 | + translators_data, |
| 81 | + visitors_num, |
| 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 | + |
73 | 89 | @dataclass(frozen=True)
|
74 | 90 | class LanguageProjectData:
|
75 | 91 | language: Language
|
|
0 commit comments