gdex-api-client 2.0.2__tar.gz → 2.0.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gdex-api-client
3
- Version: 2.0.2
3
+ Version: 2.0.3
4
4
  Summary: CLI and library for calling GDEX API
5
5
  Author-email: GDEX data Help <datahelp@ucar.edu>
6
6
  License-Expression: MIT
@@ -3,7 +3,7 @@ requires = ["setuptools"]
3
3
  build-backend = "setuptools.build_meta"
4
4
  [project]
5
5
  name = "gdex-api-client"
6
- version = "2.0.2"
6
+ version = "2.0.3"
7
7
  dependencies = [
8
8
  "requests",
9
9
  ]
@@ -26,6 +26,7 @@ import json
26
26
  import argparse
27
27
  import codecs
28
28
  import pdb
29
+ import re
29
30
 
30
31
 
31
32
  BASE_URL = 'https://gdex.ucar.edu/api/'
@@ -67,6 +68,13 @@ def query(args=None):
67
68
  print(json.dumps(result, indent=3))
68
69
  return result
69
70
 
71
+ def validate_dsid(dsid):
72
+ """ Validate dsid from command line input """
73
+ ms = re.match(r'^([a-z]{1})(\d{3})(\d{3})$', dsid)
74
+ if ms:
75
+ return dsid
76
+ else:
77
+ raise ValueError("dataset number 'dsid' must be formatted as 'dnnnnnn'")
70
78
 
71
79
  def get_userinfo():
72
80
  """Get token from command line."""
@@ -500,10 +508,11 @@ def write_control_file_template(ds, write_location='./'):
500
508
  Returns:
501
509
  dict: JSON decoded result of the query.
502
510
  """
511
+ dsid = validate_dsid(ds)
503
512
  _json = get_control_file_template(ds)
504
513
  control_str = _json['data']['template']
505
514
 
506
- template_filename = write_location + ds + '_control.ctl'
515
+ template_filename = write_location + dsid + '_control.ctl'
507
516
  if os.path.exists(template_filename):
508
517
  print(template_filename + " already exists.\nExiting")
509
518
  exit(1)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gdex-api-client
3
- Version: 2.0.2
3
+ Version: 2.0.3
4
4
  Summary: CLI and library for calling GDEX API
5
5
  Author-email: GDEX data Help <datahelp@ucar.edu>
6
6
  License-Expression: MIT
File without changes