[docs]defmain(args:argparse.Namespace)->None:file_format=args.formatsearch_dir=args.search_diroutput_file=args.output_filedata_design_fps=list(search_dir.rglob("**/data_design.json"))data_designs=[json.loads(fp.read_text())forfpindata_design_fps]design_dirs=[fp.parentforfpindata_design_fps]data_hls_fps=[design_dir/"data_hls.json"fordesign_dirindesign_dirs]data_hls=[json.loads(fp.read_text())forfpindata_hls_fps]data=[]fordata_design,data_hls_singleinzip(data_designs,data_hls,strict=False):data.append({**data_design,**data_hls_single})# code to handle differnt data files with different sets of keysdata_dfs=[]foridx,dinenumerate(data):df_single=pd.DataFrame(d,index=[idx])data_dfs.append(df_single)df_combined=pd.concat(data_dfs)iffile_format==FileFormat.CSV:df_combined.to_csv(output_file,index=False)iffile_format==FileFormat.JSON:df_combined.to_json(output_file,orient="records",indent=4)iffile_format==FileFormat.SQLITE:raiseNotImplementedError("sqlite output not implemented yet")
if__name__=="__main__":parser=argparse.ArgumentParser()parser.add_argument("-f","--format",type=FileFormat,choices=list(FileFormat),default=FileFormat.JSON,help="Output file format",)parser.add_argument("search_dir",type=Path,help="Directory to search for generated HLS data",)parser.add_argument("output_file",type=Path,help="Output file to write the aggregated data to",)args=parser.parse_args()main(args)