From 62e2e976f1cdf1ca2f9b3019f210d85865eea514 Mon Sep 17 00:00:00 2001 From: David Medina Date: Sun, 13 Nov 2011 23:40:52 +0100 Subject: Fix limit bug --- github3/api.py | 1 + github3/handlers/base.py | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'github3') diff --git a/github3/api.py b/github3/api.py index bf0ebe2..1c467ff 100644 --- a/github3/api.py +++ b/github3/api.py @@ -11,6 +11,7 @@ from handlers import users, gists RESOURCES_PER_PAGE = 100 +#TODO: refactor: loads json in request editing Response object class GithubCore(object): """ Wrapper to github api requests diff --git a/github3/handlers/base.py b/github3/handlers/base.py index 68eb6b4..c27b80c 100644 --- a/github3/handlers/base.py +++ b/github3/handlers/base.py @@ -48,19 +48,20 @@ class Handler(object): assert response.status_code == 204 return True - #TODO: if limit is multiple of per_page... it do another request for nothing def _get_resources(self, resource, model=None, limit=None, **kwargs): """ Hander request to multiple resources """ + if limit: + limit = abs(limit) resource = self._prefix_resource(resource) counter = 1 for page in Paginate(resource, self._gh.get, **kwargs): for raw_resource in page: - if limit and counter > limit: break counter += 1 converter = self._get_converter(**kwargs) converter.inject(model) yield converter.loads(raw_resource) + if limit and counter > limit: break else: continue break -- cgit v1.2.3-59-g8ed1b