aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThéo Le Calvar <[email protected]>2018-05-20 12:55:25 +0200
committerThéo Le Calvar <[email protected]>2018-05-20 12:55:25 +0200
commit1090d7476f08313202c82d4f6f3ea2ee81231a37 (patch)
tree6e0dd3dc6af8f50e9b0029613a69b107056ebd06 /mastodon
parent1800a9b2c176cc5f8f3b34d36233206e49d088d7 (diff)
downloadmastodon.py-1090d7476f08313202c82d4f6f3ea2ee81231a37.tar.gz
Fix optional args in account_update_credentials
avatar and header are now correctly ignored if not specified.
Diffstat (limited to 'mastodon')
-rw-r--r--mastodon/Mastodon.py26
1 files changed, 14 insertions, 12 deletions
diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py
index 527f1ac..e616aa3 100644
--- a/mastodon/Mastodon.py
+++ b/mastodon/Mastodon.py
@@ -1226,20 +1226,22 @@ class Mastodon:
1226 params_initial = locals() 1226 params_initial = locals()
1227 1227
1228 # Load avatar, if specified 1228 # Load avatar, if specified
1229 if avatar_mime_type is None and os.path.isfile(avatar): 1229 if not avatar is None:
1230 avatar_mime_type = mimetypes.guess_type(avatar)[0] 1230 if avatar_mime_type is None and os.path.isfile(avatar):
1231 avatar = open(avatar, 'rb') 1231 avatar_mime_type = mimetypes.guess_type(avatar)[0]
1232 1232 avatar = open(avatar, 'rb')
1233 if (not avatar is None and avatar_mime_type is None): 1233
1234 raise MastodonIllegalArgumentError('Could not determine mime type or data passed directly without mime type.') 1234 if avatar_mime_type is None:
1235 raise MastodonIllegalArgumentError('Could not determine mime type or data passed directly without mime type.')
1235 1236
1236 # Load header, if specified 1237 # Load header, if specified
1237 if header_mime_type is None and os.path.isfile(header): 1238 if not header is None:
1238 header_mime_type = mimetypes.guess_type(header)[0] 1239 if header_mime_type is None and os.path.isfile(header):
1239 header = open(header, 'rb') 1240 header_mime_type = mimetypes.guess_type(header)[0]
1240 1241 header = open(header, 'rb')
1241 if (not header is None and header_mime_type is None): 1242
1242 raise MastodonIllegalArgumentError('Could not determine mime type or data passed directly without mime type.') 1243 if header_mime_type is None:
1244 raise MastodonIllegalArgumentError('Could not determine mime type or data passed directly without mime type.')
1243 1245
1244 # Clean up params 1246 # Clean up params
1245 for param in ["avatar", "avatar_mime_type", "header", "header_mime_type"]: 1247 for param in ["avatar", "avatar_mime_type", "header", "header_mime_type"]:
Powered by cgit v1.2.3 (git 2.41.0)