Snake case

merge-requests/30/head
Bob Mottram 2021-12-27 15:41:04 +00:00
parent 6c928801fa
commit e2b7407e96
6 changed files with 19 additions and 19 deletions

View File

@ -13,7 +13,7 @@ import binascii
import os import os
import secrets import secrets
import datetime import datetime
from utils import isSystemAccount from utils import is_system_account
from utils import has_users_path from utils import has_users_path
@ -103,7 +103,7 @@ def authorizeBasic(base_dir: str, path: str, authHeader: str,
print('DEBUG: basic auth - this is not a users endpoint') print('DEBUG: basic auth - this is not a users endpoint')
return False return False
nicknameFromPath = pathUsersSection.split('/')[0] nicknameFromPath = pathUsersSection.split('/')[0]
if isSystemAccount(nicknameFromPath): if is_system_account(nicknameFromPath):
print('basic auth - attempted login using system account ' + print('basic auth - attempted login using system account ' +
nicknameFromPath + ' in path') nicknameFromPath + ' in path')
return False return False
@ -116,7 +116,7 @@ def authorizeBasic(base_dir: str, path: str, authHeader: str,
'separator for username:password') 'separator for username:password')
return False return False
nickname = plain.split(':')[0] nickname = plain.split(':')[0]
if isSystemAccount(nickname): if is_system_account(nickname):
print('basic auth - attempted login using system account ' + nickname + print('basic auth - attempted login using system account ' + nickname +
' in Auth header') ' in Auth header')
return False return False

View File

@ -282,7 +282,7 @@ from utils import getCSS
from utils import firstParagraphFromString from utils import firstParagraphFromString
from utils import clearFromPostCaches from utils import clearFromPostCaches
from utils import containsInvalidChars from utils import containsInvalidChars
from utils import isSystemAccount from utils import is_system_account
from utils import setConfigParam from utils import setConfigParam
from utils import get_config_param from utils import get_config_param
from utils import remove_id_ending from utils import remove_id_ending
@ -1584,7 +1584,7 @@ class PubServer(BaseHTTPRequestHandler):
tokenStr = tokenStr.split(';')[0].strip() tokenStr = tokenStr.split(';')[0].strip()
if self.server.tokens_lookup.get(tokenStr): if self.server.tokens_lookup.get(tokenStr):
nickname = self.server.tokens_lookup[tokenStr] nickname = self.server.tokens_lookup[tokenStr]
if not isSystemAccount(nickname): if not is_system_account(nickname):
self.authorizedNickname = nickname self.authorizedNickname = nickname
# default to the inbox of the person # default to the inbox of the person
if self.path == '/': if self.path == '/':
@ -1679,7 +1679,7 @@ class PubServer(BaseHTTPRequestHandler):
self.server.last_login_time, self.server.last_login_time,
self.server.domain) self.server.domain)
if loginNickname: if loginNickname:
if isSystemAccount(loginNickname): if is_system_account(loginNickname):
print('Invalid username login: ' + loginNickname + print('Invalid username login: ' + loginNickname +
' (system account)') ' (system account)')
self._clearLoginDetails(loginNickname, calling_domain) self._clearLoginDetails(loginNickname, calling_domain)

View File

@ -19,7 +19,7 @@ from reaction import updateReactionCollection
from reaction import validEmojiContent from reaction import validEmojiContent
from utils import domainPermitted from utils import domainPermitted
from utils import is_group_account from utils import is_group_account
from utils import isSystemAccount from utils import is_system_account
from utils import invalid_ciphertext from utils import invalid_ciphertext
from utils import removeHtml from utils import removeHtml
from utils import fileLastModified from utils import fileLastModified
@ -3911,7 +3911,7 @@ def _receiveFollowRequest(session, base_dir: str, http_prefix: str,
print('DEBUG: follow request does not contain a ' + print('DEBUG: follow request does not contain a ' +
'nickname for the account followed') 'nickname for the account followed')
return True return True
if isSystemAccount(nicknameToFollow): if is_system_account(nicknameToFollow):
if debug: if debug:
print('DEBUG: Cannot follow system account - ' + print('DEBUG: Cannot follow system account - ' +
nicknameToFollow) nicknameToFollow)

View File

@ -486,7 +486,7 @@ def firstParagraphFromString(content: str) -> str:
return removeHtml(paragraph) return removeHtml(paragraph)
def isSystemAccount(nickname: str) -> bool: def is_system_account(nickname: str) -> bool:
"""Returns true if the given nickname is a system account """Returns true if the given nickname is a system account
""" """
if nickname == 'news' or nickname == 'inbox': if nickname == 'news' or nickname == 'inbox':
@ -505,7 +505,7 @@ def _create_config(base_dir: str) -> None:
save_json(config_json, config_filename) save_json(config_json, config_filename)
def setConfigParam(base_dir: str, variableName: str, variableValue) -> None: def setConfigParam(base_dir: str, variable_name: str, variable_value) -> None:
"""Sets a configuration value """Sets a configuration value
""" """
_create_config(base_dir) _create_config(base_dir)
@ -513,19 +513,19 @@ def setConfigParam(base_dir: str, variableName: str, variableValue) -> None:
configJson = {} configJson = {}
if os.path.isfile(config_filename): if os.path.isfile(config_filename):
configJson = load_json(config_filename) configJson = load_json(config_filename)
configJson[variableName] = variableValue configJson[variable_name] = variable_value
save_json(configJson, config_filename) save_json(configJson, config_filename)
def get_config_param(base_dir: str, variableName: str): def get_config_param(base_dir: str, variable_name: str):
"""Gets a configuration value """Gets a configuration value
""" """
_create_config(base_dir) _create_config(base_dir)
config_filename = base_dir + '/config.json' config_filename = base_dir + '/config.json'
configJson = load_json(config_filename) configJson = load_json(config_filename)
if configJson: if configJson:
if variableName in configJson: if variable_name in configJson:
return configJson[variableName] return configJson[variable_name]
return None return None

View File

@ -8,7 +8,7 @@ __status__ = "Production"
__module_group__ = "Timeline" __module_group__ = "Timeline"
import os import os
from utils import isSystemAccount from utils import is_system_account
from utils import getDomainFromActor from utils import getDomainFromActor
from utils import get_config_param from utils import get_config_param
from person import personBoxJson from person import personBoxJson
@ -120,7 +120,7 @@ def htmlFrontScreen(signing_priv_key_pem: str,
nickname = profile_json['preferredUsername'] nickname = profile_json['preferredUsername']
if not nickname: if not nickname:
return "" return ""
if not isSystemAccount(nickname): if not is_system_account(nickname):
return "" return ""
domain, port = getDomainFromActor(profile_json['id']) domain, port = getDomainFromActor(profile_json['id'])
if not domain: if not domain:

View File

@ -20,7 +20,7 @@ from utils import is_artist
from utils import is_dormant from utils import is_dormant
from utils import getNicknameFromActor from utils import getNicknameFromActor
from utils import getDomainFromActor from utils import getDomainFromActor
from utils import isSystemAccount from utils import is_system_account
from utils import removeHtml from utils import removeHtml
from utils import load_json from utils import load_json
from utils import get_config_param from utils import get_config_param
@ -569,7 +569,7 @@ def htmlProfile(signing_priv_key_pem: str,
nickname = profile_json['preferredUsername'] nickname = profile_json['preferredUsername']
if not nickname: if not nickname:
return "" return ""
if isSystemAccount(nickname): if is_system_account(nickname):
return htmlFrontScreen(signing_priv_key_pem, return htmlFrontScreen(signing_priv_key_pem,
rss_icon_at_top, rss_icon_at_top,
cssCache, icons_as_buttons, cssCache, icons_as_buttons,
@ -652,7 +652,7 @@ def htmlProfile(signing_priv_key_pem: str,
PGPfingerprint or emailAddress: PGPfingerprint or emailAddress:
donateSection = '<div class="container">\n' donateSection = '<div class="container">\n'
donateSection += ' <center>\n' donateSection += ' <center>\n'
if donateUrl and not isSystemAccount(nickname): if donateUrl and not is_system_account(nickname):
donateSection += \ donateSection += \
' <p><a href="' + donateUrl + \ ' <p><a href="' + donateUrl + \
'"><button class="donateButton">' + translate['Donate'] + \ '"><button class="donateButton">' + translate['Donate'] + \