Merge pull request #282 from drevicko/cursor-pages

added option to cursor() to yeild "page" - ie: iterators over each page returned by twitter
This commit is contained in:
Mike Helmick 2014-03-05 10:49:40 -05:00
commit 10e60fca10

View file

@ -390,7 +390,7 @@ class Twython(EndpointsMixin, object):
)
return self.cursor(self.search, q=search_query, **params)
def cursor(self, function, **params):
def cursor(self, function, return_pages=False, **params):
"""Returns a generator for results that match a specified query.
:param function: Instance of a Twython function (Twython.get_home_timeline, Twython.search)
@ -421,6 +421,9 @@ class Twython(EndpointsMixin, object):
else:
results = content
if return_pages:
yield results
else:
for result in results:
yield result