diff options
author | Miroslav Šedivý <[email protected]> | 2022-12-02 22:04:23 +0100 |
---|---|---|
committer | Miroslav Šedivý <[email protected]> | 2022-12-02 22:04:23 +0100 |
commit | 325cc917d5ad14b130b156d23b7adca46499dc24 (patch) | |
tree | 247b41199512db9693d00baf7522602805e31c3f /mastodon/admin.py | |
parent | c796cf39b01e38fe381fb4743988da991b072183 (diff) | |
download | mastodon.py-325cc917d5ad14b130b156d23b7adca46499dc24.tar.gz |
refactor: use f-strings
Diffstat (limited to 'mastodon/admin.py')
-rw-r--r-- | mastodon/admin.py | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/mastodon/admin.py b/mastodon/admin.py index e2f5f20..422be35 100644 --- a/mastodon/admin.py +++ b/mastodon/admin.py | |||
@@ -142,7 +142,7 @@ class Mastodon(Internals): | |||
142 | Returns that dict. | 142 | Returns that dict. |
143 | """ | 143 | """ |
144 | id = self.__unpack_id(id) | 144 | id = self.__unpack_id(id) |
145 | return self.__api_request('GET', '/api/v1/admin/accounts/{0}'.format(id)) | 145 | return self.__api_request('GET', f'/api/v1/admin/accounts/{id}') |
146 | 146 | ||
147 | @api_version("2.9.1", "2.9.1", _DICT_VERSION_ADMIN_ACCOUNT) | 147 | @api_version("2.9.1", "2.9.1", _DICT_VERSION_ADMIN_ACCOUNT) |
148 | def admin_account_enable(self, id): | 148 | def admin_account_enable(self, id): |
@@ -152,7 +152,7 @@ class Mastodon(Internals): | |||
152 | Returns the updated :ref:`admin account dict <admin account dict>`. | 152 | Returns the updated :ref:`admin account dict <admin account dict>`. |
153 | """ | 153 | """ |
154 | id = self.__unpack_id(id) | 154 | id = self.__unpack_id(id) |
155 | return self.__api_request('POST', '/api/v1/admin/accounts/{0}/enable'.format(id)) | 155 | return self.__api_request('POST', f'/api/v1/admin/accounts/{id}/enable') |
156 | 156 | ||
157 | @api_version("2.9.1", "2.9.1", _DICT_VERSION_ADMIN_ACCOUNT) | 157 | @api_version("2.9.1", "2.9.1", _DICT_VERSION_ADMIN_ACCOUNT) |
158 | def admin_account_approve(self, id): | 158 | def admin_account_approve(self, id): |
@@ -162,7 +162,7 @@ class Mastodon(Internals): | |||
162 | Returns the updated :ref:`admin account dict <admin account dict>`. | 162 | Returns the updated :ref:`admin account dict <admin account dict>`. |
163 | """ | 163 | """ |
164 | id = self.__unpack_id(id) | 164 | id = self.__unpack_id(id) |
165 | return self.__api_request('POST', '/api/v1/admin/accounts/{0}/approve'.format(id)) | 165 | return self.__api_request('POST', f'/api/v1/admin/accounts/{id}/approve') |
166 | 166 | ||
167 | @api_version("2.9.1", "2.9.1", _DICT_VERSION_ADMIN_ACCOUNT) | 167 | @api_version("2.9.1", "2.9.1", _DICT_VERSION_ADMIN_ACCOUNT) |
168 | def admin_account_reject(self, id): | 168 | def admin_account_reject(self, id): |
@@ -172,7 +172,7 @@ class Mastodon(Internals): | |||
172 | Returns the updated :ref:`admin account dict <admin account dict>` for the account that is now gone. | 172 | Returns the updated :ref:`admin account dict <admin account dict>` for the account that is now gone. |
173 | """ | 173 | """ |
174 | id = self.__unpack_id(id) | 174 | id = self.__unpack_id(id) |
175 | return self.__api_request('POST', '/api/v1/admin/accounts/{0}/reject'.format(id)) | 175 | return self.__api_request('POST', f'/api/v1/admin/accounts/{id}/reject') |
176 | 176 | ||
177 | @api_version("2.9.1", "2.9.1", _DICT_VERSION_ADMIN_ACCOUNT) | 177 | @api_version("2.9.1", "2.9.1", _DICT_VERSION_ADMIN_ACCOUNT) |
178 | def admin_account_unsilence(self, id): | 178 | def admin_account_unsilence(self, id): |
@@ -182,7 +182,7 @@ class Mastodon(Internals): | |||
182 | Returns the updated :ref:`admin account dict <admin account dict>`. | 182 | Returns the updated :ref:`admin account dict <admin account dict>`. |
183 | """ | 183 | """ |
184 | id = self.__unpack_id(id) | 184 | id = self.__unpack_id(id) |
185 | return self.__api_request('POST', '/api/v1/admin/accounts/{0}/unsilence'.format(id)) | 185 | return self.__api_request('POST', f'/api/v1/admin/accounts/{id}/unsilence') |
186 | 186 | ||
187 | @api_version("2.9.1", "2.9.1", _DICT_VERSION_ADMIN_ACCOUNT) | 187 | @api_version("2.9.1", "2.9.1", _DICT_VERSION_ADMIN_ACCOUNT) |
188 | def admin_account_unsuspend(self, id): | 188 | def admin_account_unsuspend(self, id): |
@@ -192,7 +192,7 @@ class Mastodon(Internals): | |||
192 | Returns the updated :ref:`admin account dict <admin account dict>`. | 192 | Returns the updated :ref:`admin account dict <admin account dict>`. |
193 | """ | 193 | """ |
194 | id = self.__unpack_id(id) | 194 | id = self.__unpack_id(id) |
195 | return self.__api_request('POST', '/api/v1/admin/accounts/{0}/unsuspend'.format(id)) | 195 | return self.__api_request('POST', f'/api/v1/admin/accounts/{id}/unsuspend') |
196 | 196 | ||
197 | @api_version("3.3.0", "3.3.0", _DICT_VERSION_ADMIN_ACCOUNT) | 197 | @api_version("3.3.0", "3.3.0", _DICT_VERSION_ADMIN_ACCOUNT) |
198 | def admin_account_delete(self, id): | 198 | def admin_account_delete(self, id): |
@@ -202,7 +202,7 @@ class Mastodon(Internals): | |||
202 | The deleted accounts :ref:`admin account dict <admin account dict>`. | 202 | The deleted accounts :ref:`admin account dict <admin account dict>`. |
203 | """ | 203 | """ |
204 | id = self.__unpack_id(id) | 204 | id = self.__unpack_id(id) |
205 | return self.__api_request('DELETE', '/api/v1/admin/accounts/{0}'.format(id)) | 205 | return self.__api_request('DELETE', f'/api/v1/admin/accounts/{id}') |
206 | 206 | ||
207 | @api_version("3.3.0", "3.3.0", _DICT_VERSION_ADMIN_ACCOUNT) | 207 | @api_version("3.3.0", "3.3.0", _DICT_VERSION_ADMIN_ACCOUNT) |
208 | def admin_account_unsensitive(self, id): | 208 | def admin_account_unsensitive(self, id): |
@@ -212,7 +212,7 @@ class Mastodon(Internals): | |||
212 | Returns the updated :ref:`admin account dict <admin account dict>`. | 212 | Returns the updated :ref:`admin account dict <admin account dict>`. |
213 | """ | 213 | """ |
214 | id = self.__unpack_id(id) | 214 | id = self.__unpack_id(id) |
215 | return self.__api_request('POST', '/api/v1/admin/accounts/{0}/unsensitive'.format(id)) | 215 | return self.__api_request('POST', f'/api/v1/admin/accounts/{f}/unsensitive') |
216 | 216 | ||
217 | @api_version("2.9.1", "2.9.1", "2.9.1") | 217 | @api_version("2.9.1", "2.9.1", "2.9.1") |
218 | def admin_account_moderate(self, id, action=None, report_id=None, warning_preset_id=None, text=None, send_email_notification=True): | 218 | def admin_account_moderate(self, id, action=None, report_id=None, warning_preset_id=None, text=None, send_email_notification=True): |
@@ -248,8 +248,7 @@ class Mastodon(Internals): | |||
248 | 248 | ||
249 | params["type"] = action | 249 | params["type"] = action |
250 | 250 | ||
251 | self.__api_request( | 251 | self.__api_request('POST', f'/api/v1/admin/accounts/{id}/action', params) |
252 | 'POST', '/api/v1/admin/accounts/{0}/action'.format(id), params) | ||
253 | 252 | ||
254 | @api_version("2.9.1", "2.9.1", _DICT_VERSION_REPORT) | 253 | @api_version("2.9.1", "2.9.1", _DICT_VERSION_REPORT) |
255 | def admin_reports(self, resolved=False, account_id=None, target_account_id=None, max_id=None, min_id=None, since_id=None, limit=None): | 254 | def admin_reports(self, resolved=False, account_id=None, target_account_id=None, max_id=None, min_id=None, since_id=None, limit=None): |
@@ -290,7 +289,7 @@ class Mastodon(Internals): | |||
290 | Returns a :ref:`report dict <report dict>`. | 289 | Returns a :ref:`report dict <report dict>`. |
291 | """ | 290 | """ |
292 | id = self.__unpack_id(id) | 291 | id = self.__unpack_id(id) |
293 | return self.__api_request('GET', '/api/v1/admin/reports/{0}'.format(id)) | 292 | return self.__api_request('GET', f'/api/v1/admin/reports/{id}') |
294 | 293 | ||
295 | @api_version("2.9.1", "2.9.1", _DICT_VERSION_REPORT) | 294 | @api_version("2.9.1", "2.9.1", _DICT_VERSION_REPORT) |
296 | def admin_report_assign(self, id): | 295 | def admin_report_assign(self, id): |
@@ -300,7 +299,7 @@ class Mastodon(Internals): | |||
300 | Returns the updated :ref:`report dict <report dict>`. | 299 | Returns the updated :ref:`report dict <report dict>`. |
301 | """ | 300 | """ |
302 | id = self.__unpack_id(id) | 301 | id = self.__unpack_id(id) |
303 | return self.__api_request('POST', '/api/v1/admin/reports/{0}/assign_to_self'.format(id)) | 302 | return self.__api_request('POST', f'/api/v1/admin/reports/{id}/assign_to_self') |
304 | 303 | ||
305 | @api_version("2.9.1", "2.9.1", _DICT_VERSION_REPORT) | 304 | @api_version("2.9.1", "2.9.1", _DICT_VERSION_REPORT) |
306 | def admin_report_unassign(self, id): | 305 | def admin_report_unassign(self, id): |
@@ -310,7 +309,7 @@ class Mastodon(Internals): | |||
310 | Returns the updated :ref:`report dict <report dict>`. | 309 | Returns the updated :ref:`report dict <report dict>`. |
311 | """ | 310 | """ |
312 | id = self.__unpack_id(id) | 311 | id = self.__unpack_id(id) |
313 | return self.__api_request('POST', '/api/v1/admin/reports/{0}/unassign'.format(id)) | 312 | return self.__api_request('POST', f'/api/v1/admin/reports/{id}/unassign') |
314 | 313 | ||
315 | @api_version("2.9.1", "2.9.1", _DICT_VERSION_REPORT) | 314 | @api_version("2.9.1", "2.9.1", _DICT_VERSION_REPORT) |
316 | def admin_report_reopen(self, id): | 315 | def admin_report_reopen(self, id): |
@@ -320,7 +319,7 @@ class Mastodon(Internals): | |||
320 | Returns the updated :ref:`report dict <report dict>`. | 319 | Returns the updated :ref:`report dict <report dict>`. |
321 | """ | 320 | """ |
322 | id = self.__unpack_id(id) | 321 | id = self.__unpack_id(id) |
323 | return self.__api_request('POST', '/api/v1/admin/reports/{0}/reopen'.format(id)) | 322 | return self.__api_request('POST', f'/api/v1/admin/reports/{id}/reopen') |
324 | 323 | ||
325 | @api_version("2.9.1", "2.9.1", _DICT_VERSION_REPORT) | 324 | @api_version("2.9.1", "2.9.1", _DICT_VERSION_REPORT) |
326 | def admin_report_resolve(self, id): | 325 | def admin_report_resolve(self, id): |
@@ -330,7 +329,7 @@ class Mastodon(Internals): | |||
330 | Returns the updated :ref:`report dict <report dict>`. | 329 | Returns the updated :ref:`report dict <report dict>`. |
331 | """ | 330 | """ |
332 | id = self.__unpack_id(id) | 331 | id = self.__unpack_id(id) |
333 | return self.__api_request('POST', '/api/v1/admin/reports/{0}/resolve'.format(id)) | 332 | return self.__api_request('POST', f'/api/v1/admin/reports/{id}/resolve') |
334 | 333 | ||
335 | @api_version("3.5.0", "3.5.0", _DICT_VERSION_HASHTAG) | 334 | @api_version("3.5.0", "3.5.0", _DICT_VERSION_HASHTAG) |
336 | def admin_trending_tags(self, limit=None): | 335 | def admin_trending_tags(self, limit=None): |
@@ -376,7 +375,7 @@ class Mastodon(Internals): | |||
376 | """ | 375 | """ |
377 | if id is not None: | 376 | if id is not None: |
378 | id = self.__unpack_id(id) | 377 | id = self.__unpack_id(id) |
379 | return self.__api_request('GET', '/api/v1/admin/domain_blocks/{0}'.format(id)) | 378 | return self.__api_request('GET', f'/api/v1/admin/domain_blocks/{id}') |
380 | else: | 379 | else: |
381 | params = self.__generate_params(locals(),['limit']) | 380 | params = self.__generate_params(locals(),['limit']) |
382 | return self.__api_request('GET', '/api/v1/admin/domain_blocks/', params) | 381 | return self.__api_request('GET', '/api/v1/admin/domain_blocks/', params) |
@@ -430,7 +429,7 @@ class Mastodon(Internals): | |||
430 | raise AttributeError("Must provide an id to modify the existing moderation actions on a given domain.") | 429 | raise AttributeError("Must provide an id to modify the existing moderation actions on a given domain.") |
431 | id = self.__unpack_id(id) | 430 | id = self.__unpack_id(id) |
432 | params = self.__generate_params(locals(), ["id"]) | 431 | params = self.__generate_params(locals(), ["id"]) |
433 | return self.__api_request('PUT', '/api/v1/admin/domain_blocks/{0}'.format(id), params) | 432 | return self.__api_request('PUT', f'/api/v1/admin/domain_blocks/{id}', params) |
434 | 433 | ||
435 | @api_version("4.0.0", "4.0.0", _DICT_VERSION_ADMIN_DOMAIN_BLOCK) | 434 | @api_version("4.0.0", "4.0.0", _DICT_VERSION_ADMIN_DOMAIN_BLOCK) |
436 | def admin_delete_domain_block(self, id=None): | 435 | def admin_delete_domain_block(self, id=None): |
@@ -443,7 +442,7 @@ class Mastodon(Internals): | |||
443 | """ | 442 | """ |
444 | if id is not None: | 443 | if id is not None: |
445 | id = self.__unpack_id(id) | 444 | id = self.__unpack_id(id) |
446 | self.__api_request('DELETE', '/api/v1/admin/domain_blocks/{0}'.format(id)) | 445 | self.__api_request('DELETE', f'/api/v1/admin/domain_blocks/{id}') |
447 | else: | 446 | else: |
448 | raise AttributeError("You must provide an id of an existing domain block to remove it.") | 447 | raise AttributeError("You must provide an id of an existing domain block to remove it.") |
449 | 448 | ||