Skip to content

Commit 62e2e97

Browse files
committed
Fix limit bug
1 parent 43843a9 commit 62e2e97

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

github3/api.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
RESOURCES_PER_PAGE = 100
1212

1313

14+
#TODO: refactor: loads json in request editing Response object
1415
class GithubCore(object):
1516
"""
1617
Wrapper to github api requests

github3/handlers/base.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,20 @@ def _bool(self, resource, **kwargs):
4848
assert response.status_code == 204
4949
return True
5050

51-
#TODO: if limit is multiple of per_page... it do another request for nothing
5251
def _get_resources(self, resource, model=None, limit=None, **kwargs):
5352
""" Hander request to multiple resources """
5453

54+
if limit:
55+
limit = abs(limit)
5556
resource = self._prefix_resource(resource)
5657
counter = 1
5758
for page in Paginate(resource, self._gh.get, **kwargs):
5859
for raw_resource in page:
59-
if limit and counter > limit: break
6060
counter += 1
6161
converter = self._get_converter(**kwargs)
6262
converter.inject(model)
6363
yield converter.loads(raw_resource)
64+
if limit and counter > limit: break
6465
else:
6566
continue
6667
break

0 commit comments

Comments
 (0)