Skip to content

Commit

Permalink
feat: allow a start page number in fathomnet.util.page
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinsbarnard committed Jul 18, 2024
1 parent 8c7f1c6 commit 62ca914
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions fathomnet/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def debug_format_response(response: requests.Response) -> str:
return formatted_str


def page(f: callable, size: int, *args, **kwargs):
def page(f: callable, size: int, start_page_number: int = 0, *args, **kwargs):
"""
Calls the given function with the given arguments, and returns a generator that will yield all results, page by page, until there are no more results.
Expand All @@ -57,13 +57,14 @@ def page(f: callable, size: int, *args, **kwargs):
Args:
f: The function to call
size: The page size to use
start_page_number: The page number to start on (default 0)
*args: The arguments to pass to the function
**kwargs: The keyword arguments to pass to the function
Returns:
A generator that will yield all results, page by page, until there are no more results.
"""
number = 0
number = start_page_number
while True:
pageable = Pageable(size=size, number=number)
page = f(pageable, *args, **kwargs)
Expand Down

0 comments on commit 62ca914

Please sign in to comment.