#!/usr/bin/env python3 # export job that will use existing class code to export to json import json from package_version_history import PackageVersionHistory as pvh # start with just ubuntu 22.04 distro_version = '22.04' source_pkgs_filepath = './package_data/ubuntu_22.04_source_packages.container' source_file = open(source_pkgs_filepath, 'r') lines = source_file.readlines() results = [] for source_pkgname in lines: pkg = source_pkgname.strip() print(pkg) name_and_versions = pvh( pkg, distro_version).package_name_and_version_history() results.append(name_and_versions) print(name_and_versions) # create json of the results json_obj = json.dumps(results) json_arr = json.loads(json_obj) # write to a file with open('./version_history_data/ubuntu_latest_source_package_version_history.container', 'w') as outfile: json.dump(json_arr, outfile, indent=4)