added option to cursor() to yeild "page" - ie: iterators over each page returned by twitter #282

Merged
drevicko merged 5 commits from cursor-pages into master 2014-03-05 07:49:40 -08:00

View file

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