1313import concurrent .futures
1414import itertools
1515import logging
16- import subprocess
1716from collections .abc import Iterator , Sequence
1817from datetime import datetime , timezone
1918from json import loads
2019from pathlib import Path
2120from sys import argv
22- from tempfile import TemporaryDirectory
2321
2422import dacite
25- import git
26- from git import Repo
2723from jinja2 import Template
2824from urllib3 import request
2925
3026import build_warnings
3127import sphinx_lint
32- from completion import branches_from_devguide
3328from generate import LanguageProjectData
3429from repositories import Language
3530
3934def get_projects_metadata (
4035 completion_progress : Sequence [LanguageProjectData ],
4136) -> Iterator [tuple [int , int ]]:
42- with TemporaryDirectory () as clones_dir :
43- Repo . clone_from (
44- 'https://github.com/python/devguide.git' ,
45- devguide_dir := Path ( clones_dir , 'devguide' ),
46- depth = 1 ,
37+ with concurrent . futures . ProcessPoolExecutor () as executor :
38+ return executor . map (
39+ get_metadata ,
40+ * zip ( * map ( get_language_repo_and_completion , completion_progress ) ),
41+ itertools . repeat ( Path ( 'clones' )) ,
4742 )
48- latest_branch = branches_from_devguide (devguide_dir )[0 ]
49- Repo .clone_from (
50- 'https://github.com/python/cpython.git' ,
51- cpython_dir := Path (clones_dir , 'cpython' ),
52- depth = 1 ,
53- branch = latest_branch ,
54- )
55- subprocess .run (['make' , '-C' , cpython_dir / 'Doc' , 'venv' ], check = True )
56- subprocess .run (['make' , '-C' , cpython_dir / 'Doc' , 'gettext' ], check = True )
57- with concurrent .futures .ProcessPoolExecutor () as executor :
58- return executor .map (
59- get_metadata ,
60- * zip (
61- * map (get_language_repo_branch_and_completion , completion_progress )
62- ),
63- itertools .repeat (clones_dir ),
64- )
6543
6644
6745def get_metadata (
68- language : Language ,
69- repo : str | None ,
70- branch : str | None ,
71- completion : float ,
72- clones_dir : str ,
46+ language : Language , repo : str | None , completion : float , clones_dir : str
7347) -> tuple [int , int ]:
74- if repo :
75- clone_path = Path (clones_dir , repo )
76- git .Repo .clone_from (f'https://github.com/{ repo } .git' , clone_path , branch = branch )
7748 return (
7849 repo
7950 and completion
@@ -84,10 +55,10 @@ def get_metadata(
8455 ) or (0 , 0 )
8556
8657
87- def get_language_repo_branch_and_completion (
58+ def get_language_repo_and_completion (
8859 project : LanguageProjectData ,
89- ) -> tuple [Language , str | None , str | None , float ]:
90- return project .language , project .repository , project .branch , project . completion
60+ ) -> tuple [Language , str | None , float ]:
61+ return project .language , project .repository , project .completion
9162
9263
9364if __name__ == '__main__' :
0 commit comments