diff options
author | 2011-11-13 23:40:52 +0100 | |
---|---|---|
committer | 2011-11-13 23:40:52 +0100 | |
commit | 62e2e976f1cdf1ca2f9b3019f210d85865eea514 (patch) | |
tree | a7ddb595131d68643ce784b499b2f10b32c24254 | |
parent | Fix bug. Instance converter in handler base (diff) | |
download | python-github3-62e2e976f1cdf1ca2f9b3019f210d85865eea514.tar.xz python-github3-62e2e976f1cdf1ca2f9b3019f210d85865eea514.zip |
Fix limit bug
-rw-r--r-- | github3/api.py | 1 | ||||
-rw-r--r-- | github3/handlers/base.py | 5 |
2 files changed, 4 insertions, 2 deletions
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 |