def testcursorsetstartcursor(self):
c = Cursor(self.api.friends_ids, cursor=123456)
self.assertEqual(c.iterator.next_cursor, 123456)
- self.assertFalse('cursor' in c.iterator.kargs)
+ self.assertFalse('cursor' in c.iterator.kwargs)
@tape.use_cassette('testcursornext.json')
def testcursornext(self):
use_cache=False
)
- def verify_credentials(self, **kargs):
+ def verify_credentials(self, **kwargs):
""" :reference: https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/get-account-verify_credentials
:allowed_param:'include_entities', 'skip_status', 'include_email'
"""
payload_type='user',
require_auth=True,
allowed_param=['include_entities', 'skip_status', 'include_email'],
- )(**kargs)
+ )(**kwargs)
except TweepError as e:
if e.response and e.response.status == 401:
return False
require_auth=True
)(self, post_data=post_data, headers=headers)
- def update_profile_background_image(self, filename, **kargs):
+ def update_profile_background_image(self, filename, **kwargs):
""" :reference: https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/post-account-update_profile_background_image
:allowed_param:'tile', 'include_entities', 'skip_status', 'use'
"""
- f = kargs.pop('file', None)
+ f = kwargs.pop('file', None)
headers, post_data = API._pack_image(filename, 800, f=f)
return bind_api(
api=self,
require_auth=True
)(post_data=post_data, headers=headers)
- def update_profile_banner(self, filename, **kargs):
+ def update_profile_banner(self, filename, **kwargs):
""" :reference: https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/post-account-update_profile_banner
:allowed_param:'width', 'height', 'offset_left', 'offset_right'
"""
- f = kargs.pop('file', None)
+ f = kwargs.pop('file', None)
headers, post_data = API._pack_image(filename, 700, form_field="banner", f=f)
return bind_api(
api=self,
class Cursor(object):
"""Pagination helper class"""
- def __init__(self, method, *args, **kargs):
+ def __init__(self, method, *args, **kwargs):
if hasattr(method, 'pagination_mode'):
if method.pagination_mode == 'cursor':
- self.iterator = CursorIterator(method, args, kargs)
+ self.iterator = CursorIterator(method, args, kwargs)
elif method.pagination_mode == 'id':
- self.iterator = IdIterator(method, args, kargs)
+ self.iterator = IdIterator(method, args, kwargs)
elif method.pagination_mode == 'page':
- self.iterator = PageIterator(method, args, kargs)
+ self.iterator = PageIterator(method, args, kwargs)
else:
raise TweepError('Invalid pagination mode.')
else:
class BaseIterator(object):
- def __init__(self, method, args, kargs):
+ def __init__(self, method, args, kwargs):
self.method = method
self.args = args
- self.kargs = kargs
+ self.kwargs = kwargs
self.limit = 0
def __next__(self):
class CursorIterator(BaseIterator):
- def __init__(self, method, args, kargs):
- BaseIterator.__init__(self, method, args, kargs)
- start_cursor = kargs.pop('cursor', None)
+ def __init__(self, method, args, kwargs):
+ BaseIterator.__init__(self, method, args, kwargs)
+ start_cursor = kwargs.pop('cursor', None)
self.next_cursor = start_cursor or -1
self.prev_cursor = start_cursor or 0
self.num_tweets = 0
raise StopIteration
data, cursors = self.method(cursor=self.next_cursor,
*self.args,
- **self.kargs)
+ **self.kwargs)
self.prev_cursor, self.next_cursor = cursors
if len(data) == 0:
raise StopIteration
raise TweepError('Can not page back more, at first page')
data, self.next_cursor, self.prev_cursor = self.method(cursor=self.prev_cursor,
*self.args,
- **self.kargs)
+ **self.kwargs)
self.num_tweets -= 1
return data
class IdIterator(BaseIterator):
- def __init__(self, method, args, kargs):
- BaseIterator.__init__(self, method, args, kargs)
- self.max_id = kargs.pop('max_id', None)
+ def __init__(self, method, args, kwargs):
+ BaseIterator.__init__(self, method, args, kwargs)
+ self.max_id = kwargs.pop('max_id', None)
self.num_tweets = 0
self.results = []
self.model_results = []
raise StopIteration
if self.index >= len(self.results) - 1:
- data = self.method(max_id=self.max_id, parser=RawParser(), *self.args, **self.kargs)
+ data = self.method(max_id=self.max_id, parser=RawParser(), *self.args, **self.kwargs)
if hasattr(self.method, '__self__'):
old_parser = self.method.__self__.parser
class PageIterator(BaseIterator):
- def __init__(self, method, args, kargs):
- BaseIterator.__init__(self, method, args, kargs)
+ def __init__(self, method, args, kwargs):
+ BaseIterator.__init__(self, method, args, kwargs)
self.current_page = 0
def next(self):
if self.current_page > self.limit:
raise StopIteration
- items = self.method(page=self.current_page, *self.args, **self.kargs)
+ items = self.method(page=self.current_page, *self.args, **self.kwargs)
if len(items) == 0:
raise StopIteration
self.current_page += 1
if self.current_page == 1:
raise TweepError('Can not page back more, at first page')
self.current_page -= 1
- return self.method(page=self.current_page, *self.args, **self.kargs)
+ return self.method(page=self.current_page, *self.args, **self.kwargs)
class ItemIterator(BaseIterator):
results.append(cls.parse(api, obj))
return results
- def timeline(self, **kargs):
- return self._api.user_timeline(user_id=self.id, **kargs)
+ def timeline(self, **kwargs):
+ return self._api.user_timeline(user_id=self.id, **kwargs)
- def friends(self, **kargs):
- return self._api.friends(user_id=self.id, **kargs)
+ def friends(self, **kwargs):
+ return self._api.friends(user_id=self.id, **kwargs)
- def followers(self, **kargs):
- return self._api.followers(user_id=self.id, **kargs)
+ def followers(self, **kwargs):
+ return self._api.followers(user_id=self.id, **kwargs)
def follow(self):
self._api.create_friendship(user_id=self.id)
self._api.destroy_friendship(user_id=self.id)
self.following = False
- def lists_memberships(self, *args, **kargs):
+ def lists_memberships(self, *args, **kwargs):
return self._api.lists_memberships(user=self.screen_name,
*args,
- **kargs)
+ **kwargs)
- def lists_subscriptions(self, *args, **kargs):
+ def lists_subscriptions(self, *args, **kwargs):
return self._api.lists_subscriptions(user=self.screen_name,
*args,
- **kargs)
+ **kwargs)
- def lists(self, *args, **kargs):
+ def lists(self, *args, **kwargs):
return self._api.lists_all(user=self.screen_name,
*args,
- **kargs)
+ **kwargs)
- def followers_ids(self, *args, **kargs):
+ def followers_ids(self, *args, **kwargs):
return self._api.followers_ids(user_id=self.id,
*args,
- **kargs)
+ **kwargs)
def __eq__(self, other):
if isinstance(other, User):
results.append(cls.parse(api, obj))
return results
- def update(self, **kargs):
- return self._api.update_list(self.slug, **kargs)
+ def update(self, **kwargs):
+ return self._api.update_list(self.slug, **kwargs)
def destroy(self):
return self._api.destroy_list(self.slug)
- def timeline(self, **kargs):
+ def timeline(self, **kwargs):
return self._api.list_timeline(self.user.screen_name,
self.slug,
- **kargs)
+ **kwargs)
def add_member(self, id):
return self._api.add_list_member(self.slug, id)
def remove_member(self, id):
return self._api.remove_list_member(self.slug, id)
- def members(self, **kargs):
+ def members(self, **kwargs):
return self._api.list_members(self.user.screen_name,
self.slug,
- **kargs)
+ **kwargs)
def is_member(self, id):
return self._api.is_list_member(self.user.screen_name,
def unsubscribe(self):
return self._api.unsubscribe_list(self.user.screen_name, self.slug)
- def subscribers(self, **kargs):
+ def subscribers(self, **kwargs):
return self._api.list_subscribers(self.user.screen_name,
self.slug,
- **kargs)
+ **kwargs)
def is_subscribed(self, id):
return self._api.is_subscribed_list(self.user.screen_name,