From dcafa28ee4d21f880077d0e76c7f3cf749dc6254 Mon Sep 17 00:00:00 2001
From: Bob Mottram
Date: Sun, 26 Dec 2021 11:29:40 +0000
Subject: [PATCH] Snake case
---
blog.py | 12 +++++++-----
daemon.py | 7 ++++---
desktop_client.py | 19 ++++++++++---------
inbox.py | 6 +++---
media.py | 4 ++--
newsdaemon.py | 11 ++++++-----
newswire.py | 6 +++---
outbox.py | 4 ++--
posts.py | 6 +++---
utils.py | 3 ++-
webapp_column_right.py | 5 +++--
webapp_post.py | 4 ++--
webapp_search.py | 5 +++--
13 files changed, 50 insertions(+), 42 deletions(-)
diff --git a/blog.py b/blog.py
index 33498f54d..f79af57cd 100644
--- a/blog.py
+++ b/blog.py
@@ -19,7 +19,7 @@ from webapp_utils import editTextArea
from webapp_media import addEmbeddedElements
from utils import local_actor_url
from utils import get_actor_languages_list
-from utils import getBaseContentFromPost
+from utils import get_base_content_from_post
from utils import get_content_from_post
from utils import isAccountDir
from utils import removeHtml
@@ -368,7 +368,8 @@ def _htmlBlogPostRSS2(authorized: bool,
titleStr = post_json_object['object']['summary']
rssDateStr = pubDate.strftime("%a, %d %b %Y %H:%M:%S UT")
content = \
- getBaseContentFromPost(post_json_object, system_language)
+ get_base_content_from_post(post_json_object,
+ system_language)
description = firstParagraphFromString(content)
rssStr = ' - '
rssStr += ' ' + titleStr + ''
@@ -402,7 +403,8 @@ def _htmlBlogPostRSS3(authorized: bool,
titleStr = post_json_object['object']['summary']
rssDateStr = pubDate.strftime("%a, %d %b %Y %H:%M:%S UT")
content = \
- getBaseContentFromPost(post_json_object, system_language)
+ get_base_content_from_post(post_json_object,
+ system_language)
description = firstParagraphFromString(content)
rssStr = 'title: ' + titleStr + '\n'
rssStr += 'link: ' + messageLink + '\n'
@@ -427,7 +429,7 @@ def _getSnippetFromBlogContent(post_json_object: {},
system_language: str) -> str:
"""Returns a snippet of text from the blog post as a preview
"""
- content = getBaseContentFromPost(post_json_object, system_language)
+ content = get_base_content_from_post(post_json_object, system_language)
if '
' in content:
content = content.split('
', 1)[1]
if '
' in content:
@@ -896,7 +898,7 @@ def htmlEditBlog(media_instance: bool, translate: {},
editBlogForm += '
'
messageBoxHeight = 800
- contentStr = getBaseContentFromPost(post_json_object, system_language)
+ contentStr = get_base_content_from_post(post_json_object, system_language)
contentStr = contentStr.replace('', '').replace('
', '\n')
editBlogForm += \
diff --git a/daemon.py b/daemon.py
index 90da6c1cc..400af9dcf 100644
--- a/daemon.py
+++ b/daemon.py
@@ -254,7 +254,7 @@ from utils import local_actor_url
from utils import isfloat
from utils import validPassword
from utils import removeLineEndings
-from utils import getBaseContentFromPost
+from utils import get_base_content_from_post
from utils import acctDir
from utils import getImageExtensionFromMimeType
from utils import getImageMimeType
@@ -16640,9 +16640,10 @@ class PubServer(BaseHTTPRequestHandler):
if fields['schedulePost']:
return 1
if pinToProfile:
+ sys_language = self.server.system_language
contentStr = \
- getBaseContentFromPost(message_json,
- self.server.system_language)
+ get_base_content_from_post(message_json,
+ sys_language)
followersOnly = False
pinPost(self.server.base_dir,
nickname, self.server.domain, contentStr,
diff --git a/desktop_client.py b/desktop_client.py
index 0d5b59e71..b3ddc1dbd 100644
--- a/desktop_client.py
+++ b/desktop_client.py
@@ -16,7 +16,7 @@ import webbrowser
import urllib.parse
from pathlib import Path
from random import randint
-from utils import getBaseContentFromPost
+from utils import get_base_content_from_post
from utils import has_object_dict
from utils import getFullDomain
from utils import isDM
@@ -720,8 +720,8 @@ def _readLocalBoxPost(session, nickname: str, domain: str,
post_json_object2['object'].get('content'):
attributedTo = post_json_object2['object']['attributedTo']
content = \
- getBaseContentFromPost(post_json_object2,
- system_language)
+ get_base_content_from_post(post_json_object2,
+ system_language)
if isinstance(attributedTo, str) and content:
actor = attributedTo
nameStr += ' ' + translate['announces'] + ' ' + \
@@ -746,7 +746,7 @@ def _readLocalBoxPost(session, nickname: str, domain: str,
attributedTo = post_json_object['object']['attributedTo']
if not attributedTo:
return {}
- content = getBaseContentFromPost(post_json_object, system_language)
+ content = get_base_content_from_post(post_json_object, system_language)
if not isinstance(attributedTo, str) or \
not isinstance(content, str):
return {}
@@ -1072,7 +1072,8 @@ def _desktopShowBox(indent: str,
published = _formatPublished(post_json_object['published'])
- contentStr = getBaseContentFromPost(post_json_object, system_language)
+ contentStr = get_base_content_from_post(post_json_object,
+ system_language)
content = _textOnlyContent(contentStr)
if boxName != 'dm':
if isDM(post_json_object):
@@ -2423,8 +2424,8 @@ def runDesktopClient(base_dir: str, proxy_type: str, http_prefix: str,
post_json_object = post_json_object2
if post_json_object:
content = \
- getBaseContentFromPost(post_json_object,
- system_language)
+ get_base_content_from_post(post_json_object,
+ system_language)
messageStr, detectedLinks = \
speakableText(base_dir, content, translate)
linkOpened = False
@@ -2481,8 +2482,8 @@ def runDesktopClient(base_dir: str, proxy_type: str, http_prefix: str,
if post_json_object['object'].get('summary'):
print(post_json_object['object']['summary'])
contentStr = \
- getBaseContentFromPost(post_json_object,
- system_language)
+ get_base_content_from_post(post_json_object,
+ system_language)
print(contentStr)
print('')
sayStr = 'Confirm delete, yes or no?'
diff --git a/inbox.py b/inbox.py
index 2027f6359..a4a874808 100644
--- a/inbox.py
+++ b/inbox.py
@@ -28,7 +28,7 @@ from utils import hasObjectStringObject
from utils import getReplyIntervalHours
from utils import canReplyTo
from utils import getUserPaths
-from utils import getBaseContentFromPost
+from utils import get_base_content_from_post
from utils import acctDir
from utils import removeDomainPort
from utils import getPortFromDomain
@@ -521,7 +521,7 @@ def savePostToInboxQueue(base_dir: str, http_prefix: str,
return None
if post_json_object['object'].get('content'):
contentStr = \
- getBaseContentFromPost(post_json_object, system_language)
+ get_base_content_from_post(post_json_object, system_language)
if contentStr:
if isFiltered(base_dir, nickname, domain, contentStr):
if debug:
@@ -2237,7 +2237,7 @@ def _validPostContent(base_dir: str, nickname: str, domain: str,
message_json['object']['content']):
return True
- contentStr = getBaseContentFromPost(message_json, system_language)
+ contentStr = get_base_content_from_post(message_json, system_language)
if dangerousMarkup(contentStr, allow_local_network_access):
if message_json['object'].get('id'):
print('REJECT ARBITRARY HTML: ' + message_json['object']['id'])
diff --git a/media.py b/media.py
index c38edc200..934d7b04f 100644
--- a/media.py
+++ b/media.py
@@ -15,7 +15,7 @@ import random
from random import randint
from hashlib import sha1
from auth import createPassword
-from utils import getBaseContentFromPost
+from utils import get_base_content_from_post
from utils import getFullDomain
from utils import getImageExtensions
from utils import getVideoExtensions
@@ -63,7 +63,7 @@ def _replaceSiloDomain(post_json_object: {},
return
if not post_json_object['object'].get('content'):
return
- contentStr = getBaseContentFromPost(post_json_object, system_language)
+ contentStr = get_base_content_from_post(post_json_object, system_language)
if siloDomain not in contentStr:
return
contentStr = contentStr.replace(siloDomain, replacementDomain)
diff --git a/newsdaemon.py b/newsdaemon.py
index 6d7ac2d0d..6bf6ac1cb 100644
--- a/newsdaemon.py
+++ b/newsdaemon.py
@@ -25,7 +25,7 @@ from newswire import getDictFromNewswire
from posts import createNewsPost
from posts import archivePostsForPerson
from content import validHashTag
-from utils import getBaseContentFromPost
+from utils import get_base_content_from_post
from utils import removeHtml
from utils import getFullDomain
from utils import loadJson
@@ -322,7 +322,7 @@ def _hashtagAdd(base_dir: str, http_prefix: str, domain_full: str,
hashtagHtml = \
" #" + htId + ""
- content = getBaseContentFromPost(post_json_object, system_language)
+ content = get_base_content_from_post(post_json_object, system_language)
if hashtagHtml in content:
return
@@ -357,7 +357,7 @@ def _hashtagRemove(http_prefix: str, domain_full: str, post_json_object: {},
hashtagHtml = \
"#" + htId + ""
- content = getBaseContentFromPost(post_json_object, system_language)
+ content = get_base_content_from_post(post_json_object, system_language)
if hashtagHtml in content:
content = content.replace(hashtagHtml, '').replace(' ', ' ')
post_json_object['object']['content'] = content
@@ -399,7 +399,8 @@ def _newswireHashtagProcessing(session, base_dir: str, post_json_object: {},
# get the full text content of the post
content = ''
if post_json_object['object'].get('content'):
- content += getBaseContentFromPost(post_json_object, system_language)
+ content += get_base_content_from_post(post_json_object,
+ system_language)
if post_json_object['object'].get('summary'):
content += ' ' + post_json_object['object']['summary']
content = content.lower()
@@ -708,7 +709,7 @@ def _convertRSStoActivityPub(base_dir: str, http_prefix: str,
"\" class=\"addedHashtag\" " + \
"rel=\"tag\">#" + \
htId + ""
- content = getBaseContentFromPost(blog, system_language)
+ content = get_base_content_from_post(blog, system_language)
if hashtagHtml not in content:
if content.endswith('
'):
content = \
diff --git a/newswire.py b/newswire.py
index 88dbae013..b8fab585d 100644
--- a/newswire.py
+++ b/newswire.py
@@ -20,7 +20,7 @@ from utils import validPostDate
from categories import setHashtagCategory
from utils import dangerousSVG
from utils import getFavFilenameFromUrl
-from utils import getBaseContentFromPost
+from utils import get_base_content_from_post
from utils import has_object_dict
from utils import firstParagraphFromString
from utils import isPublicPost
@@ -1062,8 +1062,8 @@ def _addAccountBlogsToNewswire(base_dir: str, nickname: str, domain: str,
if os.path.isfile(fullPostFilename + '.votes'):
votes = loadJson(fullPostFilename + '.votes')
content = \
- getBaseContentFromPost(post_json_object,
- system_language)
+ get_base_content_from_post(post_json_object,
+ system_language)
description = firstParagraphFromString(content)
description = removeHtml(description)
tagsFromPost = _getHashtagsFromPost(post_json_object)
diff --git a/outbox.py b/outbox.py
index 472254abe..5a8679772 100644
--- a/outbox.py
+++ b/outbox.py
@@ -17,7 +17,7 @@ from posts import savePostToBox
from posts import sendToFollowersThread
from posts import sendToNamedAddressesThread
from utils import hasObjectStringType
-from utils import getBaseContentFromPost
+from utils import get_base_content_from_post
from utils import has_object_dict
from utils import getLocalNetworkAddresses
from utils import getFullDomain
@@ -223,7 +223,7 @@ def postMessageToOutbox(session, translate: {},
# check that the outgoing post doesn't contain any markup
# which can be used to implement exploits
if has_object_dict(message_json):
- contentStr = getBaseContentFromPost(message_json, system_language)
+ contentStr = get_base_content_from_post(message_json, system_language)
if contentStr:
if dangerousMarkup(contentStr, allow_local_network_access):
print('POST to outbox contains dangerous markup: ' +
diff --git a/posts.py b/posts.py
index b781f9798..b7bc6b66b 100644
--- a/posts.py
+++ b/posts.py
@@ -38,7 +38,7 @@ from utils import hasObjectStringType
from utils import removeIdEnding
from utils import replaceUsersWithAt
from utils import hasGroupType
-from utils import getBaseContentFromPost
+from utils import get_base_content_from_post
from utils import removeDomainPort
from utils import getPortFromDomain
from utils import has_object_dict
@@ -591,7 +591,7 @@ def _getPosts(session, outboxUrl: str, maxPosts: int,
if item['type'] != 'Note' and item['type'] != 'Page':
thisItem = item['object']
- content = getBaseContentFromPost(item, system_language)
+ content = get_base_content_from_post(item, system_language)
content = content.replace(''', "'")
mentions = []
@@ -784,7 +784,7 @@ def getPostDomains(session, outboxUrl: str, maxPosts: int,
break
if not has_object_dict(item):
continue
- contentStr = getBaseContentFromPost(item, system_language)
+ contentStr = get_base_content_from_post(item, system_language)
if contentStr:
_updateWordFrequency(contentStr, wordFrequency)
if item['object'].get('inReplyTo'):
diff --git a/utils.py b/utils.py
index b88bb51ee..ee656dfb8 100644
--- a/utils.py
+++ b/utils.py
@@ -106,7 +106,8 @@ def get_content_from_post(post_json_object: {}, system_language: str,
return content
-def getBaseContentFromPost(post_json_object: {}, system_language: str) -> str:
+def get_base_content_from_post(post_json_object: {},
+ system_language: str) -> str:
"""Returns the content from the post in the given language
"""
this_post_json = post_json_object
diff --git a/webapp_column_right.py b/webapp_column_right.py
index c8e4f53eb..28e153861 100644
--- a/webapp_column_right.py
+++ b/webapp_column_right.py
@@ -12,7 +12,7 @@ from datetime import datetime
from content import removeLongWords
from content import limitRepeatedWords
from utils import getFavFilenameFromUrl
-from utils import getBaseContentFromPost
+from utils import get_base_content_from_post
from utils import removeHtml
from utils import locatePost
from utils import loadJson
@@ -704,7 +704,8 @@ def htmlEditNewsPost(cssCache: {}, translate: {}, base_dir: str, path: str,
'
\n'
- newsPostContent = getBaseContentFromPost(post_json_object, system_language)
+ newsPostContent = get_base_content_from_post(post_json_object,
+ system_language)
editNewsPostForm += \
'