From 3a041a8fb65321d0ecbd81e259731a5ecb297b84 Mon Sep 17 00:00:00 2001 From: Jesse Weinstein Date: Tue, 27 Dec 2022 13:32:27 -0500 Subject: [PATCH] Remove redundant tests --- src/tootstream/toot.py | 34 +++++++--------------------------- 1 file changed, 7 insertions(+), 27 deletions(-) diff --git a/src/tootstream/toot.py b/src/tootstream/toot.py index 69a1900..7333a91 100644 --- a/src/tootstream/toot.py +++ b/src/tootstream/toot.py @@ -2082,6 +2082,7 @@ def listaccounts(mastodon, rest): for user in list_accounts: printUser(user) + listaccounts.__argstr__ = '' listaccounts.__section__ = 'List' @@ -2099,13 +2100,7 @@ def listdifference(mastodon, rest): cprint("Not enough arguments.", fg('red')) return list_id = get_list_id(mastodon, items[0]) - if not list_id: - cprint("List {} is not found".format(items[0]), fg('red')) - return diff_list_id = get_list_id(mastodon, items[1]) - if not diff_list_id: - cprint("List {} is not found".format(items[1]), fg('red')) - return list_accounts = mastodon.fetch_remaining(mastodon.list_accounts(diff_list_id)) existing_ids = [x['id'] for x in mastodon.fetch_remaining(mastodon.list_accounts(list_id))] @@ -2115,13 +2110,9 @@ def listdifference(mastodon, rest): cprint("User {} already missing from list {}.".format( format_username(user), items[0]), fg('green')) else: - try: - mastodon.list_accounts_delete(list_id, user['id']) - cprint("Removed {} from list {}.".format( - format_username(user), items[0]), fg('green')) - except Exception as e: - cprint("error while deleting from list: {}".format( - type(e).__name__), fg('red')) + mastodon.list_accounts_delete(list_id, user['id']) + cprint("Removed {} from list {}.".format( + format_username(user), items[0]), fg('green')) listdifference.__argstr__ = ' ' @@ -2141,18 +2132,11 @@ def listunion(mastodon, rest): cprint("Not enough arguments.", fg('red')) return list_id = get_list_id(mastodon, items[0]) - if not list_id: - cprint("List {} is not found".format(items[0]), fg('red')) - return if items[1] == "[following]": user = mastodon.account_verify_credentials() list_accounts = mastodon.fetch_remaining(mastodon.account_following(user['id'])) else: union_list_id = get_list_id(mastodon, items[1]) - if not union_list_id: - cprint("List {} is not found".format(items[1]), fg('red')) - return - list_accounts = mastodon.fetch_remaining(mastodon.list_accounts(union_list_id)) existing_ids = [x['id'] for x in mastodon.fetch_remaining(mastodon.list_accounts(list_id))] @@ -2162,13 +2146,9 @@ def listunion(mastodon, rest): cprint("User {} already on list {}.".format( format_username(user), items[0]), fg('green')) else: - try: - mastodon.list_accounts_add(list_id, user['id']) - cprint("Added {} to list {}.".format( - format_username(user), items[0]), fg('green')) - except Exception as e: - cprint("error while adding to list: {}".format( - type(e).__name__), fg('red')) + mastodon.list_accounts_add(list_id, user['id']) + cprint("Added {} to list {}.".format( + format_username(user), items[0]), fg('green')) listunion.__argstr__ = ' '