Snake case

merge-requests/30/head
Bob Mottram 2021-12-27 17:57:27 +00:00
parent b63039ae47
commit 60302e0697
2 changed files with 11 additions and 11 deletions

View File

@ -14,7 +14,7 @@ from utils import remove_id_ending
from utils import has_users_path
from utils import get_full_domain
from utils import get_status_number
from utils import createOutboxDir
from utils import create_outbox_dir
from utils import urlPermitted
from utils import getNicknameFromActor
from utils import getDomainFromActor
@ -157,7 +157,7 @@ def createAnnounce(session, base_dir: str, federation_list: [],
if len(ccUrl) > 0:
newAnnounce['cc'] = [ccUrl]
if saveToFile:
outboxDir = createOutboxDir(nickname, domain, base_dir)
outboxDir = create_outbox_dir(nickname, domain, base_dir)
filename = outboxDir + '/' + newAnnounceId.replace('/', '#') + '.json'
save_json(newAnnounce, filename)

View File

@ -777,27 +777,27 @@ def contains_invalid_chars(json_str: str) -> bool:
def removeInvalidChars(text: str) -> str:
"""Removes any invalid characters from a string
"""
for isInvalid in INVALID_CHARACTERS:
if isInvalid not in text:
for is_invalid in INVALID_CHARACTERS:
if is_invalid not in text:
continue
text = text.replace(isInvalid, '')
text = text.replace(is_invalid, '')
return text
def createPersonDir(nickname: str, domain: str, base_dir: str,
dirname: str) -> str:
dir_name: str) -> str:
"""Create a directory for a person
"""
handle = nickname + '@' + domain
if not os.path.isdir(base_dir + '/accounts/' + handle):
os.mkdir(base_dir + '/accounts/' + handle)
boxDir = base_dir + '/accounts/' + handle + '/' + dirname
if not os.path.isdir(boxDir):
os.mkdir(boxDir)
return boxDir
box_dir = base_dir + '/accounts/' + handle + '/' + dir_name
if not os.path.isdir(box_dir):
os.mkdir(box_dir)
return box_dir
def createOutboxDir(nickname: str, domain: str, base_dir: str) -> str:
def create_outbox_dir(nickname: str, domain: str, base_dir: str) -> str:
"""Create an outbox for a person
"""
return createPersonDir(nickname, domain, base_dir, 'outbox')