3 _=\}@slddlmZddlZddlZddlZddlmZddlmZddl m Z m Z ddl m Z GdddeZdS) )print_functionN)bind_api) TweepError) ModelParserParser) list_to_csvc@steZdZdZdd d Zed dZdddZeddZeddZ eddZ eddZ eddZ eddZ ddZdd Zd!d"Zed#d$Zed%d&Zed'd(Zed)d*Zed+d,Zed-d.Zed/d0Zdd1d2Zed3d4Zd5d6Zed7d8Zed9d:Zed;d<Zed=d>Zed?d@ZedAdBZ edCdDZ!edEdFZ"edGdHZ#edIdJZ$edKdLZ%edMdNZ&ddOdPZ'edQdRZ(edSdTZ)edUdVZ*edWdXZ+edYdZZ,ed[d\Z-ed]d^Z.ed_d`Z/edadbZ0dcddZ1ededfZ2edgdhZ3ddidjZ4dkdlZ5dmdnZ6edodpZ7edqdrZ8edsdtZ9edudvZ:edwdxZ;edydzZeddZ?eddZ@eddZAeddZBeddZCeddZDeddZEeddZFeddZGeddZHeddZIeddZJeddZKeddZLeddZMeddZNeddZOeddZPdddZQeddZRdddZSeddZTeddZUeddZVeddZWeddZXeddZYeddZZeddZ[eddZ\eddZ]eddZ^eddZ_edd„Z`eddĄZaeddƄZbeddȄZceddʄZdeeddd̈́ZfdS)APIz Twitter APINapi.twitter.comsearch.twitter.comupload.twitter.com/1.1r<FcCs||_||_||_||_||_||_||_||_||_| |_ | |_ | |_ | |_ ||_ ||_| pbt|_i|_|rz||jd<t}t|j|stdj|jt|jddS)ap Api instance Constructor :param auth_handler: :param host: url of the server of the rest api, default:'api.twitter.com' :param search_host: url of the search server, default:'search.twitter.com' :param upload_host: url of the upload server, default:'upload.twitter.com' :param cache: Cache to query if a GET method is used, default:None :param api_root: suffix of the api version, default:'/1.1' :param search_root: suffix of the search version, default:'' :param upload_root: suffix of the upload version, default:'/1.1' :param retry_count: number of allowed retries, default:0 :param retry_delay: delay in second between retries, default:0 :param retry_errors: default:None :param timeout: delay before to consider the request as timed out in seconds, default:60 :param parser: ModelParser instance to parse the responses, default:None :param compression: If the response is compressed, default:False :param wait_on_rate_limit: If the api wait when it hits the rate limit, default:False :param wait_on_rate_limit_notify: If the api print a notification when the rate limit is hit, default:False :param proxy: Url to use as proxy during the HTTP request, default:'' :raise TypeError: If the given parser is not a ModelParser instance. httpszT"parser" argument has to be an instance of "{required}". It is currently a {actual}.)requiredactualN)authhost search_host upload_hostapi_root search_root upload_rootcache compression retry_count retry_delay retry_errorstimeoutwait_on_rate_limitwait_on_rate_limit_notifyrparserproxyr isinstance TypeErrorformat__name__type)selfZ auth_handlerrrrrrrrrrrrr!rrr r"Z parser_typer)b/private/var/folders/47/550316q90kl84vt_jn5ctz8chwmm0c/T/pip-install-yoigbb1v/tweepy/tweepy/api.py__init__s2   z API.__init__cCst|ddddddgddS)z :reference: https://dev.twitter.com/rest/reference/get/statuses/home_timeline :allowed_param:'since_id', 'max_id', 'count' z/statuses/home_timeline.jsonstatusTsince_idmax_idcount)apipath payload_type payload_list allowed_param require_auth)r)r(r)r)r* home_timelineSs zAPI.home_timelinecCs|jt|||||S)N)_statuses_lookupr)r(Zid_include_entities trim_userZmap_ tweet_moder)r)r*statuses_lookup`s zAPI.statuses_lookupc Cst|ddddddddgdd S) z :reference: https://dev.twitter.com/rest/reference/get/statuses/lookup :allowed_param:'id', 'include_entities', 'trim_user', 'map', 'tweet_mode' z/statuses/lookup.jsonr,Tidr8r9mapr:)r0r1r2r3r4r5)r)r(r)r)r*r7es  zAPI._statuses_lookupcCs$t|ddddddddd d d d g d S)z :reference: https://dev.twitter.com/rest/reference/get/statuses/user_timeline :allowed_param:'id', 'user_id', 'screen_name', 'since_id', 'max_id', 'count', 'include_rts', 'trim_user', 'exclude_replies' z/statuses/user_timeline.jsonr,Tr<user_id screen_namer-r.r/ include_rtsr9Zexclude_replies)r0r1r2r3r4)r)r(r)r)r* user_timelinerszAPI.user_timelinecCst|ddddddgddS)z :reference: https://dev.twitter.com/rest/reference/get/statuses/mentions_timeline :allowed_param:'since_id', 'max_id', 'count' z /statuses/mentions_timeline.jsonr,Tr-r.r/)r0r1r2r3r4r5)r)r(r)r)r*mentions_timelines zAPI.mentions_timelinecCst|ddddgddS)z :reference: https://dev.twitter.com/docs/api/1.1/get/related_results/show/%3id.format :allowed_param:'id' z/related_results/show/{id}.jsonZrelationTr<F)r0r1r2r3r4r5)r)r(r)r)r*related_resultss zAPI.related_resultscCst|ddddddgddS)z :reference: https://dev.twitter.com/rest/reference/get/statuses/retweets_of_me :allowed_param:'since_id', 'max_id', 'count' z/statuses/retweets_of_me.jsonr,Tr-r.r/)r0r1r2r3r4r5)r)r(r)r)r*retweets_of_mes zAPI.retweets_of_mecCst|dddgdS)zt :reference: https://dev.twitter.com/rest/reference/get/statuses/show/%3Aid :allowed_param:'id' z/statuses/show.jsonr,r<)r0r1r2r4)r)r(r)r)r* get_statuss zAPI.get_statuscOsXi}|jdd}|dk r$t||d<t|dddddddd d d d d g dd|d|i|S)a :reference: https://dev.twitter.com/rest/reference/post/statuses/update :allowed_param:'status', 'in_reply_to_status_id', 'in_reply_to_status_id_str', 'auto_populate_reply_metadata', 'lat', 'long', 'source', 'place_id', 'display_coordinates', 'media_ids' media_idsNz/statuses/update.jsonPOSTr,in_reply_to_status_idin_reply_to_status_id_strauto_populate_reply_metadatalatlongsourceplace_iddisplay_coordinatesT)r0r1methodr2r4r5 post_data)poprr)r(argskwargsrQrFr)r)r* update_statuss  zAPI.update_statusc OsN|jdd}tj|dd|d\}}|j||dt|dddgd d d ||S) zj :reference: https://dev.twitter.com/rest/reference/post/media/upload :allowed_param: fileNiZmedia) form_fieldf)headersrQz/media/upload.jsonrGT)r0r1rPr2r4r5Z upload_api)rRr _pack_imageupdater)r(filenamerSrTrXrYrQr)r)r* media_uploads zAPI.media_uploadcOs^|jdd}tj|dd|d\}}|j||dt|ddd d d d d d ddddg dd||S)a :reference: https://dev.twitter.com/rest/reference/post/statuses/update_with_media :allowed_param:'status', 'possibly_sensitive', 'in_reply_to_status_id', 'in_reply_to_status_id_str', 'auto_populate_reply_metadata', 'lat', 'long', 'place_id', 'display_coordinates' rVNi zmedia[])rWrX)rYrQz /statuses/update_with_media.jsonrGr,Zpossibly_sensitiverHrIrJrKrLrNrOT)r0r1rPr2r4r5)rRrrZr[r)r(r\rSrTrXrYrQr)r)r*update_with_medias  zAPI.update_with_mediacCst|ddddgddS)zx :reference: https://dev.twitter.com/rest/reference/post/statuses/destroy/%3Aid :allowed_param:'id' z/statuses/destroy/{id}.jsonrGr,r<T)r0r1rPr2r4r5)r)r(r)r)r*destroy_statusszAPI.destroy_statuscCst|ddddgddS)zx :reference: https://dev.twitter.com/rest/reference/post/statuses/retweet/%3Aid :allowed_param:'id' z/statuses/retweet/{id}.jsonrGr,r<T)r0r1rPr2r4r5)r)r(r)r)r*retweetsz API.retweetcCst|ddddgddS)zz :reference: https://dev.twitter.com/rest/reference/post/statuses/unretweet/%3Aid :allowed_param:'id' z/statuses/unretweet/{id}.jsonrGr,r<T)r0r1rPr2r4r5)r)r(r)r)r* unretweetsz API.unretweetcCst|dddddgddS)z :reference: https://dev.twitter.com/rest/reference/get/statuses/retweets/%3Aid :allowed_param:'id', 'count' z/statuses/retweets/{id}.jsonr,Tr<r/)r0r1r2r3r4r5)r)r(r)r)r*retweetss z API.retweetscCst|dddddgdS)z :reference: https://dev.twitter.com/rest/reference/get/statuses/retweeters/ids :allowed_param:'id', 'cursor', 'stringify_ids z/statuses/retweeters/ids.jsonidsr<cursorZ stringify_ids)r0r1r2r4)r)r(r)r)r* retweeters"s zAPI.retweeterscCst|dddddgdS)z :reference: https://dev.twitter.com/rest/reference/get/users/show :allowed_param:'id', 'user_id', 'screen_name' z/users/show.jsonuserr<r>r?)r0r1r2r4)r)r(r)r)r*get_user.s z API.get_userc Cs t|ddddddddd d gd S) z :reference: https://dev.twitter.com/rest/reference/get/statuses/oembed :allowed_param:'id', 'url', 'maxwidth', 'hide_media', 'omit_script', 'align', 'related', 'lang' z/statuses/oembed.jsonjsonr<urlZmaxwidthZ hide_mediaZ omit_scriptZalignrelatedlang)r0r1r2r4)r)r(r)r)r* get_oembed:s zAPI.get_oembedcCsXi}|dk r |rdnd}||d<|r0t||d<|r@t||d<|rL||d<|j|dS) z; Perform bulk look up of users from user ID or screen_name Ntruefalser8r>r?r:)rQ)r _lookup_users)r(user_ids screen_namesr8r:rQr)r)r* lookup_usersFs   zAPI.lookup_usersc Cst|ddddddddgd S) z :reference: https://dev.twitter.com/rest/reference/get/users/lookup allowed_param='user_id', 'screen_name', 'include_entities', 'tweet_mode' z/users/lookup.jsonrfTrGr>r?r8r:)r0r1r2r3rPr4)r)r(r)r)r*roUs zAPI._lookup_userscCs|j|jjdS)z Get the authenticated user )r?)rgrZ get_username)r(r)r)r*mebszAPI.mec Cst|dddddddgdS)z} :reference: https://dev.twitter.com/rest/reference/get/users/search :allowed_param:'q', 'count', 'page' z/users/search.jsonrfTqr/page)r0r1r2r3r5r4)r)r(r)r)r* search_usersfs zAPI.search_userscCst|ddddddgdS)z :reference: https://dev.twitter.com/rest/reference/get/users/suggestions/%3Aslug :allowed_param:'slug', 'lang' z/users/suggestions/{slug}.jsonrfTslugrk)r0r1r2r3r5r4)r)r(r)r)r*suggested_usersss zAPI.suggested_userscCst|ddddgddS)zt :reference: https://dev.twitter.com/rest/reference/get/users/suggestions :allowed_param:'lang' z/users/suggestions.jsoncategoryTrk)r0r1r2r3r4r5)r)r(r)r)r*suggested_categoriess zAPI.suggested_categoriescCst|ddddgddS)z :reference: https://dev.twitter.com/rest/reference/get/users/suggestions/%3Aslug/members :allowed_param:'slug' z&/users/suggestions/{slug}/members.jsonr,Trw)r0r1r2r3r4r5)r)r(r)r)r*suggested_users_tweetss zAPI.suggested_users_tweetsc Cst|dddddddgddS) z :reference: https://dev.twitter.com/rest/reference/get/direct_messages :allowed_param:'since_id', 'max_id', 'count', 'full_text' z/direct_messages.jsondirect_messageTr-r.r/ full_text)r0r1r2r3r4r5)r)r(r)r)r*direct_messagess  zAPI.direct_messagescCst|ddddgddS)z :reference: https://dev.twitter.com/rest/reference/get/direct_messages/show :allowed_param:'id', 'full_text' z/direct_messages/show/{id}.jsonr|r<r}T)r0r1r2r4r5)r)r(r)r)r*get_direct_messages zAPI.get_direct_messagec Cst|ddddddddgdd S) z :reference: https://dev.twitter.com/rest/reference/get/direct_messages/sent :allowed_param:'since_id', 'max_id', 'count', 'page', 'full_text' z/direct_messages/sent.jsonr|Tr-r.r/rur})r0r1r2r3r4r5)r)r(r)r)r*sent_direct_messagess  zAPI.sent_direct_messagesc Cst|dddddddgdd S) z :reference: https://dev.twitter.com/rest/reference/post/direct_messages/new :allowed_param:'user', 'screen_name', 'user_id', 'text' z/direct_messages/new.jsonrGr|rfr?r>textT)r0r1rPr2r4r5)r)r(r)r)r*send_direct_messages zAPI.send_direct_messagecCst|ddddgddS)zy :reference: https://dev.twitter.com/rest/reference/post/direct_messages/destroy :allowed_param:'id' z/direct_messages/destroy.jsonrGr|r<T)r0r1rPr2r4r5)r)r(r)r)r*destroy_direct_messageszAPI.destroy_direct_messagec Cst|dddddddgdd S) z :reference: https://dev.twitter.com/rest/reference/post/friendships/create :allowed_param:'id', 'user_id', 'screen_name', 'follow' z/friendships/create.jsonrGrfr<r>r?followT)r0r1rPr2r4r5)r)r(r)r)r*create_friendships zAPI.create_friendshipcCst|ddddddgddS) z :reference: https://dev.twitter.com/rest/reference/post/friendships/destroy :allowed_param:'id', 'user_id', 'screen_name' z/friendships/destroy.jsonrGrfr<r>r?T)r0r1rPr2r4r5)r)r(r)r)r*destroy_friendshipszAPI.destroy_friendshipcCst|ddddddgdS)z :reference: https://dev.twitter.com/rest/reference/get/friendships/show :allowed_param:'source_id', 'source_screen_name', 'target_id', 'target_screen_name' z/friendships/show.jsonZ friendshipZ source_idZsource_screen_nameZ target_idZtarget_screen_name)r0r1r2r4)r)r(r)r)r*show_friendships zAPI.show_friendshipcCs|jt|t|S)z@ Perform bulk look up of friendships from user ID or screenname )_lookup_friendshipsr)r(rprqr)r)r*lookup_friendshipsszAPI.lookup_friendshipscCst|dddddgddS)z :reference: https://dev.twitter.com/rest/reference/get/friendships/lookup :allowed_param:'user_id', 'screen_name' z/friendships/lookup.jsonZ relationshipTr>r?)r0r1r2r3r4r5)r)r(r)r)r*r s zAPI._lookup_friendshipscCst|ddddddgdS)z :reference: https://dev.twitter.com/rest/reference/get/friends/ids :allowed_param:'id', 'user_id', 'screen_name', 'cursor' z/friends/ids.jsonrcr<r>r?rd)r0r1r2r4)r)r(r)r)r* friends_idss zAPI.friends_idsc Cst|ddddddddd gd S) z :reference: https://dev.twitter.com/rest/reference/get/friends/list :allowed_param:'id', 'user_id', 'screen_name', 'cursor', 'skip_status', 'include_user_entities' z/friends/list.jsonrfTr<r>r?rd skip_statusinclude_user_entities)r0r1r2r3r4)r)r(r)r)r*friends#s z API.friendscCst|dddgdS)zy :reference: https://dev.twitter.com/rest/reference/get/friendships/incoming :allowed_param:'cursor' z/friendships/incoming.jsonrcrd)r0r1r2r4)r)r(r)r)r*friendships_incoming/s zAPI.friendships_incomingcCst|dddgdS)zy :reference: https://dev.twitter.com/rest/reference/get/friendships/outgoing :allowed_param:'cursor' z/friendships/outgoing.jsonrcrd)r0r1r2r4)r)r(r)r)r*friendships_outgoing;s zAPI.friendships_outgoingc Cst|dddddddgdS) z :reference: https://dev.twitter.com/rest/reference/get/followers/ids :allowed_param:'id', 'user_id', 'screen_name', 'cursor', 'count' z/followers/ids.jsonrcr<r>r?rdr/)r0r1r2r4)r)r(r)r)r* followers_idsGs zAPI.followers_idsc Cs t|ddddddddd d gd S) z :reference: https://dev.twitter.com/rest/reference/get/followers/list :allowed_param:'id', 'user_id', 'screen_name', 'cursor', 'count', 'skip_status', 'include_user_entities' z/followers/list.jsonrfTr<r>r?rdr/rr)r0r1r2r3r4)r)r(r)r)r* followersSs  z API.followerscCst|ddddS)zQ :reference: https://dev.twitter.com/rest/reference/get/account/settings z/account/settings.jsonrhF)r0r1r2 use_cache)r)r(r)r)r* get_settings`s zAPI.get_settingsc Cs"t|ddddddddd d gd d S) a  :reference: https://dev.twitter.com/rest/reference/post/account/settings :allowed_param:'sleep_time_enabled', 'start_sleep_time', 'end_sleep_time', 'time_zone', 'trend_location_woeid', 'allow_contributor_request', 'lang' z/account/settings.jsonrGrhZsleep_time_enabledZstart_sleep_timeZend_sleep_timeZ time_zoneZtrend_location_woeidZallow_contributor_requestrkF)r0r1rPr2r4r)r)r(r)r)r* set_settingskszAPI.set_settingscKs^yt|ddddddgdf|Stk rX}z|jrF|jjdkrFd SWYd d }~XnXd S) z :reference: https://dev.twitter.com/rest/reference/get/account/verify_credentials :allowed_param:'include_entities', 'skip_status', 'include_email' z /account/verify_credentials.jsonrfTr8rZ include_email)r0r1r2r5r4iFN)rrresponser,)r(kargser)r)r*verify_credentials~szAPI.verify_credentialscCst|dddgddS)z :reference: https://dev.twitter.com/rest/reference/get/application/rate_limit_status :allowed_param:'resources' z#/application/rate_limit_status.jsonrh resourcesF)r0r1r2r4r)r)r(r)r)r*rate_limit_statuss zAPI.rate_limit_statuscCst|dddgdddS)z :reference: https://dev.twitter.com/rest/reference/post/account/update_delivery_device :allowed_param:'device' z$/account/update_delivery_device.jsonrGZdevicerfT)r0r1rPr4r2r5)r)r(r)r)r*set_delivery_deviceszAPI.set_delivery_devicecCs6tj|d|d\}}t|dddddgdd |||d S) z :reference: https://dev.twitter.com/rest/reference/post/account/update_profile_image :allowed_param:'include_entities', 'skip_status' i)rXz"/account/update_profile_image.jsonrGrfr8rT)r0r1rPr2r4r5)rQrY)rrZr)r(r\file_rYrQr)r)r*update_profile_imageszAPI.update_profile_imagec KsH|jdd}tj|d|d\}}t|ddddd d d gd d ||ddS)z :reference: https://dev.twitter.com/rest/reference/post/account/update_profile_background_image :allowed_param:'tile', 'include_entities', 'skip_status', 'use' rVNi )rXz-/account/update_profile_background_image.jsonrGrfZtiler8rZuseT)r0r1rPr2r4r5)rQrY)rRrrZr)r(r\rrXrYrQr)r)r*update_profile_background_images  z#API.update_profile_background_imagecKsH|jdd}tj|dd|d\}}t|dddd d d gd d ||ddS)z :reference: https://dev.twitter.com/rest/reference/post/account/update_profile_banner :allowed_param:'width', 'height', 'offset_left', 'offset_right' rVNiZbanner)rWrXz#/account/update_profile_banner.jsonrGwidthheightZ offset_leftZ offset_rightT)r0r1rPr4r5)rQrY)rRrrZr)r(r\rrXrYrQr)r)r*update_profile_banners  zAPI.update_profile_bannerc Cst|ddddddddgd d S) z :reference: https://dev.twitter.com/rest/reference/post/account/update_profile :allowed_param:'name', 'url', 'location', 'description', 'profile_link_color' z/account/update_profile.jsonrGrfnamerilocation descriptionZprofile_link_colorT)r0r1rPr2r4r5)r)r(r)r)r*update_profiles zAPI.update_profilec Cst|dddddddddgd S) z :reference: https://dev.twitter.com/rest/reference/get/favorites/list :allowed_param:'screen_name', 'user_id', 'max_id', 'count', 'since_id', 'max_id' z/favorites/list.jsonr,Tr?r>r.r/r-)r0r1r2r3r4)r)r(r)r)r* favoritess z API.favoritescCst|ddddgddS)zq :reference:https://dev.twitter.com/rest/reference/post/favorites/create :allowed_param:'id' z/favorites/create.jsonrGr,r<T)r0r1rPr2r4r5)r)r(r)r)r*create_favoriteszAPI.create_favoritecCst|ddddgddS)zs :reference: https://dev.twitter.com/rest/reference/post/favorites/destroy :allowed_param:'id' z/favorites/destroy.jsonrGr,r<T)r0r1rPr2r4r5)r)r(r)r)r*destroy_favoriteszAPI.destroy_favoritecCst|ddddddgddS) z :reference: https://dev.twitter.com/rest/reference/post/blocks/create :allowed_param:'id', 'user_id', 'screen_name' z/blocks/create.jsonrGrfr<r>r?T)r0r1rPr2r4r5)r)r(r)r)r* create_block szAPI.create_blockcCst|ddddddgddS) z :reference: https://dev.twitter.com/rest/reference/post/blocks/destroy :allowed_param:'id', 'user_id', 'screen_name' z/blocks/destroy.jsonrGrfr<r>r?T)r0r1rPr2r4r5)r)r(r)r)r* destroy_blockszAPI.destroy_blockcCst|ddddS)zH :reference: https://dev.twitter.com/rest/reference/get/mutes/users/ids z/mutes/users/ids.jsonrhT)r0r1r2r5)r)r(r)r)r* mutes_ids's z API.mutes_idscCst|ddddddgddS) z :reference: https://dev.twitter.com/rest/reference/post/mutes/users/create :allowed_param:'id', 'user_id', 'screen_name' z/mutes/users/create.jsonrGrfr<r>r?T)r0r1rPr2r4r5)r)r(r)r)r* create_mute1szAPI.create_mutecCst|ddddddgddS) z :reference: https://dev.twitter.com/rest/reference/post/mutes/users/destroy :allowed_param:'id', 'user_id', 'screen_name' z/mutes/users/destroy.jsonrGrfr<r>r?T)r0r1rPr2r4r5)r)r(r)r)r* destroy_mute?szAPI.destroy_mutecCst|ddddgddS)zp :reference: https://dev.twitter.com/rest/reference/get/blocks/list :allowed_param:'cursor' z/blocks/list.jsonrfTrd)r0r1r2r3r4r5)r)r(r)r)r*blocksOs z API.blockscCst|ddddS)zC :reference: https://dev.twitter.com/rest/reference/get/blocks/ids z/blocks/ids.jsonrhT)r0r1r2r5)r)r(r)r)r* blocks_ids\s zAPI.blocks_idscCst|dddddgddS)z :reference: https://dev.twitter.com/rest/reference/post/users/report_spam :allowed_param:'user_id', 'screen_name' z/users/report_spam.jsonrGrfr>r?T)r0r1rPr2r4r5)r)r(r)r)r* report_spamfszAPI.report_spamcCst|dddddS)zR :reference: https://dev.twitter.com/rest/reference/get/saved_searches/show/%3Aid z/saved_searches/list.json saved_searchT)r0r1r2r3r5)r)r(r)r)r*saved_searchests zAPI.saved_searchescCst|dddgddS)zz :reference: https://dev.twitter.com/rest/reference/get/saved_searches/show/%3Aid :allowed_param:'id' z/saved_searches/show/{id}.jsonrr<T)r0r1r2r4r5)r)r(r)r)r*get_saved_search~s zAPI.get_saved_searchcCst|ddddgddS)zz :reference: https://dev.twitter.com/rest/reference/post/saved_searches/create :allowed_param:'query' z/saved_searches/create.jsonrGrqueryT)r0r1rPr2r4r5)r)r(r)r)r*create_saved_searchszAPI.create_saved_searchcCst|ddddgddS)z~ :reference: https://dev.twitter.com/rest/reference/post/saved_searches/destroy/%3Aid :allowed_param:'id' z!/saved_searches/destroy/{id}.jsonrGrr<T)r0r1rPr2r4r5)r)r(r)r)r*destroy_saved_searchszAPI.destroy_saved_searchcCst|ddddddgddS) z :reference: https://dev.twitter.com/rest/reference/post/lists/create :allowed_param:'name', 'mode', 'description' z/lists/create.jsonrGlistrmoderT)r0r1rPr2r4r5)r)r(r)r)r* create_listszAPI.create_listc Cst|dddddddgdd S) z :reference: https://dev.twitter.com/rest/reference/post/lists/destroy :allowed_param:'owner_screen_name', 'owner_id', 'list_id', 'slug' z/lists/destroy.jsonrGrowner_screen_nameowner_idlist_idrwT)r0r1rPr2r4r5)r)r(r)r)r* destroy_lists zAPI.destroy_listc Cs"t|ddddddddd d gd d S) z :reference: https://dev.twitter.com/rest/reference/post/lists/update :allowed_param: list_id', 'slug', 'name', 'mode', 'description', 'owner_screen_name', 'owner_id' z/lists/update.jsonrGrrrwrrrrrT)r0r1rPr2r4r5)r)r(r)r)r* update_listszAPI.update_listcCst|dddddgddS)z :reference: https://dev.twitter.com/rest/reference/get/lists/list :allowed_param:'screen_name', 'user_id' z/lists/list.jsonrTr?r>)r0r1r2r3r4r5)r)r(r)r)r* lists_alls z API.lists_allc Cst|dddddddgddS) z :reference: https://dev.twitter.com/rest/reference/get/lists/memberships :allowed_param:'screen_name', 'user_id', 'filter_to_owned_lists', 'cursor' z/lists/memberships.jsonrTr?r>Zfilter_to_owned_listsrd)r0r1r2r3r4r5)r)r(r)r)r*lists_membershipss  zAPI.lists_membershipscCst|ddddddgddS)z :reference: https://dev.twitter.com/rest/reference/get/lists/subscriptions :allowed_param:'screen_name', 'user_id', 'cursor' z/lists/subscriptions.jsonrTr?r>rd)r0r1r2r3r4r5)r)r(r)r)r*lists_subscriptionss zAPI.lists_subscriptionsc Cs"t|ddddddddd d d gd S) z :reference: https://dev.twitter.com/docs/api/1.1/get/lists/statuses :allowed_param:'owner_screen_name', 'slug', 'owner_id', 'list_id', 'since_id', 'max_id', 'count', 'include_rts z/lists/statuses.jsonr,Trrwrrr-r.r/r@)r0r1r2r3r4)r)r(r)r)r* list_timelineszAPI.list_timelinecCst|ddddddgdS)z :reference: https://dev.twitter.com/rest/reference/get/lists/show :allowed_param:'owner_screen_name', 'owner_id', 'slug', 'list_id' z/lists/show.jsonrrrrwr)r0r1r2r4)r)r(r)r)r*get_lists z API.get_listc Cs t|ddddddddd gd d S) z :reference: https://dev.twitter.com/docs/api/1.1/post/lists/members/create :allowed_param:'screen_name', 'user_id', 'owner_screen_name', 'owner_id', 'slug', 'list_id' z/lists/members/create.jsonrGrr?r>rrrwrT)r0r1rPr2r4r5)r)r(r)r)r*add_list_memberszAPI.add_list_memberc Cs t|ddddddddd gd d S) z :reference: https://dev.twitter.com/docs/api/1.1/post/lists/members/destroy :allowed_param:'screen_name', 'user_id', 'owner_screen_name', 'owner_id', 'slug', 'list_id' z/lists/members/destroy.jsonrGrr?r>rrrwrT)r0r1rPr2r4r5)r)r(r)r)r*remove_list_member#szAPI.remove_list_membercCs|jt|t|||||S)z= Perform bulk add of list members from user ID or screenname )_add_list_membersr)r(r?r>rwrrrr)r)r*add_list_members3s zAPI.add_list_membersc Cs t|ddddddddd gd d S) z :reference: https://dev.twitter.com/docs/api/1.1/post/lists/members/create_all :allowed_param:'screen_name', 'user_id', 'slug', 'list_id', 'owner_id', 'owner_screen_name' z/lists/members/create_all.jsonrGrr?r>rwrrrT)r0r1rPr2r4r5)r)r(r)r)r*r;szAPI._add_list_memberscCs|jt|t|||||S)z@ Perform bulk remove of list members from user ID or screenname )_remove_list_membersr)r(r?r>rwrrrr)r)r*remove_list_membersLs zAPI.remove_list_membersc Cs t|ddddddddd gd d S) z :reference: https://dev.twitter.com/docs/api/1.1/post/lists/members/destroy_all :allowed_param:'screen_name', 'user_id', 'slug', 'list_id', 'owner_id', 'owner_screen_name' z/lists/members/destroy_all.jsonrGrr?r>rwrrrT)r0r1rPr2r4r5)r)r(r)r)r*rTszAPI._remove_list_membersc Cst|ddddddddgd S) z :reference: https://dev.twitter.com/docs/api/1.1/get/lists/members :allowed_param:'owner_screen_name', 'slug', 'list_id', 'owner_id', 'cursor z/lists/members.jsonrfTrrwrrrd)r0r1r2r3r4)r)r(r)r)r* list_memberses zAPI.list_membersc Cst|ddddddddgd S) z :reference: https://dev.twitter.com/docs/api/1.1/get/lists/members/show :allowed_param:'list_id', 'slug', 'user_id', 'screen_name', 'owner_screen_name', 'owner_id z/lists/members/show.jsonrfrrwr>r?rr)r0r1r2r4)r)r(r)r)r*show_list_memberss zAPI.show_list_memberc Cst|dddddddgdd S) z :reference: https://dev.twitter.com/docs/api/1.1/post/lists/subscribers/create :allowed_param:'owner_screen_name', 'slug', 'owner_id', 'list_id' z/lists/subscribers/create.jsonrGrrrwrrT)r0r1rPr2r4r5)r)r(r)r)r*subscribe_listszAPI.subscribe_listc Cst|dddddddgdd S) z :reference: https://dev.twitter.com/docs/api/1.1/post/lists/subscribers/destroy :allowed_param:'owner_screen_name', 'slug', 'owner_id', 'list_id' z/lists/subscribers/destroy.jsonrGrrrwrrT)r0r1rPr2r4r5)r)r(r)r)r*unsubscribe_listszAPI.unsubscribe_listc Cst|ddddddddgd S) z :reference: https://dev.twitter.com/docs/api/1.1/get/lists/subscribers :allowed_param:'owner_screen_name', 'slug', 'owner_id', 'list_id', 'cursor z/lists/subscribers.jsonrfTrrwrrrd)r0r1r2r3r4)r)r(r)r)r*list_subscriberss zAPI.list_subscribersc Cst|ddddddddgd S) z :reference: https://dev.twitter.com/docs/api/1.1/get/lists/subscribers/show :allowed_param:'owner_screen_name', 'slug', 'screen_name', 'owner_id', 'list_id', 'user_id z/lists/subscribers/show.jsonrfrrwr?rrr>)r0r1r2r4)r)r(r)r)r*show_list_subscribers zAPI.show_list_subscribercCst|dddS)zI :reference: https://dev.twitter.com/rest/reference/get/trends/available z/trends/available.jsonrh)r0r1r2)r)r(r)r)r*trends_availableszAPI.trends_availablecCst|ddddgdS)zx :reference: https://dev.twitter.com/rest/reference/get/trends/place :allowed_param:'id', 'exclude' z/trends/place.jsonrhr<exclude)r0r1r2r4)r)r(r)r)r* trends_places zAPI.trends_placecCst|ddddgdS)zx :reference: https://dev.twitter.com/rest/reference/get/trends/closest :allowed_param:'lat', 'long' z/trends/closest.jsonrhrKrL)r0r1r2r4)r)r(r)r)r*trends_closests zAPI.trends_closestcCs,t|ddddddddd d d d d dddgdS)a :reference: https://dev.twitter.com/rest/reference/get/search/tweets :allowed_param:'q', 'lang', 'locale', 'since_id', 'geocode', 'max_id', 'since', 'until', 'result_type', 'count', 'include_entities', 'from', 'to', 'source' z/search/tweets.jsonZsearch_resultsrtrklocaler-Zgeocoder.ZsinceZuntilZ result_typer/r8fromZtorM)r0r1r2r4)r)r(r)r)r*searchs z API.searchc Cst|ddddddddgd S) z :reference: https://dev.twitter.com/rest/reference/get/geo/reverse_geocode :allowed_param:'lat', 'long', 'accuracy', 'granularity', 'max_results' z/geo/reverse_geocode.jsonplaceTrKrLaccuracy granularity max_results)r0r1r2r3r4)r)r(r)r)r*reverse_geocodes zAPI.reverse_geocodecCst|dddgdS)zs :reference: https://dev.twitter.com/rest/reference/get/geo/id/%3Aplace_id :allowed_param:'id' z/geo/id/{id}.jsonrr<)r0r1r2r4)r)r(r)r)r*geo_ids z API.geo_idc Cs"t|ddddddddd d d gd S) z :reference: https://dev.twitter.com/docs/api/1.1/get/geo/search :allowed_param:'lat', 'long', 'query', 'ip', 'granularity', 'accuracy', 'max_results', 'contained_within z/geo/search.jsonrTrKrLriprrrcontained_within)r0r1r2r3r4)r)r(r)r)r* geo_searchs  zAPI.geo_searchc Cst|dddddddgdS) z :reference: https://dev.twitter.com/rest/reference/get/geo/similar_places :allowed_param:'lat', 'long', 'name', 'contained_within' z/geo/similar_places.jsonrTrKrLrr)r0r1r2r3r4)r)r(r)r)r*geo_similar_placess zAPI.geo_similar_placescCst|ddddS)zG :reference: https://dev.twitter.com/rest/reference/get/help/languages z/help/languages.jsonrhT)r0r1r2r5)r)r(r)r)r*supported_languages#s zAPI.supported_languagescCst|ddddS)zK :reference: https://dev.twitter.com/rest/reference/get/help/configuration z/help/configuration.jsonrhT)r0r1r2r5)r)r(r)r)r* configuration-s zAPI.configurationimagec Cs|dkrly$tjj||dkr*td|Wn2tjk r^}ztd|jWYdd}~XnXt|d}n6|jdd|j|dkrtd||jd|}t j |}|dkrtd|d}|dkrtd |t |t j r|jd }d}g}|jd||jdj||jd |jdj|jd |jd|j|j|jd|d|jd|jdj|}dtt|d} | |fS)z6Pack image from file into multipart-formdata post bodyNiz(File is too big, must be less than %skb.zUnable to access file: %srbrzCould not determine file type image/gif image/jpeg image/pngzInvalid file type for image: %szutf-8sTw3ePys--z:Content-Disposition: form-data; name="{0}"; filename="{1}"zContent-Type: {0}s z$multipart/form-data; boundary=Tw3ePy)z Content-TypezContent-Length)rrr)osr1getsizererrorstrerroropenseektell mimetypes guess_typer#six text_typeencodeappendr%readclosejoinstrlen) r\max_sizerWrXrfp file_typeZBOUNDARYbodyrYr)r)r*rZ9sH            zAPI._pack_image)Nr r r Nr r r rrNrNFFFr )NNNN)NNNN)NN)N)NNNNNN)NNNNNN)rN)gr& __module__ __qualname____doc__r+propertyr6r;r7rArBrCrDrErUr]r^r_r`rarbrergrlrrrorsrvrxrzr{r~rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr staticmethodrZr)r)r)r*rs 8                                              r) __future__rrrrZ tweepy.binderrZ tweepy.errorrZtweepy.parsersrrZ tweepy.utilsrobjectrr)r)r)r*s