From 8b6dc582fa728b4023876f4b359d6d84e0d4db92 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 26 Dec 2021 19:36:40 +0000 Subject: [PATCH] Snake case --- inbox.py | 28 ++++++++++++++-------------- speaker.py | 4 ++-- utils.py | 20 ++++++++++---------- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/inbox.py b/inbox.py index 51ec777b8..3b98c3b86 100644 --- a/inbox.py +++ b/inbox.py @@ -90,7 +90,7 @@ from utils import updateAnnounceCollection from utils import undoAnnounceCollectionEntry from utils import dangerousMarkup from utils import isDM -from utils import isReply +from utils import is_reply from utils import has_actor from httpsig import messageContentDigest from posts import editedPostFilename @@ -3079,13 +3079,13 @@ def _createReplyNotificationFile(base_dir: str, nickname: str, domain: str, The file can then be used by other systems to create a notification xmpp, matrix, email, etc """ - isReplyToMutedPost = False + is_replyToMutedPost = False if postIsDM: - return isReplyToMutedPost - if not isReply(post_json_object, actor): - return isReplyToMutedPost + return is_replyToMutedPost + if not is_reply(post_json_object, actor): + return is_replyToMutedPost if nickname == 'inbox': - return isReplyToMutedPost + return is_replyToMutedPost # replies index will be updated updateIndexList.append('tlreplies') @@ -3094,12 +3094,12 @@ def _createReplyNotificationFile(base_dir: str, nickname: str, domain: str, conversationId = post_json_object['object']['conversation'] if not post_json_object['object'].get('inReplyTo'): - return isReplyToMutedPost + return is_replyToMutedPost inReplyTo = post_json_object['object']['inReplyTo'] if not inReplyTo: - return isReplyToMutedPost + return is_replyToMutedPost if not isinstance(inReplyTo, str): - return isReplyToMutedPost + return is_replyToMutedPost if not isMuted(base_dir, nickname, domain, inReplyTo, conversationId): # check if the reply is within the allowed time period # after publication @@ -3117,8 +3117,8 @@ def _createReplyNotificationFile(base_dir: str, nickname: str, domain: str, ' hours') return False else: - isReplyToMutedPost = True - return isReplyToMutedPost + is_replyToMutedPost = True + return is_replyToMutedPost def _lowFrequencyPostNotification(base_dir: str, http_prefix: str, @@ -3474,7 +3474,7 @@ def _inboxAfterInitial(recentPostsCache: {}, max_recent_posts: int, max_like_count, cw_lists, lists_enabled) - isReplyToMutedPost = False + is_replyToMutedPost = False if not isGroup: # create a DM notification file if needed @@ -3498,7 +3498,7 @@ def _inboxAfterInitial(recentPostsCache: {}, max_recent_posts: int, actor = local_actor_url(http_prefix, nickname, domain_full) # create a reply notification file if needed - isReplyToMutedPost = \ + is_replyToMutedPost = \ _createReplyNotificationFile(base_dir, nickname, domain, handle, debug, postIsDM, post_json_object, actor, @@ -3533,7 +3533,7 @@ def _inboxAfterInitial(recentPostsCache: {}, max_recent_posts: int, # If this is a reply to a muted post then also mute it. # This enables you to ignore a threat that's getting boring - if isReplyToMutedPost: + if is_replyToMutedPost: print('MUTE REPLY: ' + destinationFilename) destinationFilenameMuted = destinationFilename + '.muted' try: diff --git a/speaker.py b/speaker.py index f715e7373..1715da6ed 100644 --- a/speaker.py +++ b/speaker.py @@ -13,7 +13,7 @@ import random import urllib.parse from utils import removeIdEnding from utils import isDM -from utils import isReply +from utils import is_reply from utils import camelCaseSplit from utils import getDomainFromActor from utils import getNicknameFromActor @@ -455,7 +455,7 @@ def _postToSpeakerJson(base_dir: str, http_prefix: str, isDirect = isDM(post_json_object) actor = local_actor_url(http_prefix, nickname, domain_full) - replyToYou = isReply(post_json_object, actor) + replyToYou = is_reply(post_json_object, actor) published = '' if post_json_object['object'].get('published'): diff --git a/utils.py b/utils.py index 548dbf354..93c3c6cc3 100644 --- a/utils.py +++ b/utils.py @@ -1506,8 +1506,8 @@ def removeModerationPostFromIndex(base_dir: str, postUrl: str, ' from moderation index') -def _isReplyToBlogPost(base_dir: str, nickname: str, domain: str, - post_json_object: str): +def _is_reply_to_blog_post(base_dir: str, nickname: str, domain: str, + post_json_object: str): """Is the given post a reply to a blog post? """ if not has_object_dict(post_json_object): @@ -1516,13 +1516,13 @@ def _isReplyToBlogPost(base_dir: str, nickname: str, domain: str, return False if not isinstance(post_json_object['object']['inReplyTo'], str): return False - blogsIndexFilename = \ + blogs_index_filename = \ acct_dir(base_dir, nickname, domain) + '/tlblogs.index' - if not os.path.isfile(blogsIndexFilename): + if not os.path.isfile(blogs_index_filename): return False - postId = removeIdEnding(post_json_object['object']['inReplyTo']) - postId = postId.replace('/', '#') - if postId in open(blogsIndexFilename).read(): + post_id = removeIdEnding(post_json_object['object']['inReplyTo']) + post_id = post_id.replace('/', '#') + if post_id in open(blogs_index_filename).read(): return True return False @@ -1736,8 +1736,8 @@ def deletePost(base_dir: str, http_prefix: str, return # don't remove replies to blog posts - if _isReplyToBlogPost(base_dir, nickname, domain, - post_json_object): + if _is_reply_to_blog_post(base_dir, nickname, domain, + post_json_object): return # remove from recent posts cache in memory @@ -2613,7 +2613,7 @@ def isDM(post_json_object: {}) -> bool: return True -def isReply(post_json_object: {}, actor: str) -> bool: +def is_reply(post_json_object: {}, actor: str) -> bool: """Returns true if the given post is a reply to the given actor """ if post_json_object['type'] != 'Create':