Skip to content

Commit

Permalink
Added support for the keyword, which rounds out all available API opt…
Browse files Browse the repository at this point in the history
…ions.
  • Loading branch information
mattdeboard committed Jul 29, 2011
1 parent 13fff75 commit b501189
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions python_usdol.py
Expand Up @@ -17,6 +17,7 @@
import hmac
import json
import string
import urllib
import urllib2
import urlparse

Expand Down Expand Up @@ -99,7 +100,11 @@ def _get_querystring(self, **kwargs):
qs = []
for arg in kwargs:
if kwargs[arg]:
qs.append("$%s=%s" % (arg, kwargs[arg]))
# `filter` is a keyword in Python, so I avoid using it by
# adding a _ to the end, then removing it here.
key = arg.replace('_', '')
val = kwargs[arg].replace(' ', '+')
qs.append("$%s=%s" % (key, val))
return '?' + string.join(qs, '&')

def _get_request(self, qs='', fmt='json'):
Expand All @@ -111,7 +116,7 @@ def _get_request(self, qs='', fmt='json'):
return req

def fetch_data(self, dataset, table='$metadata', fmt='json', top=0,
skip=0, select='', orderby=''):
skip=0, select='', orderby='', filter_=''):
'''
fetch_data(dataset, table[, fmt, top, skip, select, orderby]) ->
Expand All @@ -126,7 +131,9 @@ def fetch_data(self, dataset, table='$metadata', fmt='json', top=0,
'''

qs = self._get_querystring(top=top, skip=skip, select=select,
orderby=orderby)
orderby=orderby, filter_=filter_)
import sys
print >> sys.stdout, qs
self.dataset = dataset
self.table = table
enc_opts = ['json', 'xml']
Expand Down

0 comments on commit b501189

Please sign in to comment.