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

View File

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