From: Harmon Date: Sat, 10 Apr 2021 14:32:24 +0000 (-0500) Subject: Update and improve documentation for API.update_profile_image X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=ca6d373e7eea9787b226307fee6009cb28b8eae6;p=tweepy.git Update and improve documentation for API.update_profile_image Automatically use docstring for documentation Improve method and documentation order Add documentation for file, include_entities, and skip_status parameters Improve documentation for filename parameter by using substitution --- diff --git a/docs/api.rst b/docs/api.rst index 2419d07..a7e6b22 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -162,6 +162,8 @@ Manage account settings and profile .. automethod:: API.update_profile_banner +.. automethod:: API.update_profile_image + Direct Message Methods ---------------------- @@ -233,15 +235,6 @@ Account Methods :rtype: :class:`JSON` object -.. method:: API.update_profile_image(filename) - - Update the authenticating user's profile image. Valid formats: GIF, JPG, or - PNG - - :param filename: local path to image file to upload. Not a remote URL! - :rtype: :class:`User` object - - Block Methods ------------- diff --git a/tweepy/api.py b/tweepy/api.py index a412197..72b6d60 100644 --- a/tweepy/api.py +++ b/tweepy/api.py @@ -1945,6 +1945,33 @@ class API: ), files=files, **kwargs ) + @payload('user') + def update_profile_image(self, filename, *, file=None, **kwargs): + """update_profile_image(filename, *, file, include_entities, \ + skip_status) + + Update the authenticating user's profile image. Valid formats: GIF, + JPG, or PNG + + :param filename: |filename| + :param file: |file| + :param include_entities: |include_entities| + :param skip_status: |skip_status| + + :rtype: :class:`User` object + + :reference: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/manage-account-settings/api-reference/post-account-update_profile_image + """ + if file is not None: + files = {'image': (filename, file)} + else: + files = {'image': open(filename, 'rb')} + return self.request( + 'POST', 'account/update_profile_image', endpoint_parameters=( + 'include_entities', 'skip_status' + ), files=files, **kwargs + ) + def media_upload(self, filename, *, file=None, chunked=False, media_category=None, additional_owners=None, **kwargs): """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/media/upload-media/overview @@ -2184,20 +2211,6 @@ class API: ), use_cache=False, **kwargs ) - @payload('user') - def update_profile_image(self, filename, *, file=None, **kwargs): - """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/manage-account-settings/api-reference/post-account-update_profile_image - """ - if file is not None: - files = {'image': (filename, file)} - else: - files = {'image': open(filename, 'rb')} - return self.request( - 'POST', 'account/update_profile_image', endpoint_parameters=( - 'include_entities', 'skip_status' - ), files=files, **kwargs - ) - @payload('user') def create_block(self, **kwargs): """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/mute-block-report-users/api-reference/post-blocks-create