#!/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 20.04 distro_version = '20.04' source_pkgs_filepath = './package_data/source_packages_remote_ubuntu_2004.default' 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_2004_source_package_version_history.data', 'w') as outfile: json.dump(json_arr, outfile, indent=4)