-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #123: simpler pagination with .pages() without first .get #131
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -261,8 +261,19 @@ def _reached_max_limits(self, page_count, item_count, max_pages, | |
reached_item_limit = max_items is not None and max_items <= item_count | ||
return reached_page_limit or reached_item_limit | ||
|
||
def pages(self, max_pages=None, max_items=None, **kwargs): | ||
executor = self | ||
def pages(self, max_pages=None, max_items=None, params=None, **kwargs): | ||
if self._response is not None: | ||
if params is not None: | ||
raise Exception("Since you're paging after the first .get call, " | ||
"you can't pass params here." | ||
"Pass params on the .get call instead.") | ||
executor = self | ||
else: | ||
# this mean .pages() was called before the first .get, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
# like `api.statuses_user_timeline().pages()` | ||
response = self.get(params=params) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't we simply pass all the |
||
executor = response() | ||
|
||
iterator_list = executor._get_iterator_list() | ||
page_count = 0 | ||
item_count = 0 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just improving the message:
You cannot pass new params after the first request is done. Use the ".get" method to pass parameters