Skip to content

Commit

Permalink
Merge pull request #25 from jrieke/master
Browse files Browse the repository at this point in the history
Pass kwargs to operation in `paged`
  • Loading branch information
Hamel Husain authored Dec 28, 2020
2 parents 1ec2b75 + 1ad0fe7 commit 378bbe9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion 03_page.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
"#export\n",
"def paged(oper, *args, per_page=30, max_pages=9999, **kwargs):\n",
" \"Convert operation `oper(*args,**kwargs)` into an iterator\"\n",
" yield from itertools.takewhile(noop, (oper(*args, per_page=per_page, page=i) for i in range(1,max_pages+1)))"
" yield from itertools.takewhile(noop, (oper(*args, per_page=per_page, page=i, **kwargs) for i in range(1,max_pages+1)))"
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions ghapi/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# Cell
def paged(oper, *args, per_page=30, max_pages=9999, **kwargs):
"Convert operation `oper(*args,**kwargs)` into an iterator"
yield from itertools.takewhile(noop, (oper(*args, per_page=per_page, page=i) for i in range(1,max_pages+1)))
yield from itertools.takewhile(noop, (oper(*args, per_page=per_page, page=i, **kwargs) for i in range(1,max_pages+1)))

# Cell
class _Scanner:
Expand Down Expand Up @@ -67,4 +67,4 @@ def _call_page(i, oper, args, kwargs, per_page):
def pages(oper, n_pages, *args, n_workers=None, per_page=100, **kwargs):
"Get `n_pages` pages from `oper(*args,**kwargs)`"
return parallel(_call_page, range(1,n_pages+1), oper=oper, per_page=per_page, args=args, kwargs=kwargs,
progress=False, n_workers=ifnone(n_workers,n_pages), threadpool=True)
progress=False, n_workers=ifnone(n_workers,n_pages), threadpool=True)

0 comments on commit 378bbe9

Please sign in to comment.