Snake case

merge-requests/30/head
Bob Mottram 2021-12-28 14:41:10 +00:00
parent e580ea1963
commit a68667d829
16 changed files with 53 additions and 53 deletions

View File

@ -269,7 +269,7 @@ from utils import set_occupation_name
from utils import load_translations_from_file from utils import load_translations_from_file
from utils import get_local_network_addresses from utils import get_local_network_addresses
from utils import decoded_host from utils import decoded_host
from utils import isPublicPost from utils import is_public_post
from utils import get_locked_account from utils import get_locked_account
from utils import has_users_path from utils import has_users_path
from utils import get_full_domain from utils import get_full_domain
@ -9989,7 +9989,7 @@ class PubServer(BaseHTTPRequestHandler):
# Otherwize marketers could gain more social graph info # Otherwize marketers could gain more social graph info
if not authorized: if not authorized:
pjo = post_json_object pjo = post_json_object
if not isPublicPost(pjo): if not is_public_post(pjo):
self._404() self._404()
self.server.GETbusy = False self.server.GETbusy = False
return True return True

View File

@ -74,7 +74,7 @@ from utils import get_config_param
from utils import get_domain_from_actor from utils import get_domain_from_actor
from utils import get_nickname_from_actor from utils import get_nickname_from_actor
from utils import follow_person from utils import follow_person
from utils import validNickname from utils import valid_nickname
from utils import get_protocol_prefixes from utils import get_protocol_prefixes
from utils import acct_dir from utils import acct_dir
from media import archiveMedia from media import archiveMedia
@ -2271,7 +2271,7 @@ if args.addaccount:
print('The account domain is expected to be ' + configuredDomain) print('The account domain is expected to be ' + configuredDomain)
sys.exit() sys.exit()
if not validNickname(domain, nickname): if not valid_nickname(domain, nickname):
print(nickname + ' is a reserved name. Use something different.') print(nickname + ' is a reserved name. Use something different.')
sys.exit() sys.exit()
@ -2315,7 +2315,7 @@ if args.addgroup:
if nickname.startswith('!'): if nickname.startswith('!'):
# remove preceding group indicator # remove preceding group indicator
nickname = nickname[1:] nickname = nickname[1:]
if not validNickname(domain, nickname): if not valid_nickname(domain, nickname):
print(nickname + ' is a reserved name. Use something different.') print(nickname + ' is a reserved name. Use something different.')
sys.exit() sys.exit()
if not args.password: if not args.password:

View File

@ -15,7 +15,7 @@ from utils import remove_domain_port
from utils import has_users_path from utils import has_users_path
from utils import get_full_domain from utils import get_full_domain
from utils import get_followers_list from utils import get_followers_list
from utils import validNickname from utils import valid_nickname
from utils import domain_permitted from utils import domain_permitted
from utils import get_domain_from_actor from utils import get_domain_from_actor
from utils import get_nickname_from_actor from utils import get_nickname_from_actor
@ -463,7 +463,7 @@ def getFollowingFeed(base_dir: str, domain: str, port: int, path: str,
nickname = path.replace('/@', '', 1).replace('/' + followFile, '') nickname = path.replace('/@', '', 1).replace('/' + followFile, '')
if not nickname: if not nickname:
return None return None
if not validNickname(domain, nickname): if not valid_nickname(domain, nickname):
return None return None
domain = get_full_domain(domain, port) domain = get_full_domain(domain, port)

View File

@ -12,7 +12,7 @@ from uuid import UUID
from datetime import datetime from datetime import datetime
from datetime import timedelta from datetime import timedelta
from utils import isPublicPost from utils import is_public_post
from utils import load_json from utils import load_json
from utils import save_json from utils import save_json
from utils import locate_post from utils import locate_post
@ -214,7 +214,7 @@ def getTodaysEvents(base_dir: str, nickname: str, domain: str,
if not _isHappeningPost(post_json_object): if not _isHappeningPost(post_json_object):
continue continue
publicEvent = isPublicPost(post_json_object) publicEvent = is_public_post(post_json_object)
postEvent = [] postEvent = []
dayOfMonth = None dayOfMonth = None

View File

@ -43,7 +43,7 @@ from utils import remove_id_ending
from utils import get_protocol_prefixes from utils import get_protocol_prefixes
from utils import is_blog_post from utils import is_blog_post
from utils import remove_avatar_from_cache from utils import remove_avatar_from_cache
from utils import isPublicPost from utils import is_public_post
from utils import get_cached_post_filename from utils import get_cached_post_filename
from utils import remove_post_from_cache from utils import remove_post_from_cache
from utils import url_permitted from utils import url_permitted
@ -205,7 +205,7 @@ def storeHashTags(base_dir: str, nickname: str, domain: str,
"""Extracts hashtags from an incoming post and updates the """Extracts hashtags from an incoming post and updates the
relevant tags files. relevant tags files.
""" """
if not isPublicPost(post_json_object): if not is_public_post(post_json_object):
return return
if not has_object_dict(post_json_object): if not has_object_dict(post_json_object):
return return

View File

@ -10,8 +10,8 @@ __module_group__ = "Metadata"
import os import os
from utils import is_account_dir from utils import is_account_dir
from utils import load_json from utils import load_json
from utils import noOfAccounts from utils import no_of_accounts
from utils import noOfActiveAccountsMonthly from utils import no_of_active_accounts_monthly
def _getStatusCount(base_dir: str) -> int: def _getStatusCount(base_dir: str) -> int:
@ -47,9 +47,9 @@ def metaDataNodeInfo(base_dir: str,
sensitive sensitive
""" """
if showAccounts: if showAccounts:
activeAccounts = noOfAccounts(base_dir) activeAccounts = no_of_accounts(base_dir)
activeAccountsMonthly = noOfActiveAccountsMonthly(base_dir, 1) activeAccountsMonthly = no_of_active_accounts_monthly(base_dir, 1)
activeAccountsHalfYear = noOfActiveAccountsMonthly(base_dir, 6) activeAccountsHalfYear = no_of_active_accounts_monthly(base_dir, 6)
localPosts = _getStatusCount(base_dir) localPosts = _getStatusCount(base_dir)
else: else:
activeAccounts = 1 activeAccounts = 1
@ -132,7 +132,7 @@ def metaDataInstance(showAccounts: bool,
adminActor['preferredUsername'] adminActor['preferredUsername']
if showAccounts: if showAccounts:
activeAccounts = noOfAccounts(base_dir) activeAccounts = no_of_accounts(base_dir)
localPosts = _getStatusCount(base_dir) localPosts = _getStatusCount(base_dir)
else: else:
activeAccounts = 1 activeAccounts = 1

View File

@ -23,7 +23,7 @@ from utils import get_fav_filename_from_url
from utils import get_base_content_from_post from utils import get_base_content_from_post
from utils import has_object_dict from utils import has_object_dict
from utils import first_paragraph_from_string from utils import first_paragraph_from_string
from utils import isPublicPost from utils import is_public_post
from utils import locate_post from utils import locate_post
from utils import load_json from utils import load_json
from utils import save_json from utils import save_json
@ -976,7 +976,7 @@ def _isNewswireBlogPost(post_json_object: {}) -> bool:
post_json_object['object'].get('url') and \ post_json_object['object'].get('url') and \
post_json_object['object'].get('content') and \ post_json_object['object'].get('content') and \
post_json_object['object'].get('published'): post_json_object['object'].get('published'):
return isPublicPost(post_json_object) return is_public_post(post_json_object)
return False return False

View File

@ -45,7 +45,7 @@ from utils import remove_line_endings
from utils import remove_domain_port from utils import remove_domain_port
from utils import get_status_number from utils import get_status_number
from utils import get_full_domain from utils import get_full_domain
from utils import validNickname from utils import valid_nickname
from utils import load_json from utils import load_json
from utils import save_json from utils import save_json
from utils import set_config_param from utils import set_config_param
@ -546,7 +546,7 @@ def registerAccount(base_dir: str, http_prefix: str, domain: str, port: int,
""" """
if _accountExists(base_dir, nickname, domain): if _accountExists(base_dir, nickname, domain):
return False return False
if not validNickname(domain, nickname): if not valid_nickname(domain, nickname):
print('REGISTER: Nickname ' + nickname + ' is invalid') print('REGISTER: Nickname ' + nickname + ' is invalid')
return False return False
if len(password) < 8: if len(password) < 8:
@ -598,7 +598,7 @@ def createPerson(base_dir: str, nickname: str, domain: str, port: int,
group_account: bool = False) -> (str, str, {}, {}): group_account: bool = False) -> (str, str, {}, {}):
"""Returns the private key, public key, actor and webfinger endpoint """Returns the private key, public key, actor and webfinger endpoint
""" """
if not validNickname(domain, nickname): if not valid_nickname(domain, nickname):
return None, None, None, None return None, None, None, None
# If a config.json file doesn't exist then don't decrement # If a config.json file doesn't exist then don't decrement
@ -883,7 +883,7 @@ def personLookup(domain: str, path: str, base_dir: str) -> {}:
nickname = path.replace('/@', '', 1) nickname = path.replace('/@', '', 1)
if not nickname: if not nickname:
return None return None
if not isSharedInbox and not validNickname(domain, nickname): if not isSharedInbox and not valid_nickname(domain, nickname):
return None return None
domain = remove_domain_port(domain) domain = remove_domain_port(domain)
handle = nickname + '@' + domain handle = nickname + '@' + domain
@ -946,7 +946,7 @@ def personBoxJson(recent_posts_cache: {},
nickname = path.replace('/@', '', 1).replace('/' + boxname, '') nickname = path.replace('/@', '', 1).replace('/' + boxname, '')
if not nickname: if not nickname:
return None return None
if not validNickname(domain, nickname): if not valid_nickname(domain, nickname):
return None return None
if boxname == 'inbox': if boxname == 'inbox':
return createInbox(recent_posts_cache, return createInbox(recent_posts_cache,

View File

@ -45,7 +45,7 @@ from utils import has_object_dict
from utils import reject_post_id from utils import reject_post_id
from utils import remove_invalid_chars from utils import remove_invalid_chars
from utils import file_last_modified from utils import file_last_modified
from utils import isPublicPost from utils import is_public_post
from utils import has_users_path from utils import has_users_path
from utils import valid_post_date from utils import valid_post_date
from utils import get_full_domain from utils import get_full_domain
@ -57,7 +57,7 @@ from utils import url_permitted
from utils import get_nickname_from_actor from utils import get_nickname_from_actor
from utils import get_domain_from_actor from utils import get_domain_from_actor
from utils import deletePost from utils import deletePost
from utils import validNickname from utils import valid_nickname
from utils import locate_post from utils import locate_post
from utils import load_json from utils import load_json
from utils import save_json from utils import save_json
@ -2037,7 +2037,7 @@ def getMentionedPeople(base_dir: str, http_prefix: str,
mentionedDomain = handle.split('@')[1].strip('\n').strip('\r') mentionedDomain = handle.split('@')[1].strip('\n').strip('\r')
if ':' in mentionedDomain: if ':' in mentionedDomain:
mentionedDomain = remove_domain_port(mentionedDomain) mentionedDomain = remove_domain_port(mentionedDomain)
if not validNickname(mentionedDomain, mentionedNickname): if not valid_nickname(mentionedDomain, mentionedNickname):
continue continue
actor = \ actor = \
local_actor_url(http_prefix, mentionedNickname, local_actor_url(http_prefix, mentionedNickname,
@ -3580,7 +3580,7 @@ def removePostInteractions(post_json_object: {}, force: bool) -> bool:
if not force: if not force:
# If not authorized and it's a private post # If not authorized and it's a private post
# then just don't show it within timelines # then just don't show it within timelines
if not isPublicPost(post_json_object): if not is_public_post(post_json_object):
return False return False
else: else:
postObj = post_json_object postObj = post_json_object

View File

@ -27,7 +27,7 @@ from utils import date_string_to_seconds
from utils import date_seconds_to_string from utils import date_seconds_to_string
from utils import get_config_param from utils import get_config_param
from utils import get_full_domain from utils import get_full_domain
from utils import validNickname from utils import valid_nickname
from utils import load_json from utils import load_json
from utils import save_json from utils import save_json
from utils import get_image_extensions from utils import get_image_extensions
@ -483,7 +483,7 @@ def getSharesFeedForPerson(base_dir: str,
path.replace('/@', '', 1).replace('/' + sharesFileType, '') path.replace('/@', '', 1).replace('/' + sharesFileType, '')
if not nickname: if not nickname:
return None return None
if not validNickname(domain, nickname): if not valid_nickname(domain, nickname):
return None return None
domain = get_full_domain(domain, port) domain = get_full_domain(domain, port)

View File

@ -70,7 +70,7 @@ from utils import user_agent_domain
from utils import camel_case_split from utils import camel_case_split
from utils import decoded_host from utils import decoded_host
from utils import get_full_domain from utils import get_full_domain
from utils import validNickname from utils import valid_nickname
from utils import first_paragraph_from_string from utils import first_paragraph_from_string
from utils import remove_id_ending from utils import remove_id_ending
from utils import update_recent_posts_cache from utils import update_recent_posts_cache
@ -4189,16 +4189,16 @@ def _testValidNickname():
domain = 'somedomain.net' domain = 'somedomain.net'
nickname = 'myvalidnick' nickname = 'myvalidnick'
assert validNickname(domain, nickname) assert valid_nickname(domain, nickname)
nickname = 'my.invalid.nick' nickname = 'my.invalid.nick'
assert not validNickname(domain, nickname) assert not valid_nickname(domain, nickname)
nickname = 'myinvalidnick?' nickname = 'myinvalidnick?'
assert not validNickname(domain, nickname) assert not valid_nickname(domain, nickname)
nickname = 'my invalid nick?' nickname = 'my invalid nick?'
assert not validNickname(domain, nickname) assert not valid_nickname(domain, nickname)
def _testGuessHashtagCategory() -> None: def _testGuessHashtagCategory() -> None:

View File

@ -1890,7 +1890,7 @@ def _isReservedName(nickname: str) -> bool:
return False return False
def validNickname(domain: str, nickname: str) -> bool: def valid_nickname(domain: str, nickname: str) -> bool:
"""Is the given nickname valid? """Is the given nickname valid?
""" """
if len(nickname) == 0: if len(nickname) == 0:
@ -1911,7 +1911,7 @@ def validNickname(domain: str, nickname: str) -> bool:
return True return True
def noOfAccounts(base_dir: str) -> bool: def no_of_accounts(base_dir: str) -> bool:
"""Returns the number of accounts on the system """Returns the number of accounts on the system
""" """
account_ctr = 0 account_ctr = 0
@ -1923,7 +1923,7 @@ def noOfAccounts(base_dir: str) -> bool:
return account_ctr return account_ctr
def noOfActiveAccountsMonthly(base_dir: str, months: int) -> bool: def no_of_active_accounts_monthly(base_dir: str, months: int) -> bool:
"""Returns the number of accounts on the system this month """Returns the number of accounts on the system this month
""" """
account_ctr = 0 account_ctr = 0
@ -1947,7 +1947,7 @@ def noOfActiveAccountsMonthly(base_dir: str, months: int) -> bool:
return account_ctr return account_ctr
def isPublicPostFromUrl(base_dir: str, nickname: str, domain: str, def is_public_post_from_url(base_dir: str, nickname: str, domain: str,
post_url: str) -> bool: post_url: str) -> bool:
"""Returns whether the given url is a public post """Returns whether the given url is a public post
""" """
@ -1957,10 +1957,10 @@ def isPublicPostFromUrl(base_dir: str, nickname: str, domain: str,
post_json_object = load_json(post_filename, 1) post_json_object = load_json(post_filename, 1)
if not post_json_object: if not post_json_object:
return False return False
return isPublicPost(post_json_object) return is_public_post(post_json_object)
def isPublicPost(post_json_object: {}) -> bool: def is_public_post(post_json_object: {}) -> bool:
"""Returns true if the given post is public """Returns true if the given post is public
""" """
if not post_json_object.get('type'): if not post_json_object.get('type'):

View File

@ -9,7 +9,7 @@ __module_group__ = "Web Interface"
import os import os
from utils import get_new_post_endpoints from utils import get_new_post_endpoints
from utils import isPublicPostFromUrl from utils import is_public_post_from_url
from utils import get_nickname_from_actor from utils import get_nickname_from_actor
from utils import get_domain_from_actor from utils import get_domain_from_actor
from utils import get_media_formats from utils import get_media_formats
@ -287,7 +287,7 @@ def htmlNewPost(css_cache: {}, media_instance: bool, translate: {},
# if replying to a non-public post then also make # if replying to a non-public post then also make
# this post non-public # this post non-public
if not isPublicPostFromUrl(base_dir, nickname, domain, if not is_public_post_from_url(base_dir, nickname, domain,
inReplyTo): inReplyTo):
newPostPath = path newPostPath = path
if '?' in newPostPath: if '?' in newPostPath:

View File

@ -11,7 +11,7 @@ import os
import time import time
from shutil import copyfile from shutil import copyfile
from utils import get_config_param from utils import get_config_param
from utils import noOfAccounts from utils import no_of_accounts
from utils import getNicknameValidationPattern from utils import getNicknameValidationPattern
from webapp_utils import setCustomBackground from webapp_utils import setCustomBackground
from webapp_utils import htmlHeaderWithWebsiteMarkup from webapp_utils import htmlHeaderWithWebsiteMarkup
@ -61,7 +61,7 @@ def htmlLogin(css_cache: {}, translate: {},
autocomplete: bool) -> str: autocomplete: bool) -> str:
"""Shows the login screen """Shows the login screen
""" """
accounts = noOfAccounts(base_dir) accounts = no_of_accounts(base_dir)
loginImage = 'login.png' loginImage = 'login.png'
loginImageFilename = None loginImageFilename = None

View File

@ -45,7 +45,7 @@ from utils import get_protocol_prefixes
from utils import is_news_post from utils import is_news_post
from utils import is_blog_post from utils import is_blog_post
from utils import get_display_name from utils import get_display_name
from utils import isPublicPost from utils import is_public_post
from utils import update_recent_posts_cache from utils import update_recent_posts_cache
from utils import remove_id_ending from utils import remove_id_ending
from utils import get_nickname_from_actor from utils import get_nickname_from_actor
@ -1486,7 +1486,7 @@ def individualPostAsHtml(signing_priv_key_pem: str,
if postIsDM: if postIsDM:
showRepeatIcon = False showRepeatIcon = False
else: else:
if not isPublicPost(post_json_object): if not is_public_post(post_json_object):
isPublicRepeat = True isPublicRepeat = True
titleStr = '' titleStr = ''
@ -1635,7 +1635,7 @@ def individualPostAsHtml(signing_priv_key_pem: str,
conversationId = post_json_object['object']['conversation'] conversationId = post_json_object['object']['conversation']
publicReply = False publicReply = False
if isPublicPost(post_json_object): if is_public_post(post_json_object):
publicReply = True publicReply = True
replyStr = _getReplyIconHtml(base_dir, nickname, domain, replyStr = _getReplyIconHtml(base_dir, nickname, domain,
publicReply, publicReply,

View File

@ -20,7 +20,7 @@ from utils import load_json
from utils import get_domain_from_actor from utils import get_domain_from_actor
from utils import get_nickname_from_actor from utils import get_nickname_from_actor
from utils import locate_post from utils import locate_post
from utils import isPublicPost from utils import is_public_post
from utils import first_paragraph_from_string from utils import first_paragraph_from_string
from utils import search_box_posts from utils import search_box_posts
from utils import get_alt_path from utils import get_alt_path
@ -839,7 +839,7 @@ def htmlHashtagSearch(css_cache: {},
if not post_json_object: if not post_json_object:
index += 1 index += 1
continue continue
if not isPublicPost(post_json_object): if not is_public_post(post_json_object):
index += 1 index += 1
continue continue
showIndividualPostIcons = False showIndividualPostIcons = False
@ -964,7 +964,7 @@ def rssHashtagSearch(nickname: str, domain: str, port: int,
continue continue
post_json_object = load_json(post_filename) post_json_object = load_json(post_filename)
if post_json_object: if post_json_object:
if not isPublicPost(post_json_object): if not is_public_post(post_json_object):
index += 1 index += 1
if index >= maxFeedLength: if index >= maxFeedLength:
break break