Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Zahra Rajabi
tweepy
Commits
e3d23762
Commit
e3d23762
authored
Oct 13, 2009
by
Josh Roesslein
Browse files
Fix Cursor pagination mode detection.
parent
01dc7345
Changes
3
Hide whitespace changes
Inline
Side-by-side
tweepy/api.py
View file @
e3d23762
...
...
@@ -946,6 +946,7 @@ class API(object):
parser
=
parse_search_results
,
allowed_param
=
[
'q'
,
'lang'
,
'locale'
,
'rpp'
,
'page'
,
'since_id'
,
'geocode'
,
'show_user'
],
)(
self
,
*
args
,
**
kargs
)
search
.
pagination_mode
=
'page'
""" trends
...
...
tweepy/binder.py
View file @
e3d23762
...
...
@@ -21,7 +21,7 @@ except ImportError:
raise
ImportError
,
"Can't load a json library"
def
bind_api
(
path
,
parser
,
allowed_param
=
None
,
method
=
'GET'
,
require_auth
=
False
,
def
bind_api
(
path
,
parser
,
allowed_param
=
[]
,
method
=
'GET'
,
require_auth
=
False
,
timeout
=
None
,
host
=
None
):
def
_call
(
api
,
*
args
,
**
kargs
):
...
...
@@ -186,8 +186,12 @@ def bind_api(path, parser, allowed_param=None, method='GET', require_auth=False,
return
out
# Expose extra data in callable object
_call
.
allowed_param
=
allowed_param
# Set pagination mode
if
'cursor'
in
allowed_param
:
_call
.
pagination_mode
=
'cursor'
elif
'page'
in
allowed_param
:
_call
.
pagination_mode
=
'page'
return
_call
tweepy/cursor.py
View file @
e3d23762
...
...
@@ -8,10 +8,11 @@ class Cursor(object):
"""Pagination helper class"""
def
__init__
(
self
,
method
,
*
args
,
**
kargs
):
if
'cursor'
in
method
.
allowed_param
:
self
.
iterator
=
CursorIterator
(
method
,
args
,
kargs
)
elif
'page'
in
method
.
allowed_param
:
self
.
iterator
=
PageIterator
(
method
,
args
,
kargs
)
if
hasattr
(
method
,
'pagination_mode'
):
if
method
.
pagination_mode
==
'cursor'
:
self
.
iterator
=
CursorIterator
(
method
,
args
,
kargs
)
else
:
self
.
iterator
=
PageIterator
(
method
,
args
,
kargs
)
else
:
raise
TweepError
(
'This method does not perform pagination'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment