From: Harmon Date: Thu, 28 Jan 2021 16:21:38 +0000 (-0600) Subject: Pass arguments directly to bind_api in API methods X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=ab02eb532018dd2b0043c990cd2b3c12fb9ca6df;p=tweepy.git Pass arguments directly to bind_api in API methods Rather than using property decorators for API methods Replace APIMethod pagination_mode determination with pagination decorator usage --- diff --git a/tweepy/api.py b/tweepy/api.py index 862787c..5ce9b65 100644 --- a/tweepy/api.py +++ b/tweepy/api.py @@ -76,8 +76,8 @@ class API: f' It is currently a {type(self.parser)}.' ) - @property - def home_timeline(self): + @pagination(mode='id') + def home_timeline(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/tweets/timelines/api-reference/get-statuses-home_timeline :allowed_param: 'count', 'since_id', 'max_id', 'trim_user', 'exclude_replies', 'include_entities' @@ -89,7 +89,7 @@ class API: allowed_param=['count', 'since_id', 'max_id', 'trim_user', 'exclude_replies', 'include_entities'], require_auth=True - ) + )(*args, **kwargs) def statuses_lookup(self, id_, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/get-statuses-lookup @@ -108,8 +108,8 @@ class API: require_auth=True )(list_to_csv(id_), *args, **kwargs) - @property - def user_timeline(self): + @pagination(mode='id') + def user_timeline(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/tweets/timelines/api-reference/get-statuses-user_timeline :allowed_param: 'user_id', 'screen_name', 'since_id', 'count', 'max_id', 'trim_user', 'exclude_replies', @@ -122,10 +122,10 @@ class API: allowed_param=['user_id', 'screen_name', 'since_id', 'count', 'max_id', 'trim_user', 'exclude_replies', 'include_rts'] - ) + )(*args, **kwargs) - @property - def mentions_timeline(self): + @pagination(mode='id') + def mentions_timeline(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/tweets/timelines/api-reference/get-statuses-mentions_timeline :allowed_param: 'since_id', 'max_id', 'count' """ @@ -135,10 +135,9 @@ class API: payload_type='status', payload_list=True, allowed_param=['since_id', 'max_id', 'count'], require_auth=True - ) + )(*args, **kwargs) - @property - def related_results(self): + def related_results(self, *args, **kwargs): """ :reference: https://dev.twitter.com/docs/api/1.1/get/related_results/show/%3id.format :allowed_param: 'id' """ @@ -148,10 +147,10 @@ class API: payload_type='relation', payload_list=True, allowed_param=['id'], require_auth=False - ) + )(*args, **kwargs) - @property - def retweets_of_me(self): + @pagination(mode='id') + def retweets_of_me(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/get-statuses-retweets_of_me :allowed_param: 'since_id', 'max_id', 'count' """ @@ -161,10 +160,9 @@ class API: payload_type='status', payload_list=True, allowed_param=['since_id', 'max_id', 'count'], require_auth=True - ) + )(*args, **kwargs) - @property - def get_status(self): + def get_status(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/get-statuses-show-id :allowed_param: 'id', 'trim_user', 'include_my_retweet', 'include_entities', 'include_ext_alt_text', @@ -177,7 +175,7 @@ class API: allowed_param=['id', 'trim_user', 'include_my_retweet', 'include_entities', 'include_ext_alt_text', 'include_card_uri'] - ) + )(*args, **kwargs) def update_status(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/post-statuses-update @@ -282,8 +280,7 @@ class API: require_auth=True )(*args, **kwargs) - @property - def destroy_status(self): + def destroy_status(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/post-statuses-destroy-id :allowed_param: 'id' """ @@ -294,10 +291,9 @@ class API: payload_type='status', allowed_param=['id'], require_auth=True - ) + )(*args, **kwargs) - @property - def retweet(self): + def retweet(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/post-statuses-retweet-id :allowed_param: 'id' """ @@ -308,10 +304,9 @@ class API: payload_type='status', allowed_param=['id'], require_auth=True - ) + )(*args, **kwargs) - @property - def unretweet(self): + def unretweet(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/post-statuses-unretweet-id :allowed_param: 'id' """ @@ -322,10 +317,9 @@ class API: payload_type='status', allowed_param=['id'], require_auth=True - ) + )(*args, **kwargs) - @property - def retweets(self): + def retweets(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/get-statuses-retweets-id :allowed_param: 'id', 'count' """ @@ -335,10 +329,10 @@ class API: payload_type='status', payload_list=True, allowed_param=['id', 'count'], require_auth=True - ) + )(*args, **kwargs) - @property - def retweeters(self): + @pagination(mode='cursor') + def retweeters(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/get-statuses-retweeters-ids :allowed_param: 'id', 'cursor', 'stringify_ids """ @@ -347,10 +341,9 @@ class API: path='/statuses/retweeters/ids.json', payload_type='ids', allowed_param=['id', 'cursor', 'stringify_ids'] - ) + )(*args, **kwargs) - @property - def get_user(self): + def get_user(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-users-show :allowed_param: 'id', 'user_id', 'screen_name' """ @@ -359,10 +352,9 @@ class API: path='/users/show.json', payload_type='user', allowed_param=['id', 'user_id', 'screen_name'] - ) + )(*args, **kwargs) - @property - def get_oembed(self): + def get_oembed(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/get-statuses-oembed :allowed_param: 'url', 'maxwidth', 'hide_media', 'hide_thread', 'omit_script', 'align', 'related', 'lang', 'theme', @@ -375,7 +367,7 @@ class API: allowed_param=['url', 'maxwidth', 'hide_media', 'hide_thread', 'omit_script', 'align', 'related', 'lang', 'theme', 'link_color', 'widget_type', 'dnt'] - ) + )(*args, **kwargs) def lookup_users(self, user_ids=None, screen_names=None, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-users-lookup @@ -395,8 +387,8 @@ class API: """ Get the authenticated user """ return self.get_user(screen_name=self.auth.get_username()) - @property - def search_users(self): + @pagination(mode='page') + def search_users(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-users-search :allowed_param: 'q', 'count', 'page' """ @@ -406,10 +398,9 @@ class API: payload_type='user', payload_list=True, require_auth=True, allowed_param=['q', 'count', 'page'] - ) + )(*args, **kwargs) - @property - def get_direct_message(self): + def get_direct_message(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/direct-messages/sending-and-receiving/api-reference/get-event :allowed_param: 'id' """ @@ -419,10 +410,10 @@ class API: payload_type='direct_message', allowed_param=['id'], require_auth=True - ) + )(*args, **kwargs) - @property - def list_direct_messages(self): + @pagination(mode='dm_cursor') + def list_direct_messages(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/direct-messages/sending-and-receiving/api-reference/list-events :allowed_param: 'count', 'cursor' """ @@ -432,7 +423,7 @@ class API: payload_type='direct_message', payload_list=True, allowed_param=['count', 'cursor'], require_auth=True - ) + )(*args, **kwargs) def send_direct_message(self, recipient_id, text, quick_reply_options=None, attachment_type=None, attachment_media_id=None, @@ -470,8 +461,7 @@ class API: require_auth=True )(json_payload=json_payload) - @property - def destroy_direct_message(self): + def destroy_direct_message(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/direct-messages/sending-and-receiving/api-reference/delete-message-event :allowed_param: 'id' """ @@ -481,10 +471,9 @@ class API: method='DELETE', allowed_param=['id'], require_auth=True - ) + )(*args, **kwargs) - @property - def create_friendship(self): + def create_friendship(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/post-friendships-create :allowed_param: 'id', 'user_id', 'screen_name', 'follow' """ @@ -495,10 +484,9 @@ class API: payload_type='user', allowed_param=['id', 'user_id', 'screen_name', 'follow'], require_auth=True - ) + )(*args, **kwargs) - @property - def destroy_friendship(self): + def destroy_friendship(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/post-friendships-destroy :allowed_param: 'id', 'user_id', 'screen_name' """ @@ -509,10 +497,9 @@ class API: payload_type='user', allowed_param=['id', 'user_id', 'screen_name'], require_auth=True - ) + )(*args, **kwargs) - @property - def show_friendship(self): + def show_friendship(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-friendships-show :allowed_param: 'source_id', 'source_screen_name', 'target_id', 'target_screen_name' @@ -523,7 +510,7 @@ class API: payload_type='friendship', allowed_param=['source_id', 'source_screen_name', 'target_id', 'target_screen_name'] - ) + )(*args, **kwargs) def lookup_friendships(self, user_ids=None, screen_names=None): """ :reference: https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-friendships-lookup @@ -537,8 +524,8 @@ class API: require_auth=True )(list_to_csv(user_ids), list_to_csv(screen_names)) - @property - def friends_ids(self): + @pagination(mode='cursor') + def friends_ids(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-friends-ids :allowed_param: 'id', 'user_id', 'screen_name', 'cursor' """ @@ -547,10 +534,10 @@ class API: path='/friends/ids.json', payload_type='ids', allowed_param=['id', 'user_id', 'screen_name', 'cursor'] - ) + )(*args, **kwargs) - @property - def friends(self): + @pagination(mode='cursor') + def friends(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-friends-list :allowed_param: 'id', 'user_id', 'screen_name', 'cursor', 'count', 'skip_status', 'include_user_entities' @@ -561,10 +548,10 @@ class API: payload_type='user', payload_list=True, allowed_param=['id', 'user_id', 'screen_name', 'cursor', 'count', 'skip_status', 'include_user_entities'] - ) + )(*args, **kwargs) - @property - def friendships_incoming(self): + @pagination(mode='cursor') + def friendships_incoming(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-friendships-incoming :allowed_param: 'cursor' """ @@ -573,10 +560,10 @@ class API: path='/friendships/incoming.json', payload_type='ids', allowed_param=['cursor'] - ) + )(*args, **kwargs) - @property - def friendships_outgoing(self): + @pagination(mode='cursor') + def friendships_outgoing(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-friendships-outgoing :allowed_param: 'cursor' """ @@ -585,10 +572,10 @@ class API: path='/friendships/outgoing.json', payload_type='ids', allowed_param=['cursor'] - ) + )(*args, **kwargs) - @property - def followers_ids(self): + @pagination(mode='cursor') + def followers_ids(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-followers-ids :allowed_param: 'id', 'user_id', 'screen_name', 'cursor', 'count' """ @@ -597,10 +584,10 @@ class API: path='/followers/ids.json', payload_type='ids', allowed_param=['id', 'user_id', 'screen_name', 'cursor', 'count'] - ) + )(*args, **kwargs) - @property - def followers(self): + @pagination(mode='cursor') + def followers(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-followers-list :allowed_param: 'id', 'user_id', 'screen_name', 'cursor', 'count', 'skip_status', 'include_user_entities' @@ -611,20 +598,18 @@ class API: payload_type='user', payload_list=True, allowed_param=['id', 'user_id', 'screen_name', 'cursor', 'count', 'skip_status', 'include_user_entities'] - ) + )(*args, **kwargs) - @property - def get_settings(self): + def get_settings(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/get-account-settings """ return bind_api( api=self, path='/account/settings.json', payload_type='json', use_cache=False - ) + )(*args, **kwargs) - @property - def set_settings(self): + def set_settings(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/post-account-settings :allowed_param: 'sleep_time_enabled', 'start_sleep_time', 'end_sleep_time', 'time_zone', @@ -641,7 +626,7 @@ class API: 'trend_location_woeid', 'allow_contributor_request', 'lang'], use_cache=False - ) + )(*args, **kwargs) def verify_credentials(self, **kwargs): """ :reference: https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/get-account-verify_credentials @@ -663,8 +648,7 @@ class API: return False raise - @property - def rate_limit_status(self): + def rate_limit_status(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/developer-utilities/rate-limit-status/api-reference/get-application-rate_limit_status :allowed_param: 'resources' """ @@ -674,7 +658,7 @@ class API: payload_type='json', allowed_param=['resources'], use_cache=False - ) + )(*args, **kwargs) def update_profile_image(self, filename, file_=None): """ :reference: https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/post-account-update_profile_image @@ -705,8 +689,7 @@ class API: require_auth=True )(post_data=post_data, headers=headers) - @property - def update_profile(self): + def update_profile(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/post-account-update_profile :allowed_param: 'name', 'url', 'location', 'description', 'profile_link_color' @@ -719,10 +702,10 @@ class API: allowed_param=['name', 'url', 'location', 'description', 'profile_link_color'], require_auth=True - ) + )(*args, **kwargs) - @property - def favorites(self): + @pagination(mode='id') + def favorites(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/get-favorites-list :allowed_param: 'screen_name', 'user_id', 'max_id', 'count', 'since_id', 'max_id' @@ -733,10 +716,9 @@ class API: payload_type='status', payload_list=True, allowed_param=['screen_name', 'user_id', 'max_id', 'count', 'since_id', 'max_id'] - ) + )(*args, **kwargs) - @property - def create_favorite(self): + def create_favorite(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/post-favorites-create :allowed_param: 'id' """ @@ -747,10 +729,9 @@ class API: payload_type='status', allowed_param=['id'], require_auth=True - ) + )(*args, **kwargs) - @property - def destroy_favorite(self): + def destroy_favorite(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/post-favorites-destroy :allowed_param: 'id' """ @@ -761,10 +742,9 @@ class API: payload_type='status', allowed_param=['id'], require_auth=True - ) + )(*args, **kwargs) - @property - def create_block(self): + def create_block(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/accounts-and-users/mute-block-report-users/api-reference/post-blocks-create :allowed_param: 'id', 'user_id', 'screen_name' """ @@ -775,10 +755,9 @@ class API: payload_type='user', allowed_param=['id', 'user_id', 'screen_name'], require_auth=True - ) + )(*args, **kwargs) - @property - def destroy_block(self): + def destroy_block(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/accounts-and-users/mute-block-report-users/api-reference/post-blocks-destroy :allowed_param: 'id', 'user_id', 'screen_name' """ @@ -789,10 +768,10 @@ class API: payload_type='user', allowed_param=['id', 'user_id', 'screen_name'], require_auth=True - ) + )(*args, **kwargs) - @property - def mutes_ids(self): + @pagination(mode='cursor') + def mutes_ids(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/accounts-and-users/mute-block-report-users/api-reference/get-mutes-users-ids :allowed_param: 'cursor' """ @@ -802,10 +781,10 @@ class API: payload_type='ids', allowed_param=['cursor'], require_auth=True - ) + )(*args, **kwargs) - @property - def mutes(self): + @pagination(mode='cursor') + def mutes(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/accounts-and-users/mute-block-report-users/api-reference/get-mutes-users-list :allowed_param: 'cursor', 'include_entities', 'skip_status' """ @@ -815,10 +794,9 @@ class API: payload_type='user', payload_list=True, allowed_param=['cursor', 'include_entities', 'skip_status'], required_auth=True - ) + )(*args, **kwargs) - @property - def create_mute(self): + def create_mute(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/accounts-and-users/mute-block-report-users/api-reference/post-mutes-users-create :allowed_param: 'id', 'user_id', 'screen_name' """ @@ -829,10 +807,9 @@ class API: payload_type='user', allowed_param=['id', 'user_id', 'screen_name'], require_auth=True - ) + )(*args, **kwargs) - @property - def destroy_mute(self): + def destroy_mute(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/accounts-and-users/mute-block-report-users/api-reference/post-mutes-users-destroy :allowed_param: 'id', 'user_id', 'screen_name' """ @@ -843,10 +820,10 @@ class API: payload_type='user', allowed_param=['id', 'user_id', 'screen_name'], require_auth=True - ) + )(*args, **kwargs) - @property - def blocks(self): + @pagination(mode='cursor') + def blocks(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/accounts-and-users/mute-block-report-users/api-reference/get-blocks-list :allowed_param: 'cursor' """ @@ -856,10 +833,10 @@ class API: payload_type='user', payload_list=True, allowed_param=['cursor'], require_auth=True - ) + )(*args, **kwargs) - @property - def blocks_ids(self): + @pagination(mode='cursor') + def blocks_ids(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/accounts-and-users/mute-block-report-users/api-reference/get-blocks-ids :allowed_param: 'cursor' """ @@ -869,10 +846,9 @@ class API: payload_type='ids', allowed_param=['cursor'], require_auth=True - ) + )(*args, **kwargs) - @property - def report_spam(self): + def report_spam(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/accounts-and-users/mute-block-report-users/api-reference/post-users-report_spam :allowed_param: 'user_id', 'screen_name', 'perform_block' """ @@ -883,20 +859,18 @@ class API: payload_type='user', allowed_param=['user_id', 'screen_name', 'perform_block'], require_auth=True - ) + )(*args, **kwargs) - @property - def saved_searches(self): + def saved_searches(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/get-saved_searches-list """ return bind_api( api=self, path='/saved_searches/list.json', payload_type='saved_search', payload_list=True, require_auth=True - ) + )(*args, **kwargs) - @property - def get_saved_search(self): + def get_saved_search(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/get-saved_searches-show-id :allowed_param: 'id' """ @@ -906,10 +880,9 @@ class API: payload_type='saved_search', allowed_param=['id'], require_auth=True - ) + )(*args, **kwargs) - @property - def create_saved_search(self): + def create_saved_search(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/post-saved_searches-create :allowed_param: 'query' """ @@ -920,10 +893,9 @@ class API: payload_type='saved_search', allowed_param=['query'], require_auth=True - ) + )(*args, **kwargs) - @property - def destroy_saved_search(self): + def destroy_saved_search(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/post-saved_searches-destroy-id :allowed_param: 'id' """ @@ -934,10 +906,9 @@ class API: payload_type='saved_search', allowed_param=['id'], require_auth=True - ) + )(*args, **kwargs) - @property - def create_list(self): + def create_list(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/post-lists-create :allowed_param: 'name', 'mode', 'description' """ @@ -948,10 +919,9 @@ class API: payload_type='list', allowed_param=['name', 'mode', 'description'], require_auth=True - ) + )(*args, **kwargs) - @property - def destroy_list(self): + def destroy_list(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/post-lists-destroy :allowed_param: 'owner_screen_name', 'owner_id', 'list_id', 'slug' """ @@ -962,10 +932,9 @@ class API: payload_type='list', allowed_param=['owner_screen_name', 'owner_id', 'list_id', 'slug'], require_auth=True - ) + )(*args, **kwargs) - @property - def update_list(self): + def update_list(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/post-lists-update :allowed_param: 'list_id', 'slug', 'name', 'mode', 'description', 'owner_screen_name', 'owner_id' @@ -978,10 +947,9 @@ class API: allowed_param=['list_id', 'slug', 'name', 'mode', 'description', 'owner_screen_name', 'owner_id'], require_auth=True - ) + )(*args, **kwargs) - @property - def lists_all(self): + def lists_all(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/get-lists-list :allowed_param: 'screen_name', 'user_id', 'reverse' """ @@ -991,10 +959,10 @@ class API: payload_type='list', payload_list=True, allowed_param=['screen_name', 'user_id', 'reverse'], require_auth=True - ) + )(*args, **kwargs) - @property - def lists_memberships(self): + @pagination(mode='cursor') + def lists_memberships(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/get-lists-memberships :allowed_param: 'screen_name', 'user_id', 'filter_to_owned_lists', 'cursor', 'count' @@ -1006,10 +974,10 @@ class API: allowed_param=['screen_name', 'user_id', 'filter_to_owned_lists', 'cursor', 'count'], require_auth=True - ) + )(*args, **kwargs) - @property - def lists_ownerships(self): + @pagination(mode='cursor') + def lists_ownerships(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/get-lists-ownerships :allowed_param: 'user_id', 'screen_name', 'count', 'cursor' """ @@ -1019,10 +987,10 @@ class API: payload_type='list', payload_list=True, allowed_param=['user_id', 'screen_name', 'count', 'cursor'], require_auth=True - ) + )(*args, **kwargs) - @property - def lists_subscriptions(self): + @pagination(mode='cursor') + def lists_subscriptions(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/get-lists-subscriptions :allowed_param: 'screen_name', 'user_id', 'cursor', 'count' """ @@ -1032,10 +1000,10 @@ class API: payload_type='list', payload_list=True, allowed_param=['screen_name', 'user_id', 'cursor', 'count'], require_auth=True - ) + )(*args, **kwargs) - @property - def list_timeline(self): + @pagination(mode='id') + def list_timeline(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/get-lists-statuses :allowed_param: 'owner_screen_name', 'slug', 'owner_id', 'list_id', 'since_id', 'max_id', 'count', 'include_entities', @@ -1048,10 +1016,9 @@ class API: allowed_param=['owner_screen_name', 'slug', 'owner_id', 'list_id', 'since_id', 'max_id', 'count', 'include_entities', 'include_rts'] - ) + )(*args, **kwargs) - @property - def get_list(self): + def get_list(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/get-lists-show :allowed_param: 'owner_screen_name', 'owner_id', 'slug', 'list_id' """ @@ -1060,10 +1027,9 @@ class API: path='/lists/show.json', payload_type='list', allowed_param=['owner_screen_name', 'owner_id', 'slug', 'list_id'] - ) + )(*args, **kwargs) - @property - def add_list_member(self): + def add_list_member(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/post-lists-members-create :allowed_param: 'screen_name', 'user_id', 'owner_screen_name', 'owner_id', 'slug', 'list_id' @@ -1076,10 +1042,9 @@ class API: allowed_param=['screen_name', 'user_id', 'owner_screen_name', 'owner_id', 'slug', 'list_id'], require_auth=True - ) + )(*args, **kwargs) - @property - def remove_list_member(self): + def remove_list_member(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/post-lists-members-destroy :allowed_param: 'screen_name', 'user_id', 'owner_screen_name', 'owner_id', 'slug', 'list_id' @@ -1092,7 +1057,7 @@ class API: allowed_param=['screen_name', 'user_id', 'owner_screen_name', 'owner_id', 'slug', 'list_id'], require_auth=True - ) + )(*args, **kwargs) def add_list_members(self, screen_name=None, user_id=None, slug=None, list_id=None, owner_id=None, owner_screen_name=None): @@ -1129,8 +1094,8 @@ class API: )(list_to_csv(screen_name), list_to_csv(user_id), slug, list_id, owner_id, owner_screen_name) - @property - def list_members(self): + @pagination(mode='cursor') + def list_members(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/get-lists-members :allowed_param: 'owner_screen_name', 'slug', 'list_id', 'owner_id', 'cursor' @@ -1141,10 +1106,9 @@ class API: payload_type='user', payload_list=True, allowed_param=['owner_screen_name', 'slug', 'list_id', 'owner_id', 'cursor'] - ) + )(*args, **kwargs) - @property - def show_list_member(self): + def show_list_member(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/get-lists-members-show :allowed_param: 'list_id', 'slug', 'user_id', 'screen_name', 'owner_screen_name', 'owner_id' @@ -1155,10 +1119,9 @@ class API: payload_type='user', allowed_param=['list_id', 'slug', 'user_id', 'screen_name', 'owner_screen_name', 'owner_id'] - ) + )(*args, **kwargs) - @property - def subscribe_list(self): + def subscribe_list(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/post-lists-subscribers-create :allowed_param: 'owner_screen_name', 'slug', 'owner_id', 'list_id' """ @@ -1169,10 +1132,9 @@ class API: payload_type='list', allowed_param=['owner_screen_name', 'slug', 'owner_id', 'list_id'], require_auth=True - ) + )(*args, **kwargs) - @property - def unsubscribe_list(self): + def unsubscribe_list(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/post-lists-subscribers-destroy :allowed_param: 'owner_screen_name', 'slug', 'owner_id', 'list_id' """ @@ -1183,10 +1145,10 @@ class API: payload_type='list', allowed_param=['owner_screen_name', 'slug', 'owner_id', 'list_id'], require_auth=True - ) + )(*args, **kwargs) - @property - def list_subscribers(self): + @pagination(mode='cursor') + def list_subscribers(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/get-lists-subscribers :allowed_param: 'owner_screen_name', 'slug', 'owner_id', 'list_id', 'cursor', 'count', 'include_entities', @@ -1199,10 +1161,9 @@ class API: allowed_param=['owner_screen_name', 'slug', 'owner_id', 'list_id', 'cursor', 'count', 'include_entities', 'skip_status'] - ) + )(*args, **kwargs) - @property - def show_list_subscriber(self): + def show_list_subscriber(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/get-lists-subscribers-show :allowed_param: 'owner_screen_name', 'slug', 'screen_name', 'owner_id', 'list_id', 'user_id' @@ -1213,19 +1174,17 @@ class API: payload_type='user', allowed_param=['owner_screen_name', 'slug', 'screen_name', 'owner_id', 'list_id', 'user_id'] - ) + )(*args, **kwargs) - @property - def trends_available(self): + def trends_available(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/trends/locations-with-trending-topics/api-reference/get-trends-available """ return bind_api( api=self, path='/trends/available.json', payload_type='json' - ) + )(*args, **kwargs) - @property - def trends_place(self): + def trends_place(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/trends/trends-for-location/api-reference/get-trends-place :allowed_param: 'id', 'exclude' """ @@ -1234,10 +1193,9 @@ class API: path='/trends/place.json', payload_type='json', allowed_param=['id', 'exclude'] - ) + )(*args, **kwargs) - @property - def trends_closest(self): + def trends_closest(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/trends/locations-with-trending-topics/api-reference/get-trends-closest :allowed_param: 'lat', 'long' """ @@ -1246,10 +1204,10 @@ class API: path='/trends/closest.json', payload_type='json', allowed_param=['lat', 'long'] - ) + )(*args, **kwargs) - @property - def search(self): + @pagination(mode='id') + def search(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/tweets/search/api-reference/get-search-tweets :allowed_param: 'q', 'lang', 'locale', 'since_id', 'geocode', 'max_id', 'until', 'result_type', 'count', @@ -1262,7 +1220,7 @@ class API: allowed_param=['q', 'lang', 'locale', 'since_id', 'geocode', 'max_id', 'until', 'result_type', 'count', 'include_entities'] - ) + )(*args, **kwargs) @pagination(mode='next') def search_30_day(self, environment_name, *args, **kwargs): @@ -1294,8 +1252,7 @@ class API: require_auth=True )(*args, **kwargs) - @property - def reverse_geocode(self): + def reverse_geocode(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/geo/places-near-location/api-reference/get-geo-reverse_geocode :allowed_param: 'lat', 'long', 'accuracy', 'granularity', 'max_results' @@ -1306,10 +1263,9 @@ class API: payload_type='place', payload_list=True, allowed_param=['lat', 'long', 'accuracy', 'granularity', 'max_results'] - ) + )(*args, **kwargs) - @property - def geo_id(self): + def geo_id(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/geo/place-information/api-reference/get-geo-id-place_id :allowed_param: 'id' """ @@ -1318,10 +1274,9 @@ class API: path='/geo/id/{id}.json', payload_type='place', allowed_param=['id'] - ) + )(*args, **kwargs) - @property - def geo_search(self): + def geo_search(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/geo/places-near-location/api-reference/get-geo-search :allowed_param: 'lat', 'long', 'query', 'ip', 'granularity', 'accuracy', 'max_results', 'contained_within' @@ -1333,27 +1288,25 @@ class API: payload_type='place', payload_list=True, allowed_param=['lat', 'long', 'query', 'ip', 'granularity', 'accuracy', 'max_results', 'contained_within'] - ) + )(*args, **kwargs) - @property - def supported_languages(self): + def supported_languages(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/developer-utilities/supported-languages/api-reference/get-help-languages """ return bind_api( api=self, path='/help/languages.json', payload_type='json', require_auth=True - ) + )(*args, **kwargs) - @property - def configuration(self): + def configuration(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/developer-utilities/configuration/api-reference/get-help-configuration """ return bind_api( api=self, path='/help/configuration.json', payload_type='json', require_auth=True - ) + )(*args, **kwargs) """ Internal use only """ diff --git a/tweepy/binder.py b/tweepy/binder.py index f978aec..68cc66d 100644 --- a/tweepy/binder.py +++ b/tweepy/binder.py @@ -239,18 +239,6 @@ def bind_api(**config): finally: method.session.close() - # Set pagination mode - if 'cursor' in APIMethod.allowed_param: - 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' - elif 'page' in APIMethod.allowed_param: - _call.pagination_mode = 'page' - return _call