Snake case

main
Bob Mottram 2021-12-27 11:31:04 +00:00
parent 48f51887b8
commit e58e1435d5
2 changed files with 21 additions and 21 deletions

View File

@ -81,7 +81,7 @@ from utils import copytree
from utils import load_json from utils import load_json
from utils import save_json from utils import save_json
from utils import getStatusNumber from utils import getStatusNumber
from utils import getFollowersOfPerson from utils import get_followers_of_person
from utils import removeHtml from utils import removeHtml
from utils import dangerousMarkup from utils import dangerousMarkup
from utils import acct_dir from utils import acct_dir
@ -2473,7 +2473,7 @@ def _testFollowersOfPerson(base_dir: str) -> None:
followPerson(base_dir, nickname, domain, 'someother', 'randodomain.net', followPerson(base_dir, nickname, domain, 'someother', 'randodomain.net',
federation_list, False, False) federation_list, False, False)
followList = getFollowersOfPerson(base_dir, 'ultrapancake', domain) followList = get_followers_of_person(base_dir, 'ultrapancake', domain)
assert len(followList) == 3 assert len(followList) == 3
assert 'mxpop@' + domain in followList assert 'mxpop@' + domain in followList
assert 'drokk@' + domain in followList assert 'drokk@' + domain in followList

View File

@ -566,9 +566,9 @@ def getFollowersList(base_dir: str,
return [] return []
def getFollowersOfPerson(base_dir: str, def get_followers_of_person(base_dir: str,
nickname: str, domain: str, nickname: str, domain: str,
followFile='following.txt') -> []: follow_file='following.txt') -> []:
"""Returns a list containing the followers of the given person """Returns a list containing the followers of the given person
Used by the shared inbox to know who to send incoming mail to Used by the shared inbox to know who to send incoming mail to
""" """
@ -579,7 +579,7 @@ def getFollowersOfPerson(base_dir: str,
return followers return followers
for subdir, dirs, files in os.walk(base_dir + '/accounts'): for subdir, dirs, files in os.walk(base_dir + '/accounts'):
for account in dirs: for account in dirs:
filename = os.path.join(subdir, account) + '/' + followFile filename = os.path.join(subdir, account) + '/' + follow_file
if account == handle or \ if account == handle or \
account.startswith('inbox@') or \ account.startswith('inbox@') or \
account.startswith('news@'): account.startswith('news@'):
@ -598,20 +598,20 @@ def getFollowersOfPerson(base_dir: str,
return followers return followers
def remove_id_ending(idStr: str) -> str: def remove_id_ending(id_str: str) -> str:
"""Removes endings such as /activity and /undo """Removes endings such as /activity and /undo
""" """
if idStr.endswith('/activity'): if id_str.endswith('/activity'):
idStr = idStr[:-len('/activity')] id_str = id_str[:-len('/activity')]
elif idStr.endswith('/undo'): elif id_str.endswith('/undo'):
idStr = idStr[:-len('/undo')] id_str = id_str[:-len('/undo')]
elif idStr.endswith('/event'): elif id_str.endswith('/event'):
idStr = idStr[:-len('/event')] id_str = id_str[:-len('/event')]
elif idStr.endswith('/replies'): elif id_str.endswith('/replies'):
idStr = idStr[:-len('/replies')] id_str = id_str[:-len('/replies')]
if idStr.endswith('#Create'): if id_str.endswith('#Create'):
idStr = idStr.split('#Create')[0] id_str = id_str.split('#Create')[0]
return idStr return id_str
def removeHashFromPostId(post_id: str) -> str: def removeHashFromPostId(post_id: str) -> str:
@ -1136,7 +1136,7 @@ def followPerson(base_dir: str, nickname: str, domain: str,
followNickname: str, followDomain: str, followNickname: str, followDomain: str,
federation_list: [], debug: bool, federation_list: [], debug: bool,
group_account: bool, group_account: bool,
followFile: str = 'following.txt') -> bool: follow_file: str = 'following.txt') -> bool:
"""Adds a person to the follow list """Adds a person to the follow list
""" """
followDomainStrLower = followDomain.lower().replace('\n', '') followDomainStrLower = followDomain.lower().replace('\n', '')
@ -1187,7 +1187,7 @@ def followPerson(base_dir: str, nickname: str, domain: str,
handleToFollow = followNickname + '@' + followDomain handleToFollow = followNickname + '@' + followDomain
if group_account: if group_account:
handleToFollow = '!' + handleToFollow handleToFollow = '!' + handleToFollow
filename = base_dir + '/accounts/' + handle + '/' + followFile filename = base_dir + '/accounts/' + handle + '/' + follow_file
if os.path.isfile(filename): if os.path.isfile(filename):
if handleToFollow in open(filename).read(): if handleToFollow in open(filename).read():
if debug: if debug:
@ -1213,7 +1213,7 @@ def followPerson(base_dir: str, nickname: str, domain: str,
with open(filename, 'w+') as f: with open(filename, 'w+') as f:
f.write(handleToFollow + '\n') f.write(handleToFollow + '\n')
if followFile.endswith('following.txt'): if follow_file.endswith('following.txt'):
# Default to adding new follows to the calendar. # Default to adding new follows to the calendar.
# Possibly this could be made optional # Possibly this could be made optional
# if following a person add them to the list of # if following a person add them to the list of