updates the ghuser on login

This commit is contained in:
Jonas Obrist 2012-08-18 17:57:24 +02:00
parent 603c29c8b4
commit 055e10b97e
9 changed files with 166 additions and 62 deletions

View file

@ -25,8 +25,11 @@ class GitHub(object):
"""
Gets a resource, eg 'users/ojii'.
Returns tuple (jsondata, response)
Returns parsed json data as a python dictionary
"""
return self._get(path, params)[0]
def _get(self, path, params=None):
if params is None:
params = {}
params['per_page'] = 100
@ -34,12 +37,13 @@ class GitHub(object):
response.raise_for_status()
return response.json, response
def get_iter(self, path, params=None):
"""
Returns an iterator over a resource, eg 'repos/divio/django-cms/watchers' that automatically handles
pagination.
"""
data, response = self.get(path, params)
data, response = self._get(path, params)
for thing in data:
yield thing
next_page = get_next_page(response)