1616from dataclasses import dataclass , asdict
1717from datetime import datetime , timezone
1818from pathlib import Path
19- from tempfile import TemporaryDirectory
2019
2120from git import Repo
2221from jinja2 import Template
2322from urllib3 import PoolManager
2423
25- import contribute
2624import build_status
25+ import contribute
2726from completion import branches_from_devguide , get_completion , TranslatorsData
28- from repositories import get_languages_and_repos , Language
27+ from repositories import Language , get_languages_and_repos
2928
3029generation_time = datetime .now (timezone .utc )
3130
3231
3332def get_completion_progress () -> Iterator ['LanguageProjectData' ]:
34- with TemporaryDirectory () as clones_dir :
35- Repo .clone_from (
36- 'https://github.com/python/devguide.git' ,
37- devguide_dir := Path (clones_dir , 'devguide' ),
38- depth = 1 ,
39- )
40- latest_branch = branches_from_devguide (devguide_dir )[0 ]
41- Repo .clone_from (
42- 'https://github.com/python/cpython.git' ,
43- cpython_dir := Path (clones_dir , 'cpython' ),
44- depth = 1 ,
45- branch = latest_branch ,
46- )
47- subprocess .run (['make' , '-C' , cpython_dir / 'Doc' , 'venv' ], check = True )
48- subprocess .run (['make' , '-C' , cpython_dir / 'Doc' , 'gettext' ], check = True )
49- languages_built = dict (build_status .get_languages (http := PoolManager ()))
33+ clones_dir = Path ( 'clones' )
34+ Repo .clone_from (
35+ 'https://github.com/python/devguide.git' ,
36+ devguide_dir := Path (clones_dir , 'devguide' ),
37+ depth = 1 ,
38+ )
39+ latest_branch = branches_from_devguide (devguide_dir )[0 ]
40+ Repo .clone_from (
41+ 'https://github.com/python/cpython.git' ,
42+ cpython_dir := Path (clones_dir , 'cpython' ),
43+ depth = 1 ,
44+ branch = latest_branch ,
45+ )
46+ subprocess .run (['make' , '-C' , cpython_dir / 'Doc' , 'venv' ], check = True )
47+ subprocess .run (['make' , '-C' , cpython_dir / 'Doc' , 'gettext' ], check = True )
48+ languages_built = dict (build_status .get_languages (PoolManager ()))
5049
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 (http ),
58- )
50+ with concurrent .futures .ThreadPoolExecutor () as executor :
51+ return executor .map (
52+ get_project_data ,
53+ * zip (* get_languages_and_repos (devguide_dir )),
54+ itertools .repeat (languages_built ),
55+ itertools .repeat (clones_dir ),
56+ )
5957
6058
6159def get_project_data (
6260 language : Language ,
6361 repo : str | None ,
6462 languages_built : dict [str , bool ],
6563 clones_dir : str ,
66- http : PoolManager ,
6764) -> 'LanguageProjectData' :
6865 built = language .code in languages_built
6966 if repo :
@@ -72,7 +69,7 @@ def get_project_data(
7269 completion = 0.0
7370 translators_data = TranslatorsData (0 , False )
7471 change = 0.0
75- branch = None
72+ branch = ''
7673 return LanguageProjectData (
7774 language ,
7875 repo ,
@@ -91,7 +88,7 @@ def get_project_data(
9188class LanguageProjectData :
9289 language : Language
9390 repository : str | None
94- branch : str | None
91+ branch : str
9592 completion : float
9693 change : float
9794 translators : TranslatorsData
0 commit comments