From e2b7407e966f5476714dc0593faa6b62d05cdd42 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 27 Dec 2021 15:41:04 +0000 Subject: [PATCH] Snake case --- auth.py | 6 +++--- daemon.py | 6 +++--- inbox.py | 4 ++-- utils.py | 12 ++++++------ webapp_frontscreen.py | 4 ++-- webapp_profile.py | 6 +++--- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/auth.py b/auth.py index d51bb0893..1123f0dfb 100644 --- a/auth.py +++ b/auth.py @@ -13,7 +13,7 @@ import binascii import os import secrets import datetime -from utils import isSystemAccount +from utils import is_system_account 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') return False nicknameFromPath = pathUsersSection.split('/')[0] - if isSystemAccount(nicknameFromPath): + if is_system_account(nicknameFromPath): print('basic auth - attempted login using system account ' + nicknameFromPath + ' in path') return False @@ -116,7 +116,7 @@ def authorizeBasic(base_dir: str, path: str, authHeader: str, 'separator for username:password') return False nickname = plain.split(':')[0] - if isSystemAccount(nickname): + if is_system_account(nickname): print('basic auth - attempted login using system account ' + nickname + ' in Auth header') return False diff --git a/daemon.py b/daemon.py index 2ec1729a3..1f61d56b3 100644 --- a/daemon.py +++ b/daemon.py @@ -282,7 +282,7 @@ from utils import getCSS from utils import firstParagraphFromString from utils import clearFromPostCaches from utils import containsInvalidChars -from utils import isSystemAccount +from utils import is_system_account from utils import setConfigParam from utils import get_config_param from utils import remove_id_ending @@ -1584,7 +1584,7 @@ class PubServer(BaseHTTPRequestHandler): tokenStr = tokenStr.split(';')[0].strip() if self.server.tokens_lookup.get(tokenStr): nickname = self.server.tokens_lookup[tokenStr] - if not isSystemAccount(nickname): + if not is_system_account(nickname): self.authorizedNickname = nickname # default to the inbox of the person if self.path == '/': @@ -1679,7 +1679,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.last_login_time, self.server.domain) if loginNickname: - if isSystemAccount(loginNickname): + if is_system_account(loginNickname): print('Invalid username login: ' + loginNickname + ' (system account)') self._clearLoginDetails(loginNickname, calling_domain) diff --git a/inbox.py b/inbox.py index cf2611687..c5f5d636c 100644 --- a/inbox.py +++ b/inbox.py @@ -19,7 +19,7 @@ from reaction import updateReactionCollection from reaction import validEmojiContent from utils import domainPermitted from utils import is_group_account -from utils import isSystemAccount +from utils import is_system_account from utils import invalid_ciphertext from utils import removeHtml 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 ' + 'nickname for the account followed') return True - if isSystemAccount(nicknameToFollow): + if is_system_account(nicknameToFollow): if debug: print('DEBUG: Cannot follow system account - ' + nicknameToFollow) diff --git a/utils.py b/utils.py index f2f1f888e..d89fbae92 100644 --- a/utils.py +++ b/utils.py @@ -486,7 +486,7 @@ def firstParagraphFromString(content: str) -> str: 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 """ if nickname == 'news' or nickname == 'inbox': @@ -505,7 +505,7 @@ def _create_config(base_dir: str) -> None: 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 """ _create_config(base_dir) @@ -513,19 +513,19 @@ def setConfigParam(base_dir: str, variableName: str, variableValue) -> None: configJson = {} if os.path.isfile(config_filename): configJson = load_json(config_filename) - configJson[variableName] = variableValue + configJson[variable_name] = variable_value 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 """ _create_config(base_dir) config_filename = base_dir + '/config.json' configJson = load_json(config_filename) if configJson: - if variableName in configJson: - return configJson[variableName] + if variable_name in configJson: + return configJson[variable_name] return None diff --git a/webapp_frontscreen.py b/webapp_frontscreen.py index 49b8a2509..a673a2d74 100644 --- a/webapp_frontscreen.py +++ b/webapp_frontscreen.py @@ -8,7 +8,7 @@ __status__ = "Production" __module_group__ = "Timeline" import os -from utils import isSystemAccount +from utils import is_system_account from utils import getDomainFromActor from utils import get_config_param from person import personBoxJson @@ -120,7 +120,7 @@ def htmlFrontScreen(signing_priv_key_pem: str, nickname = profile_json['preferredUsername'] if not nickname: return "" - if not isSystemAccount(nickname): + if not is_system_account(nickname): return "" domain, port = getDomainFromActor(profile_json['id']) if not domain: diff --git a/webapp_profile.py b/webapp_profile.py index 80a76804b..3e984e418 100644 --- a/webapp_profile.py +++ b/webapp_profile.py @@ -20,7 +20,7 @@ from utils import is_artist from utils import is_dormant from utils import getNicknameFromActor from utils import getDomainFromActor -from utils import isSystemAccount +from utils import is_system_account from utils import removeHtml from utils import load_json from utils import get_config_param @@ -569,7 +569,7 @@ def htmlProfile(signing_priv_key_pem: str, nickname = profile_json['preferredUsername'] if not nickname: return "" - if isSystemAccount(nickname): + if is_system_account(nickname): return htmlFrontScreen(signing_priv_key_pem, rss_icon_at_top, cssCache, icons_as_buttons, @@ -652,7 +652,7 @@ def htmlProfile(signing_priv_key_pem: str, PGPfingerprint or emailAddress: donateSection = '
\n' donateSection += '
\n' - if donateUrl and not isSystemAccount(nickname): + if donateUrl and not is_system_account(nickname): donateSection += \ '