Nicky Nicolson commited on
Commit
4d96b32
1 Parent(s): 691c525

Added licence name

Browse files
Files changed (1) hide show
  1. getDownloadMetadata.py +8 -3
getDownloadMetadata.py CHANGED
@@ -2,6 +2,8 @@ import argparse
2
  from pygbif import occurrences as occ
3
  import json
4
 
 
 
5
  if __name__ == '__main__':
6
  parser = argparse.ArgumentParser()
7
  parser.add_argument("inputfile")
@@ -15,9 +17,12 @@ if __name__ == '__main__':
15
  datasette_metadata = json.load(f_in)
16
 
17
  gbif_metadata = occ.download_meta(key = args.download_id)
18
- datasette_metadata['licence'] = gbif_metadata['license']
19
- datasette_metadata['source_url'] = 'https://doi.org{}'.format(gbif_metadata['doi'])
 
 
 
20
 
21
- datasette_metadata_json = json.dumps(datasette_metadata)
22
  with open(args.outputfile, 'w') as f_out:
23
  f_out.write(datasette_metadata_json)
 
2
  from pygbif import occurrences as occ
3
  import json
4
 
5
+
6
+ licences = {'http://creativecommons.org/licenses/by-nc/4.0/legalcode':'CC BY-NC 4.0'}
7
  if __name__ == '__main__':
8
  parser = argparse.ArgumentParser()
9
  parser.add_argument("inputfile")
 
17
  datasette_metadata = json.load(f_in)
18
 
19
  gbif_metadata = occ.download_meta(key = args.download_id)
20
+ licence_url = gbif_metadata['license']
21
+ if licence_url in licences:
22
+ datasette_metadata['licence'] = licences[licence_url]
23
+ datasette_metadata['licence_url'] = licence_url
24
+ datasette_metadata['source_url'] = 'https://doi.org/{}'.format(gbif_metadata['doi'])
25
 
26
+ datasette_metadata_json = json.dumps(datasette_metadata, indent=4)
27
  with open(args.outputfile, 'w') as f_out:
28
  f_out.write(datasette_metadata_json)