Skip to content

Commit f337f3c

Browse files
committed
Added method 'iter' for commits. It uses pagerator library to iterate over pages.
1 parent 7c9680b commit f337f3c

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

github2/commits.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import pagerator
12
from github2.core import BaseData, GithubCommand, Attribute, DateAttribute
23

34

@@ -34,6 +35,16 @@ def list(self, project, branch="master", file=None, page = None):
3435
filter="commits", datatype=Commit,
3536
post_data=post_data)
3637

38+
def iter(self, project, branch="master", file=None):
39+
return pagerator.IterableQuery(
40+
lambda page: self.get_values(
41+
"list", project, branch, file,
42+
filter="commits", datatype=Commit,
43+
post_data=dict(page=page+1)
44+
),
45+
35 # page_size hardcoded in the GitHub
46+
)
47+
3748
def show(self, project, sha):
3849
return self.get_value("show", project, sha,
3950
filter="commit", datatype=Commit)

0 commit comments

Comments
 (0)