Spaces:
Build error
Build error
| """ | |
| Module which builds a dictionary keyed by issue number from a json file | |
| """ | |
| import argparse | |
| import json | |
| def build_json_file(input_filename, output_filename): | |
| with open(input_filename, "r") as f: | |
| json_lines = f.readlines() | |
| issues = [json.loads(line) for line in json_lines] | |
| json_dict = {issue["number"]: issue for issue in issues} | |
| with open(output_filename, "w") as f: | |
| json.dump(json_dict, f, indent=4) | |
| if __name__ == "__main__": | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument("--input_filename", type=str, default="issues.json") | |
| parser.add_argument("--output_filename", type=str, default="issues_dict.json") | |
| args = parser.parse_args() | |
| build_json_file(**vars(args)) | |