climate-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jo...@apache.org
Subject svn commit: r1563547 - /incubator/climate/trunk/ocw-ui/backend/rcmed_helpers.py
Date Sun, 02 Feb 2014 02:32:03 GMT
Author: joyce
Date: Sun Feb  2 02:32:03 2014
New Revision: 1563547

URL: http://svn.apache.org/r1563547
Log:
CLIMATE-326 - Cleanup rcmed_helpers

- Cleanup rcmed_helpers so formatting falls in line with the remainder
  of the codebase.
- Add docstrings to each endpoint to explain the expected return format
  of the data.

Note, no tests were added for this endpoints since they're effectively
just passing off calls to the RCMED endpoints.

Modified:
    incubator/climate/trunk/ocw-ui/backend/rcmed_helpers.py

Modified: incubator/climate/trunk/ocw-ui/backend/rcmed_helpers.py
URL: http://svn.apache.org/viewvc/incubator/climate/trunk/ocw-ui/backend/rcmed_helpers.py?rev=1563547&r1=1563546&r2=1563547&view=diff
==============================================================================
--- incubator/climate/trunk/ocw-ui/backend/rcmed_helpers.py (original)
+++ incubator/climate/trunk/ocw-ui/backend/rcmed_helpers.py Sun Feb  2 02:32:03 2014
@@ -23,25 +23,58 @@ import requests
 
 rcmed_app = Bottle()
 
-@rcmed_app.route('/getObsDatasets')
-def getObservationDatasetData():
+@rcmed_app.route('/datasets/')
+def get_observation_dataset_data():
+    ''' Return a list of dataset information from JPL's RCMED.
+
+    * Example Return JSON Format *
+
+    ..sourcecode: javascript
+
+        [
+            {
+                "dataset_id": "17",
+                "shortname": "The dataset's short name",
+                "longname": "The dataset's, full name",
+                "source": "Where the dataset originated"
+            },
+            ...
+        ]
+    '''
     r = requests.get('http://rcmes.jpl.nasa.gov/query-api/datasets.php')
 
-    # Handle JSONP requests
     if (request.query.callback):
         return "%s(%s)" % (request.query.callback, r.text)
-    # Otherwise, just return JSON
-    else:
-        return r.text
+    return r.text
+
+@rcmed_app.route('/parameters/')
+def get_dataset_parameters():
+    ''' Return dataset specific parameter information from JPL's RCMED.
+
+    * Example Call Format *
+
+    ..sourcecode: javascript
+
+        /parameters/?dataset=<dataset's short name>
+
+    * Example Return JSON Format *
+
+    ..sourcecode: javascript
+
+        [
+            {
+                "parameter_id": "80",
+                "shortname": "The dataset's short name",
+                "datasetshortname": "The dataset's short name again",
+                "longname": "The dataset's long name",
+                "units": "Units for the dataset's measurements"
+            }
+        ]
 
-@rcmed_app.route('/getDatasetParam')
-def getDatasetParameters():
+    '''
     url = 'http://rcmes.jpl.nasa.gov/query-api/parameters.php?dataset=' + request.query.dataset
     r = requests.get(url)
 
-    # Handle JSONP requests
     if (request.query.callback):
         return "%s(%s)" % (request.query.callback, r.text)
-    # Otherwise, just return JSON
-    else:
-        return r.text
+    return r.text



Mime
View raw message