From 177af4fac959be2a22940d141feab4f8848379c5 Mon Sep 17 00:00:00 2001 From: Ivan Habunek Date: Sat, 30 Dec 2017 13:14:37 +0100 Subject: [PATCH] Fix code style --- toot/api.py | 2 +- toot/commands.py | 13 ++++++++----- toot/output.py | 10 +++++----- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/toot/api.py b/toot/api.py index f0de3ef..14e5513 100644 --- a/toot/api.py +++ b/toot/api.py @@ -37,7 +37,7 @@ def _process_response(response): error = data['error_description'] elif "error" in data: error = data['error'] - except: + except Exception: pass if response.status_code == 404: diff --git a/toot/commands.py b/toot/commands.py index 6b92d14..953e07f 100644 --- a/toot/commands.py +++ b/toot/commands.py @@ -74,7 +74,7 @@ def post(app, user, args): else: media_ids = None - response = api.post_status(app, user, args.text, media_ids=media_ids, visibility=args.visibility) + response = api.post_status(app, user, args.text, args.visibility, media_ids) print_out("Toot posted: {}".format(response.get('url'))) @@ -83,8 +83,10 @@ def auth(app, user, args): if app and user: print_out("You are logged in to {} as {}\n".format( app.instance, user.username)) - print_out("User data: {}".format(config.get_user_config_path())) - print_out("App data: {}".format(config.get_instance_config_path(app.instance))) + print_out("User data: {}".format( + config.get_user_config_path())) + print_out("App data: {}".format( + config.get_instance_config_path(app.instance))) else: print_out("You are not logged in") @@ -114,9 +116,10 @@ def logout(app, user, args): def upload(app, user, args): response = _do_upload(app, user, args.file) + msg = "Successfully uploaded media ID {}, type '{}'" + print_out() - print_out("Successfully uploaded media ID {}, type '{}'".format( - response['id'], response['type'])) + print_out(msg.format(response['id'], response['type'])) print_out("Original URL: {}".format(response['url'])) print_out("Preview URL: {}".format(response['preview_url'])) print_out("Text URL: {}".format(response['text_url'])) diff --git a/toot/output.py b/toot/output.py index 831c774..7f4eb20 100644 --- a/toot/output.py +++ b/toot/output.py @@ -7,12 +7,12 @@ from textwrap import wrap from toot.utils import format_content, get_text START_CODES = { - 'red': '\033[31m', - 'green': '\033[32m', - 'yellow': '\033[33m', - 'blue': '\033[34m', + 'red': '\033[31m', + 'green': '\033[32m', + 'yellow': '\033[33m', + 'blue': '\033[34m', 'magenta': '\033[35m', - 'cyan': '\033[36m', + 'cyan': '\033[36m', } END_CODE = '\033[0m'