From a7c1c5272b6bc0988dd110de6fcee468e6b05be8 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 25 Dec 2021 21:02:44 +0000 Subject: [PATCH] Snake case --- daemon.py | 4 ++-- epicyon.py | 8 ++++---- inbox.py | 14 +++++++------- posts.py | 22 +++++++++++----------- socnet.py | 4 ++-- tests.py | 16 ++++++++-------- 6 files changed, 34 insertions(+), 34 deletions(-) diff --git a/daemon.py b/daemon.py index 33fc7bf13..f714c2f4e 100644 --- a/daemon.py +++ b/daemon.py @@ -18474,7 +18474,7 @@ def runDaemon(content_license_url: str, port: int = 80, proxy_port: int = 80, http_prefix: str = 'https', fed_list: [] = [], - maxMentions: int = 10, maxEmoji: int = 10, + max_mentions: int = 10, maxEmoji: int = 10, secureMode: bool = False, proxyType: str = None, maxReplies: int = 64, domainMaxPostsPerDay: int = 8640, @@ -18931,7 +18931,7 @@ def runDaemon(content_license_url: str, domainMaxPostsPerDay, accountMaxPostsPerDay, allowDeletion, debug, - maxMentions, maxEmoji, + max_mentions, maxEmoji, httpd.translate, unitTest, httpd.yt_replace_domain, httpd.twitter_replacement_domain, diff --git a/epicyon.py b/epicyon.py index e4c69f95e..794b32617 100644 --- a/epicyon.py +++ b/epicyon.py @@ -558,7 +558,7 @@ parser.add_argument("-c", "--client", type=str2bool, nargs='?', help="Use as an ActivityPub client") parser.add_argument('--maxreplies', dest='maxReplies', type=int, default=64, help='Maximum number of replies to a post') -parser.add_argument('--maxMentions', '--hellthread', dest='maxMentions', +parser.add_argument('--max_mentions', '--hellthread', dest='max_mentions', type=int, default=10, help='Maximum number of mentions within a post') parser.add_argument('--maxEmoji', '--maxemoji', dest='maxEmoji', @@ -2998,8 +2998,8 @@ if args.testdata: # set a lower bound to the maximum mentions # so that it can't be accidentally set to zero and disable replies -if args.maxMentions < 4: - args.maxMentions = 4 +if args.max_mentions < 4: + args.max_mentions = 4 registration = getConfigParam(base_dir, 'registration') if not registration: @@ -3251,7 +3251,7 @@ if __name__ == "__main__": args.yt_replace_domain, args.twitter_replacement_domain, port, proxy_port, http_prefix, - federationList, args.maxMentions, + federationList, args.max_mentions, args.maxEmoji, args.secureMode, proxyType, args.maxReplies, args.domainMaxPostsPerDay, diff --git a/inbox.py b/inbox.py index 95b0a715f..ddbc56f0e 100644 --- a/inbox.py +++ b/inbox.py @@ -2185,7 +2185,7 @@ def _estimateNumberOfEmoji(content: str) -> int: def _validPostContent(base_dir: str, nickname: str, domain: str, - messageJson: {}, maxMentions: int, maxEmoji: int, + messageJson: {}, max_mentions: int, maxEmoji: int, allow_local_network_access: bool, debug: bool, systemLanguage: str, http_prefix: str, domainFull: str, @@ -2238,7 +2238,7 @@ def _validPostContent(base_dir: str, nickname: str, domain: str, # check (rough) number of mentions mentionsEst = _estimateNumberOfMentions(contentStr) - if mentionsEst > maxMentions: + if mentionsEst > max_mentions: if messageJson['object'].get('id'): print('REJECT HELLTHREAD: ' + messageJson['object']['id']) print('REJECT HELLTHREAD: Too many mentions in post - ' + @@ -2255,7 +2255,7 @@ def _validPostContent(base_dir: str, nickname: str, domain: str, if not isinstance(messageJson['object']['tag'], list): messageJson['object']['tag'] = [] else: - if len(messageJson['object']['tag']) > int(maxMentions * 2): + if len(messageJson['object']['tag']) > int(max_mentions * 2): if messageJson['object'].get('id'): print('REJECT: ' + messageJson['object']['id']) print('REJECT: Too many tags in post - ' + @@ -3186,7 +3186,7 @@ def _inboxAfterInitial(recentPostsCache: {}, max_recent_posts: int, federationList: [], debug: bool, queueFilename: str, destinationFilename: str, maxReplies: int, allowDeletion: bool, - maxMentions: int, maxEmoji: int, translate: {}, + max_mentions: int, maxEmoji: int, translate: {}, unitTest: bool, yt_replace_domain: str, twitter_replacement_domain: str, @@ -3415,7 +3415,7 @@ def _inboxAfterInitial(recentPostsCache: {}, max_recent_posts: int, jsonObj = None domainFull = getFullDomain(domain, port) if _validPostContent(base_dir, nickname, domain, - postJsonObject, maxMentions, maxEmoji, + postJsonObject, max_mentions, maxEmoji, allow_local_network_access, debug, systemLanguage, http_prefix, domainFull, personCache): @@ -4070,7 +4070,7 @@ def runInboxQueue(recentPostsCache: {}, max_recent_posts: int, federationList: [], maxReplies: int, domainMaxPostsPerDay: int, accountMaxPostsPerDay: int, - allowDeletion: bool, debug: bool, maxMentions: int, + allowDeletion: bool, debug: bool, max_mentions: int, maxEmoji: int, translate: {}, unitTest: bool, yt_replace_domain: str, twitter_replacement_domain: str, @@ -4501,7 +4501,7 @@ def runInboxQueue(recentPostsCache: {}, max_recent_posts: int, debug, queueFilename, destination, maxReplies, allowDeletion, - maxMentions, maxEmoji, + max_mentions, maxEmoji, translate, unitTest, yt_replace_domain, twitter_replacement_domain, diff --git a/posts.py b/posts.py index 2ee3d2fa4..ce22e5455 100644 --- a/posts.py +++ b/posts.py @@ -524,7 +524,7 @@ def isCreateInsideAnnounce(item: {}) -> bool: def _getPosts(session, outboxUrl: str, maxPosts: int, - maxMentions: int, + max_mentions: int, maxEmoji: int, maxAttachments: int, federationList: [], personCache: {}, raw: bool, @@ -623,7 +623,7 @@ def _getPosts(session, outboxUrl: str, maxPosts: int, if tagItem.get('name'): if tagItem['name'] not in mentions: mentions.append(tagItem['name']) - if len(mentions) > maxMentions: + if len(mentions) > max_mentions: if debug: print('max mentions reached') continue @@ -743,7 +743,7 @@ def _updateWordFrequency(content: str, wordFrequency: {}) -> None: def getPostDomains(session, outboxUrl: str, maxPosts: int, - maxMentions: int, + max_mentions: int, maxEmoji: int, maxAttachments: int, federationList: [], personCache: {}, @@ -810,7 +810,7 @@ def getPostDomains(session, outboxUrl: str, maxPosts: int, def _getPostsForBlockedDomains(base_dir: str, session, outboxUrl: str, maxPosts: int, - maxMentions: int, + max_mentions: int, maxEmoji: int, maxAttachments: int, federationList: [], personCache: {}, @@ -4113,10 +4113,10 @@ def getPublicPostsOfPerson(base_dir: str, nickname: str, domain: str, if not personId: return - maxMentions = 10 + max_mentions = 10 maxEmoji = 10 maxAttachments = 5 - _getPosts(session, personUrl, 30, maxMentions, maxEmoji, + _getPosts(session, personUrl, 30, max_mentions, maxEmoji, maxAttachments, federationList, personCache, raw, simple, debug, project_version, http_prefix, originDomain, systemLanguage, @@ -4161,11 +4161,11 @@ def getPublicPostDomains(session, base_dir: str, nickname: str, domain: str, project_version, http_prefix, nickname, domain, 'outbox', 92522) - maxMentions = 99 + max_mentions = 99 maxEmoji = 99 maxAttachments = 5 postDomains = \ - getPostDomains(session, personUrl, 64, maxMentions, maxEmoji, + getPostDomains(session, personUrl, 64, max_mentions, maxEmoji, maxAttachments, federationList, personCache, debug, project_version, http_prefix, domain, @@ -4257,12 +4257,12 @@ def getPublicPostInfo(session, base_dir: str, nickname: str, domain: str, project_version, http_prefix, nickname, domain, 'outbox', 13863) - maxMentions = 99 + max_mentions = 99 maxEmoji = 99 maxAttachments = 5 maxPosts = 64 postDomains = \ - getPostDomains(session, personUrl, maxPosts, maxMentions, maxEmoji, + getPostDomains(session, personUrl, maxPosts, max_mentions, maxEmoji, maxAttachments, federationList, personCache, debug, project_version, http_prefix, domain, @@ -4275,7 +4275,7 @@ def getPublicPostInfo(session, base_dir: str, nickname: str, domain: str, blockedPosts = \ _getPostsForBlockedDomains(base_dir, session, personUrl, maxPosts, - maxMentions, + max_mentions, maxEmoji, maxAttachments, federationList, personCache, diff --git a/socnet.py b/socnet.py index 1131d9ef5..1b12156f0 100644 --- a/socnet.py +++ b/socnet.py @@ -34,7 +34,7 @@ def instancesGraph(base_dir: str, handles: str, personCache = {} cachedWebfingers = {} federationList = [] - maxMentions = 99 + max_mentions = 99 maxEmoji = 99 maxAttachments = 5 @@ -74,7 +74,7 @@ def instancesGraph(base_dir: str, handles: str, 27261) wordFrequency = {} postDomains = \ - getPostDomains(session, personUrl, 64, maxMentions, maxEmoji, + getPostDomains(session, personUrl, 64, max_mentions, maxEmoji, maxAttachments, federationList, personCache, debug, project_version, http_prefix, domain, diff --git a/tests.py b/tests.py index 34a35c8ac..89345664d 100644 --- a/tests.py +++ b/tests.py @@ -775,7 +775,7 @@ def createServerAlice(path: str, domain: str, port: int, regenerateIndexForBox(path, nickname, domain, 'outbox') global testServerAliceRunning testServerAliceRunning = True - maxMentions = 10 + max_mentions = 10 maxEmoji = 10 onion_domain = None i2p_domain = None @@ -815,7 +815,7 @@ def createServerAlice(path: str, domain: str, port: int, 5, True, True, 'en', __version__, "instance_id", False, path, domain, onion_domain, i2p_domain, None, None, port, port, - http_prefix, federationList, maxMentions, maxEmoji, False, + http_prefix, federationList, max_mentions, maxEmoji, False, proxyType, maxReplies, domainMaxPostsPerDay, accountMaxPostsPerDay, allowDeletion, True, True, False, sendThreads, @@ -917,7 +917,7 @@ def createServerBob(path: str, domain: str, port: int, regenerateIndexForBox(path, nickname, domain, 'outbox') global testServerBobRunning testServerBobRunning = True - maxMentions = 10 + max_mentions = 10 maxEmoji = 10 onion_domain = None i2p_domain = None @@ -957,7 +957,7 @@ def createServerBob(path: str, domain: str, port: int, 5, True, True, 'en', __version__, "instance_id", False, path, domain, onion_domain, i2p_domain, None, None, port, port, - http_prefix, federationList, maxMentions, maxEmoji, False, + http_prefix, federationList, max_mentions, maxEmoji, False, proxyType, maxReplies, domainMaxPostsPerDay, accountMaxPostsPerDay, allowDeletion, True, True, False, sendThreads, @@ -986,7 +986,7 @@ def createServerEve(path: str, domain: str, port: int, federationList: [], deleteAllPosts(path, nickname, domain, 'outbox') global testServerEveRunning testServerEveRunning = True - maxMentions = 10 + max_mentions = 10 maxEmoji = 10 onion_domain = None i2p_domain = None @@ -1027,7 +1027,7 @@ def createServerEve(path: str, domain: str, port: int, federationList: [], 5, True, True, 'en', __version__, "instance_id", False, path, domain, onion_domain, i2p_domain, None, None, port, port, - http_prefix, federationList, maxMentions, maxEmoji, False, + http_prefix, federationList, max_mentions, maxEmoji, False, proxyType, maxReplies, allowDeletion, True, True, False, sendThreads, False) @@ -1058,7 +1058,7 @@ def createServerGroup(path: str, domain: str, port: int, deleteAllPosts(path, nickname, domain, 'outbox') global testServerGroupRunning testServerGroupRunning = True - maxMentions = 10 + max_mentions = 10 maxEmoji = 10 onion_domain = None i2p_domain = None @@ -1099,7 +1099,7 @@ def createServerGroup(path: str, domain: str, port: int, 5, True, True, 'en', __version__, "instance_id", False, path, domain, onion_domain, i2p_domain, None, None, port, port, - http_prefix, federationList, maxMentions, maxEmoji, False, + http_prefix, federationList, max_mentions, maxEmoji, False, proxyType, maxReplies, domainMaxPostsPerDay, accountMaxPostsPerDay, allowDeletion, True, True, False, sendThreads,