Information image file named 'How to add translated documents' has uploaded to tweepy discord.
-_build
\ No newline at end of file
+_build
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
-locale_dirs = ['locales']
-language = None
+#language = None
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
)
-pause
-
if "%1" == "" goto help
if "%1" == "help" (
)
:end
-pause
--- /dev/null
+# TRANSLATORS of tweepy's documents.
+# Language: Korean (Korea, Republic of)
+
+# Please write down your name at below,
+# <GitHub Username> (<@GitHub ID>)
+# <GitHub Profile URL> forms.
+# If you don't have Username, please write GitHub ID twice.
+
+악동분홍토끼(@pinkrabbit412)
+https://github.com/pinkrabbit412
+
+thdkrhk99 (@thdkrhk99)
+https://github.com/thdkrhk99
+
+ifeve (@ifeve)
+https://github.com/ifeve
\ No newline at end of file
api.wait_on_rate_limit)
self.wait_on_rate_limit_notify = kwargs.pop('wait_on_rate_limit_notify',
api.wait_on_rate_limit_notify)
+ self.return_cursors = kwargs.pop('return_cursors', False)
self.parser = kwargs.pop('parser', api.parser)
self.session.headers = kwargs.pop('headers', {})
self.build_parameters(args, kwargs)
raise TweepError(error_msg, resp, api_code=api_error_code)
# Parse the response payload
- result = self.parser.parse(self, resp.text)
+ self.return_cursors = self.return_cursors or 'cursor' in self.session.params
+ result = self.parser.parse(self, resp.text, return_cursors=self.return_cursors)
# Store result into cache if one is available.
if self.use_cache and self.api.cache and self.method == 'GET' and result:
# Set pagination mode
if 'cursor' in APIMethod.allowed_param:
- _call.pagination_mode = 'cursor'
+ if APIMethod.payload_type == 'direct_message':
+ _call.pagination_mode = 'dm_cursor'
+ else:
+ _call.pagination_mode = 'cursor'
elif 'max_id' in APIMethod.allowed_param:
if 'since_id' in APIMethod.allowed_param:
_call.pagination_mode = 'id'
if hasattr(method, 'pagination_mode'):
if method.pagination_mode == 'cursor':
self.iterator = CursorIterator(method, *args, **kwargs)
+ elif method.pagination_mode == 'dm_cursor':
+ self.iterator = DMCursorIterator(method, *args, **kwargs)
elif method.pagination_mode == 'id':
self.iterator = IdIterator(method, *args, **kwargs)
elif method.pagination_mode == 'page':
return data
+class DMCursorIterator(BaseIterator):
+
+ def __init__(self, method, *args, **kwargs):
+ BaseIterator.__init__(self, method, *args, **kwargs)
+ self.next_cursor = self.kwargs.pop('cursor', None)
+ self.page_count = 0
+
+ def next(self):
+ if self.next_cursor == -1 or (self.limit and self.page_count == self.limit):
+ raise StopIteration
+ data = self.method(cursor=self.next_cursor, return_cursors=True, *self.args, **self.kwargs)
+ self.page_count += 1
+ if isinstance(data, tuple):
+ data, self.next_cursor = data
+ else:
+ self.next_cursor = -1
+ return data
+
+ def prev(self):
+ raise TweepError('This method does not allow backwards pagination')
+
+
class IdIterator(BaseIterator):
def __init__(self, method, *args, **kwargs):
if self.current_page is None or self.page_index == len(self.current_page) - 1:
# Reached end of current page, get the next page...
self.current_page = self.page_iterator.next()
+ while len(self.current_page) == 0:
+ self.current_page = self.page_iterator.next()
self.page_index = -1
self.page_index += 1
self.num_tweets += 1
class Parser(object):
- def parse(self, method, payload):
+ def parse(self, method, payload, *args, **kwargs):
"""
Parse the response payload and return the result.
Returns a tuple that contains the result data and the cursors
def __init__(self):
pass
- def parse(self, method, payload):
+ def parse(self, method, payload, *args, **kwargs):
return payload
def parse_error(self, payload):
payload_format = 'json'
- def parse(self, method, payload):
+ def parse(self, method, payload, return_cursors=False):
try:
json = json_lib.loads(payload)
except Exception as e:
raise TweepError('Failed to parse JSON payload: %s' % e)
- needs_cursors = 'cursor' in method.session.params
- if needs_cursors and isinstance(json, dict) \
- and 'previous_cursor' in json \
- and 'next_cursor' in json:
- cursors = json['previous_cursor'], json['next_cursor']
- return json, cursors
- else:
- return json
+ if return_cursors and isinstance(json, dict):
+ if 'next_cursor' in json:
+ if 'previous_cursor' in json:
+ cursors = json['previous_cursor'], json['next_cursor']
+ return json, cursors
+ else:
+ return json, json['next_cursor']
+ return json
def parse_error(self, payload):
error_object = json_lib.loads(payload)
JSONParser.__init__(self)
self.model_factory = model_factory or ModelFactory
- def parse(self, method, payload):
+ def parse(self, method, payload, return_cursors=False):
try:
if method.payload_type is None:
return
raise TweepError('No model for this payload type: '
'%s' % method.payload_type)
- json = JSONParser.parse(self, method, payload)
+ json = JSONParser.parse(self, method, payload, return_cursors=return_cursors)
if isinstance(json, tuple):
json, cursors = json
else: