From 5d1f7212e74bc15d48c000ca43f348418389cf07 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 13 Dec 2021 16:04:12 +0000 Subject: [PATCH] Tidying --- desktop_client.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/desktop_client.py b/desktop_client.py index 7fd9888bc..8584b6844 100644 --- a/desktop_client.py +++ b/desktop_client.py @@ -624,15 +624,16 @@ def _showLikesOnPost(postJsonObject: {}, maxLikes: int) -> None: return if not postJsonObject['object'].get('likes'): return - if not isinstance(postJsonObject['object']['likes'], dict): + objectLikes = postJsonObject['object']['likes'] + if not isinstance(objectLikes, dict): return - if not postJsonObject['object']['likes'].get('items'): + if not objectLikes.get('items'): return - if not isinstance(postJsonObject['object']['likes']['items'], list): + if not isinstance(objectLikes['items'], list): return print('') ctr = 0 - for item in postJsonObject['object']['likes']['items']: + for item in objectLikes['items']: print(' ❤ ' + str(item['actor'])) ctr += 1 if ctr >= maxLikes: @@ -646,15 +647,16 @@ def _showRepliesOnPost(postJsonObject: {}, maxReplies: int) -> None: return if not postJsonObject['object'].get('replies'): return - if not isinstance(postJsonObject['object']['replies'], dict): + objectReplies = postJsonObject['object']['replies'] + if not isinstance(objectReplies, dict): return - if not postJsonObject['object']['replies'].get('items'): + if not objectReplies.get('items'): return - if not isinstance(postJsonObject['object']['replies']['items'], list): + if not isinstance(objectReplies['items'], list): return print('') ctr = 0 - for item in postJsonObject['object']['replies']['items']: + for item in objectReplies['items']: print(' ↰ ' + str(item['url'])) ctr += 1 if ctr >= maxReplies: