22from pathlib import Path
33import requests
44import json
5- from os import environ
65from zipfile import ZipFile
76from typing import Any
87from pydantic import BaseModel
@@ -36,6 +35,12 @@ class Config:
3635 extra = "forbid"
3736
3837
38+ class TaskGroupReadV2 (BaseModel ):
39+ pkg_name : str
40+ version : Optional [str ] = None
41+ task_list : list [TaskReadV2 ]
42+
43+
3944def parse_wheel_filename (wheel_path : str ) -> dict [str , str ]:
4045 """
4146 Given a wheel-file name or path, extract distribution and version.
@@ -210,12 +215,12 @@ def _get_task_type(
210215 if not (source .startswith ("#" ) or source == "" )
211216]
212217
213- TASKS = []
218+ TASK_GROUPS = []
214219for source in sources :
215220 t_start = time .perf_counter ()
216221 print (f"START processing { source = } " )
217222 try :
218- new_tasks = []
223+ task_list = []
219224 data = get_package_info (source )
220225 pkg_name = data ["name" ]
221226 pkg_version = data .get ("version" )
@@ -229,16 +234,26 @@ def _get_task_type(
229234 new_task ["version" ] = pkg_version
230235 new_task ["type" ] = _get_task_type (task )
231236 TaskReadV2 (** new_task )
232- new_tasks .append (new_task )
237+ task_list .append (new_task )
238+
239+ task_group = dict (
240+ pkg_name = pkg_name ,
241+ version = pkg_version ,
242+ task_list = task_list ,
243+ )
233244 except Exception as e :
234245 print (f"ERROR, skip.\n Original error:\n { str (e )} " )
235- TASKS .extend (new_tasks )
246+
247+ TaskGroupReadV2 (** task_group )
248+
249+ TASK_GROUPS .append (task_group )
250+
236251 t_end = time .perf_counter ()
237252 print (f"END processing { source = } - elapsed { t_end - t_start :.3f} s." )
238253 print ()
239254
240255output_file = Path (__file__ ).parent / "tasks_data.json"
241256with output_file .open ("w" ) as f :
242- json .dump (TASKS , f , indent = 2 )
257+ json .dump (TASK_GROUPS , f , indent = 2 )
243258
244259DOWNLOAD_FOLDER .rmdir ()
0 commit comments