1- import collections
1+ import functools
22import json
33import multiprocessing
44import os .path
88from typing import Dict
99from typing import Tuple
1010
11- import aspy . yaml
11+ import yaml
1212from pre_commit .clientlib import load_manifest
1313
14+ Loader = getattr (yaml , 'CSafeLoader' , yaml .SafeLoader )
15+ fast_load = functools .partial (yaml .load , Loader = Loader )
16+
1417
1518def get_manifest (repo_path : str ) -> Tuple [str , Dict [str , Any ]]:
1619 print (f'*** { repo_path } ' )
@@ -21,13 +24,16 @@ def get_manifest(repo_path: str) -> Tuple[str, Dict[str, Any]]:
2124 manifest_path = os .path .join (repo_dir , '.pre-commit-hooks.yaml' )
2225 # Validate the manifest just to make sure it's ok.
2326 load_manifest (manifest_path )
24- return (repo_path , aspy .yaml .ordered_load (open (manifest_path )))
27+ with open (manifest_path ) as f :
28+ return repo_path , fast_load (f )
2529
2630
2731def main () -> int :
28- repos = aspy .yaml .ordered_load (open ('all-repos.yaml' ))
32+ with open ('all-repos.yaml' ) as f :
33+ repos = fast_load (f )
34+
2935 pool = multiprocessing .Pool (4 )
30- hooks_json = collections . OrderedDict (pool .map (get_manifest , repos ))
36+ hooks_json = dict (pool .map (get_manifest , repos ))
3137
3238 with open ('all-hooks.json' , 'w' ) as hooks_json_file :
3339 json .dump (hooks_json , hooks_json_file , indent = 4 )
0 commit comments