Snake case

merge-requests/30/head
Bob Mottram 2021-12-26 12:24:40 +00:00
parent fc98441a40
commit 257f29a815
8 changed files with 23 additions and 23 deletions

View File

@ -14,7 +14,7 @@ from session import getJson
from utils import loadJson from utils import loadJson
from utils import saveJson from utils import saveJson
from utils import getFileCaseInsensitive from utils import getFileCaseInsensitive
from utils import getUserPaths from utils import get_user_paths
def _removePersonFromCache(base_dir: str, personUrl: str, def _removePersonFromCache(base_dir: str, personUrl: str,
@ -144,7 +144,7 @@ def getPersonPubKey(base_dir: str, session, personUrl: str,
if not personUrl: if not personUrl:
return None return None
personUrl = personUrl.replace('#main-key', '') personUrl = personUrl.replace('#main-key', '')
usersPaths = getUserPaths() usersPaths = get_user_paths()
for possibleUsersPath in usersPaths: for possibleUsersPath in usersPaths:
if personUrl.endswith(possibleUsersPath + 'inbox'): if personUrl.endswith(possibleUsersPath + 'inbox'):
if debug: if debug:

View File

@ -26,7 +26,7 @@ from posts import getPersonBox
from utils import loadJson from utils import loadJson
from utils import saveJson from utils import saveJson
from utils import isAccountDir from utils import isAccountDir
from utils import getUserPaths from utils import get_user_paths
from utils import acct_dir from utils import acct_dir
from utils import hasGroupType from utils import hasGroupType
from utils import local_actor_url from utils import local_actor_url
@ -118,7 +118,7 @@ def _removeFromFollowBase(base_dir: str,
acceptDenyDomain = acceptOrDenyHandle.split('@')[1] acceptDenyDomain = acceptOrDenyHandle.split('@')[1]
# for each possible users path construct an actor and # for each possible users path construct an actor and
# check if it exists in teh file # check if it exists in teh file
usersPaths = getUserPaths() usersPaths = get_user_paths()
actorFound = False actorFound = False
for usersName in usersPaths: for usersName in usersPaths:
acceptDenyActor = \ acceptDenyActor = \
@ -271,7 +271,7 @@ def isFollowerOfPerson(base_dir: str, nickname: str, domain: str,
if handle in followersStr: if handle in followersStr:
alreadyFollowing = True alreadyFollowing = True
else: else:
paths = getUserPaths() paths = get_user_paths()
for userPath in paths: for userPath in paths:
url = '://' + followerDomain + userPath + followerNickname url = '://' + followerDomain + userPath + followerNickname
if url in followersStr: if url in followersStr:
@ -652,7 +652,7 @@ def storeFollowRequest(base_dir: str,
if approveHandle in followersStr: if approveHandle in followersStr:
alreadyFollowing = True alreadyFollowing = True
else: else:
usersPaths = getUserPaths() usersPaths = get_user_paths()
for possibleUsersPath in usersPaths: for possibleUsersPath in usersPaths:
url = '://' + domain_full + possibleUsersPath + nickname url = '://' + domain_full + possibleUsersPath + nickname
if url in followersStr: if url in followersStr:

View File

@ -27,7 +27,7 @@ from utils import hasObjectString
from utils import hasObjectStringObject from utils import hasObjectStringObject
from utils import getReplyIntervalHours from utils import getReplyIntervalHours
from utils import canReplyTo from utils import canReplyTo
from utils import getUserPaths from utils import get_user_paths
from utils import get_base_content_from_post from utils import get_base_content_from_post
from utils import acct_dir from utils import acct_dir
from utils import removeDomainPort from utils import removeDomainPort
@ -836,7 +836,7 @@ def _personReceiveUpdate(base_dir: str,
' ' + str(personJson)) ' ' + str(personJson))
domain_full = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
updateDomainFull = getFullDomain(updateDomain, updatePort) updateDomainFull = getFullDomain(updateDomain, updatePort)
usersPaths = getUserPaths() usersPaths = get_user_paths()
usersStrFound = False usersStrFound = False
for usersStr in usersPaths: for usersStr in usersPaths:
actor = updateDomainFull + usersStr + updateNickname actor = updateDomainFull + usersStr + updateNickname

View File

@ -14,7 +14,7 @@ from follow import removeFromFollowRequests
from utils import loadJson from utils import loadJson
from utils import removeDomainPort from utils import removeDomainPort
from utils import getPortFromDomain from utils import getPortFromDomain
from utils import getUserPaths from utils import get_user_paths
from utils import acct_dir from utils import acct_dir
from threads import threadWithTrace from threads import threadWithTrace
@ -157,7 +157,7 @@ def manualApproveFollowRequest(session, base_dir: str,
reqNick = approveHandle.split('@')[0].replace('!', '') reqNick = approveHandle.split('@')[0].replace('!', '')
reqDomain = approveHandle.split('@')[1].strip() reqDomain = approveHandle.split('@')[1].strip()
reqPrefix = http_prefix + '://' + reqDomain reqPrefix = http_prefix + '://' + reqDomain
paths = getUserPaths() paths = get_user_paths()
for userPath in paths: for userPath in paths:
if reqPrefix + userPath + reqNick in approveFollowsStr: if reqPrefix + userPath + reqNick in approveFollowsStr:
exists = True exists = True

View File

@ -56,7 +56,7 @@ from utils import has_users_path
from utils import getImageExtensions from utils import getImageExtensions
from utils import isImageFile from utils import isImageFile
from utils import acct_dir from utils import acct_dir
from utils import getUserPaths from utils import get_user_paths
from utils import getGroupPaths from utils import getGroupPaths
from utils import local_actor_url from utils import local_actor_url
from utils import dangerousSVG from utils import dangerousSVG
@ -1421,7 +1421,7 @@ def _detectUsersPath(url: str) -> str:
""" """
if '/' not in url: if '/' not in url:
return '/users/' return '/users/'
usersPaths = getUserPaths() usersPaths = get_user_paths()
for possibleUsersPath in usersPaths: for possibleUsersPath in usersPaths:
if possibleUsersPath in url: if possibleUsersPath in url:
return possibleUsersPath return possibleUsersPath
@ -1460,7 +1460,7 @@ def getActorJson(hostDomain: str, handle: str, http: bool, gnunet: bool,
for prefix in prefixes: for prefix in prefixes:
handle = handle.replace(prefix, '') handle = handle.replace(prefix, '')
handle = handle.replace('/@', detectedUsersPath) handle = handle.replace('/@', detectedUsersPath)
paths = getUserPaths() paths = get_user_paths()
userPathFound = False userPathFound = False
for userPath in paths: for userPath in paths:
if userPath in handle: if userPath in handle:
@ -1570,7 +1570,7 @@ def getActorJson(hostDomain: str, handle: str, http: bool, gnunet: bool,
if not personUrl and wfRequest: if not personUrl and wfRequest:
personUrl = getUserUrl(wfRequest, 0, debug) personUrl = getUserUrl(wfRequest, 0, debug)
if nickname == domain: if nickname == domain:
paths = getUserPaths() paths = get_user_paths()
for userPath in paths: for userPath in paths:
personUrl = personUrl.replace(userPath, '/actor/') personUrl = personUrl.replace(userPath, '/actor/')
if not personUrl and group_account: if not personUrl and group_account:

View File

@ -32,7 +32,7 @@ from webfinger import webfingerHandle
from httpsig import createSignedHeader from httpsig import createSignedHeader
from siteactive import siteIsActive from siteactive import siteIsActive
from languages import understoodPostLanguage from languages import understoodPostLanguage
from utils import getUserPaths from utils import get_user_paths
from utils import invalidCiphertext from utils import invalidCiphertext
from utils import hasObjectStringType from utils import hasObjectStringType
from utils import removeIdEnding from utils import removeIdEnding
@ -1271,7 +1271,7 @@ def _consolidateActorsList(actorsList: []) -> None:
if ccActor not in possibleDuplicateActors: if ccActor not in possibleDuplicateActors:
possibleDuplicateActors.append(ccActor) possibleDuplicateActors.append(ccActor)
if possibleDuplicateActors: if possibleDuplicateActors:
uPaths = getUserPaths() uPaths = get_user_paths()
removeActors = [] removeActors = []
for ccActor in possibleDuplicateActors: for ccActor in possibleDuplicateActors:
for usrPath in uPaths: for usrPath in uPaths:

View File

@ -194,7 +194,7 @@ def get_locked_account(actor_json: {}) -> bool:
def has_users_path(pathStr: str) -> bool: def has_users_path(pathStr: str) -> bool:
"""Whether there is a /users/ path (or equivalent) in the given string """Whether there is a /users/ path (or equivalent) in the given string
""" """
usersList = getUserPaths() usersList = get_user_paths()
for usersStr in usersList: for usersStr in usersList:
if usersStr in pathStr: if usersStr in pathStr:
return True return True
@ -1022,7 +1022,7 @@ def getNicknameFromActor(actor: str) -> str:
""" """
if actor.startswith('@'): if actor.startswith('@'):
actor = actor[1:] actor = actor[1:]
usersPaths = getUserPaths() usersPaths = get_user_paths()
for possiblePath in usersPaths: for possiblePath in usersPaths:
if possiblePath in actor: if possiblePath in actor:
nickStr = actor.split(possiblePath)[1].replace('@', '') nickStr = actor.split(possiblePath)[1].replace('@', '')
@ -1052,7 +1052,7 @@ def getNicknameFromActor(actor: str) -> str:
return None return None
def getUserPaths() -> []: def get_user_paths() -> []:
"""Returns possible user paths """Returns possible user paths
e.g. /users/nickname, /channel/nickname e.g. /users/nickname, /channel/nickname
""" """
@ -1074,7 +1074,7 @@ def getDomainFromActor(actor: str) -> (str, int):
actor = actor[1:] actor = actor[1:]
port = None port = None
prefixes = getProtocolPrefixes() prefixes = getProtocolPrefixes()
usersPaths = getUserPaths() usersPaths = get_user_paths()
for possiblePath in usersPaths: for possiblePath in usersPaths:
if possiblePath in actor: if possiblePath in actor:
domain = actor.split(possiblePath)[0] domain = actor.split(possiblePath)[0]
@ -3148,7 +3148,7 @@ def getSharesFilesList() -> []:
def replaceUsersWithAt(actor: str) -> str: def replaceUsersWithAt(actor: str) -> str:
""" https://domain/users/nick becomes https://domain/@nick """ https://domain/users/nick becomes https://domain/@nick
""" """
uPaths = getUserPaths() uPaths = get_user_paths()
for path in uPaths: for path in uPaths:
if path in actor: if path in actor:
actor = actor.replace(path, '/@') actor = actor.replace(path, '/@')

View File

@ -18,7 +18,7 @@ from utils import loadJsonOnionify
from utils import saveJson from utils import saveJson
from utils import getProtocolPrefixes from utils import getProtocolPrefixes
from utils import removeDomainPort from utils import removeDomainPort
from utils import getUserPaths from utils import get_user_paths
from utils import getGroupPaths from utils import getGroupPaths
from utils import local_actor_url from utils import local_actor_url
@ -48,7 +48,7 @@ def _parseHandle(handle: str) -> (str, str, bool):
return nickname, domain, group_account return nickname, domain, group_account
# try for different /users/ paths # try for different /users/ paths
usersPaths = getUserPaths() usersPaths = get_user_paths()
groupPaths = getGroupPaths() groupPaths = getGroupPaths()
for possibleUsersPath in usersPaths: for possibleUsersPath in usersPaths:
if possibleUsersPath in handle: if possibleUsersPath in handle: