Snake case

main
Bob Mottram 2021-12-27 17:08:19 +00:00
parent 322338a455
commit 2a57353f56
5 changed files with 63 additions and 62 deletions

View File

@ -15,7 +15,7 @@ from utils import urlPermitted
from utils import getDomainFromActor
from utils import getNicknameFromActor
from utils import domainPermitted
from utils import followPerson
from utils import follow_person
from utils import acct_dir
from utils import has_group_type
from utils import local_actor_url
@ -168,10 +168,10 @@ def _accept_follow(base_dir: str, domain: str, message_json: {},
print('Accepted follow is a group: ' + str(group_account) +
' ' + followed_actor + ' ' + base_dir)
if followPerson(base_dir,
nickname, accepted_domain_full,
followed_nickname, followed_domain_full,
federation_list, debug, group_account):
if follow_person(base_dir,
nickname, accepted_domain_full,
followed_nickname, followed_domain_full,
federation_list, debug, group_account):
if debug:
print('DEBUG: ' + nickname + '@' + accepted_domain_full +
' followed ' +

View File

@ -73,7 +73,7 @@ from utils import setConfigParam
from utils import get_config_param
from utils import getDomainFromActor
from utils import getNicknameFromActor
from utils import followPerson
from utils import follow_person
from utils import validNickname
from utils import getProtocolPrefixes
from utils import acct_dir
@ -2982,14 +2982,14 @@ if args.testdata:
low_bandwidth, args.content_license_url)
domain_full = domain + ':' + str(port)
clearFollows(base_dir, nickname, domain)
followPerson(base_dir, nickname, domain, 'maxboardroom', domain_full,
federation_list, False, False)
followPerson(base_dir, nickname, domain, 'ultrapancake', domain_full,
federation_list, False, False)
followPerson(base_dir, nickname, domain, 'sausagedog', domain_full,
federation_list, False, False)
followPerson(base_dir, nickname, domain, 'drokk', domain_full,
federation_list, False, False)
follow_person(base_dir, nickname, domain, 'maxboardroom', domain_full,
federation_list, False, False)
follow_person(base_dir, nickname, domain, 'ultrapancake', domain_full,
federation_list, False, False)
follow_person(base_dir, nickname, domain, 'sausagedog', domain_full,
federation_list, False, False)
follow_person(base_dir, nickname, domain, 'drokk', domain_full,
federation_list, False, False)
followerOfPerson(base_dir, nickname, domain, 'drokk', domain_full,
federation_list, False, False)
followerOfPerson(base_dir, nickname, domain, 'maxboardroom', domain_full,

View File

@ -20,7 +20,7 @@ from utils import domainPermitted
from utils import getDomainFromActor
from utils import getNicknameFromActor
from utils import getStatusNumber
from utils import followPerson
from utils import follow_person
from posts import sendSignedJson
from posts import getPersonBox
from utils import load_json
@ -213,9 +213,10 @@ def followerOfPerson(base_dir: str, nickname: str, domain: str,
group_account: bool) -> bool:
"""Adds a follower of the given person
"""
return followPerson(base_dir, nickname, domain,
followerNickname, followerDomain,
federation_list, debug, group_account, 'followers.txt')
return follow_person(base_dir, nickname, domain,
followerNickname, followerDomain,
federation_list, debug, group_account,
'followers.txt')
def getFollowerDomains(base_dir: str, nickname: str, domain: str) -> []:

View File

@ -74,7 +74,7 @@ from utils import validNickname
from utils import first_paragraph_from_string
from utils import remove_id_ending
from utils import updateRecentPostsCache
from utils import followPerson
from utils import follow_person
from utils import getNicknameFromActor
from utils import getDomainFromActor
from utils import copytree
@ -706,8 +706,8 @@ def createServerAlice(path: str, domain: str, port: int,
assert setSkillLevel(path, nickname, domain, 'hacking', 90)
assert setRole(path, nickname, domain, 'guru')
if hasFollows:
followPerson(path, nickname, domain, 'bob', bobAddress,
federation_list, False, False)
follow_person(path, nickname, domain, 'bob', bobAddress,
federation_list, False, False)
followerOfPerson(path, nickname, domain, 'bob', bobAddress,
federation_list, False, False)
if hasPosts:
@ -849,8 +849,8 @@ def createServerBob(path: str, domain: str, port: int,
deleteAllPosts(path, nickname, domain, 'inbox')
deleteAllPosts(path, nickname, domain, 'outbox')
if hasFollows and aliceAddress:
followPerson(path, nickname, domain,
'alice', aliceAddress, federation_list, False, False)
follow_person(path, nickname, domain,
'alice', aliceAddress, federation_list, False, False)
followerOfPerson(path, nickname, domain,
'alice', aliceAddress, federation_list, False, False)
if hasPosts:
@ -1310,8 +1310,8 @@ def testPostMessageBetweenServers(base_dir: str) -> None:
followerOfPerson(bobDir, 'bob', bobDomain, 'alice',
aliceDomainStr, federation_list, False, False)
bobDomainStr = bobDomain + ':' + str(bobPort)
followPerson(aliceDir, 'alice', aliceDomain, 'bob',
bobDomainStr, federation_list, False, False)
follow_person(aliceDir, 'alice', aliceDomain, 'bob',
bobDomainStr, federation_list, False, False)
sessionBob = createSession(proxy_type)
bobPostLog = []
@ -2459,19 +2459,19 @@ def _testFollowersOfPerson(base_dir: str) -> None:
http_prefix, True, False, password)
clearFollows(base_dir, nickname, domain)
followPerson(base_dir, nickname, domain, 'maxboardroom', domain,
federation_list, False, False)
followPerson(base_dir, 'drokk', domain, 'ultrapancake', domain,
federation_list, False, False)
follow_person(base_dir, nickname, domain, 'maxboardroom', domain,
federation_list, False, False)
follow_person(base_dir, 'drokk', domain, 'ultrapancake', domain,
federation_list, False, False)
# deliberate duplication
followPerson(base_dir, 'drokk', domain, 'ultrapancake', domain,
federation_list, False, False)
followPerson(base_dir, 'sausagedog', domain, 'ultrapancake', domain,
federation_list, False, False)
followPerson(base_dir, nickname, domain, 'ultrapancake', domain,
federation_list, False, False)
followPerson(base_dir, nickname, domain, 'someother', 'randodomain.net',
federation_list, False, False)
follow_person(base_dir, 'drokk', domain, 'ultrapancake', domain,
federation_list, False, False)
follow_person(base_dir, 'sausagedog', domain, 'ultrapancake', domain,
federation_list, False, False)
follow_person(base_dir, nickname, domain, 'ultrapancake', domain,
federation_list, False, False)
follow_person(base_dir, nickname, domain, 'someother', 'randodomain.net',
federation_list, False, False)
followList = get_followers_of_person(base_dir, 'ultrapancake', domain)
assert len(followList) == 3
@ -2508,12 +2508,12 @@ def _testNoOfFollowersOnDomain(base_dir: str) -> None:
createPerson(base_dir, 'sausagedog', otherdomain, port,
http_prefix, True, False, password)
followPerson(base_dir, 'drokk', otherdomain, nickname, domain,
federation_list, False, False)
followPerson(base_dir, 'sausagedog', otherdomain, nickname, domain,
federation_list, False, False)
followPerson(base_dir, 'maxboardroom', otherdomain, nickname, domain,
federation_list, False, False)
follow_person(base_dir, 'drokk', otherdomain, nickname, domain,
federation_list, False, False)
follow_person(base_dir, 'sausagedog', otherdomain, nickname, domain,
federation_list, False, False)
follow_person(base_dir, 'maxboardroom', otherdomain, nickname, domain,
federation_list, False, False)
followerOfPerson(base_dir, nickname, domain,
'cucumber', 'sandwiches.party',
@ -2607,16 +2607,16 @@ def _testFollows(base_dir: str) -> None:
False, password)
clearFollows(base_dir, nickname, domain)
followPerson(base_dir, nickname, domain, 'badger', 'wild.com',
federation_list, False, False)
followPerson(base_dir, nickname, domain, 'squirrel', 'secret.com',
federation_list, False, False)
followPerson(base_dir, nickname, domain, 'rodent', 'drainpipe.com',
federation_list, False, False)
followPerson(base_dir, nickname, domain, 'batman', 'mesh.com',
federation_list, False, False)
followPerson(base_dir, nickname, domain, 'giraffe', 'trees.com',
federation_list, False, False)
follow_person(base_dir, nickname, domain, 'badger', 'wild.com',
federation_list, False, False)
follow_person(base_dir, nickname, domain, 'squirrel', 'secret.com',
federation_list, False, False)
follow_person(base_dir, nickname, domain, 'rodent', 'drainpipe.com',
federation_list, False, False)
follow_person(base_dir, nickname, domain, 'batman', 'mesh.com',
federation_list, False, False)
follow_person(base_dir, nickname, domain, 'giraffe', 'trees.com',
federation_list, False, False)
accountDir = acct_dir(base_dir, nickname, domain)
f = open(accountDir + '/following.txt', 'r')

View File

@ -1128,11 +1128,11 @@ def _setDefaultPetName(base_dir: str, nickname: str, domain: str,
petnamesFile.write(petnameLookupEntry)
def followPerson(base_dir: str, nickname: str, domain: str,
followNickname: str, followDomain: str,
federation_list: [], debug: bool,
group_account: bool,
follow_file: str = 'following.txt') -> bool:
def follow_person(base_dir: str, nickname: str, domain: str,
followNickname: str, followDomain: str,
federation_list: [], debug: bool,
group_account: bool,
follow_file: str = 'following.txt') -> bool:
"""Adds a person to the follow list
"""
followDomainStrLower = followDomain.lower().replace('\n', '')
@ -1191,11 +1191,11 @@ def followPerson(base_dir: str, nickname: str, domain: str,
return True
# prepend to follow file
try:
with open(filename, 'r+') as fp:
content = fp.read()
with open(filename, 'r+') as foll_file:
content = foll_file.read()
if handleToFollow + '\n' not in content:
fp.seek(0, 0)
fp.write(handleToFollow + '\n' + content)
foll_file.seek(0, 0)
foll_file.write(handleToFollow + '\n' + content)
print('DEBUG: follow added')
except OSError as ex:
print('WARN: Failed to write entry to follow file ' +