File size: 711 Bytes
e6f931e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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)