import argparse import json if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument("inputfile") parser.add_argument("--dataset_id", type=str) parser.add_argument("outputfile") args = parser.parse_args() datasette_metadata = None with open(args.inputfile, 'r') as f_in: datasette_metadata = json.load(f_in) source_url = 'https://www.gbif.org/resource/search?contentType=literature&gbifDatasetKey={}'.format(args.dataset_id) datasette_metadata['source_url'] = source_url datasette_metadata_json = json.dumps(datasette_metadata, indent=4) with open(args.outputfile, 'w') as f_out: f_out.write(datasette_metadata_json)