mirror of https://gitlab.com/bashrc2/epicyon
Snake case
parent
322338a455
commit
2a57353f56
|
@ -15,7 +15,7 @@ from utils import urlPermitted
|
||||||
from utils import getDomainFromActor
|
from utils import getDomainFromActor
|
||||||
from utils import getNicknameFromActor
|
from utils import getNicknameFromActor
|
||||||
from utils import domainPermitted
|
from utils import domainPermitted
|
||||||
from utils import followPerson
|
from utils import follow_person
|
||||||
from utils import acct_dir
|
from utils import acct_dir
|
||||||
from utils import has_group_type
|
from utils import has_group_type
|
||||||
from utils import local_actor_url
|
from utils import local_actor_url
|
||||||
|
@ -168,7 +168,7 @@ def _accept_follow(base_dir: str, domain: str, message_json: {},
|
||||||
print('Accepted follow is a group: ' + str(group_account) +
|
print('Accepted follow is a group: ' + str(group_account) +
|
||||||
' ' + followed_actor + ' ' + base_dir)
|
' ' + followed_actor + ' ' + base_dir)
|
||||||
|
|
||||||
if followPerson(base_dir,
|
if follow_person(base_dir,
|
||||||
nickname, accepted_domain_full,
|
nickname, accepted_domain_full,
|
||||||
followed_nickname, followed_domain_full,
|
followed_nickname, followed_domain_full,
|
||||||
federation_list, debug, group_account):
|
federation_list, debug, group_account):
|
||||||
|
|
10
epicyon.py
10
epicyon.py
|
@ -73,7 +73,7 @@ from utils import setConfigParam
|
||||||
from utils import get_config_param
|
from utils import get_config_param
|
||||||
from utils import getDomainFromActor
|
from utils import getDomainFromActor
|
||||||
from utils import getNicknameFromActor
|
from utils import getNicknameFromActor
|
||||||
from utils import followPerson
|
from utils import follow_person
|
||||||
from utils import validNickname
|
from utils import validNickname
|
||||||
from utils import getProtocolPrefixes
|
from utils import getProtocolPrefixes
|
||||||
from utils import acct_dir
|
from utils import acct_dir
|
||||||
|
@ -2982,13 +2982,13 @@ if args.testdata:
|
||||||
low_bandwidth, args.content_license_url)
|
low_bandwidth, args.content_license_url)
|
||||||
domain_full = domain + ':' + str(port)
|
domain_full = domain + ':' + str(port)
|
||||||
clearFollows(base_dir, nickname, domain)
|
clearFollows(base_dir, nickname, domain)
|
||||||
followPerson(base_dir, nickname, domain, 'maxboardroom', domain_full,
|
follow_person(base_dir, nickname, domain, 'maxboardroom', domain_full,
|
||||||
federation_list, False, False)
|
federation_list, False, False)
|
||||||
followPerson(base_dir, nickname, domain, 'ultrapancake', domain_full,
|
follow_person(base_dir, nickname, domain, 'ultrapancake', domain_full,
|
||||||
federation_list, False, False)
|
federation_list, False, False)
|
||||||
followPerson(base_dir, nickname, domain, 'sausagedog', domain_full,
|
follow_person(base_dir, nickname, domain, 'sausagedog', domain_full,
|
||||||
federation_list, False, False)
|
federation_list, False, False)
|
||||||
followPerson(base_dir, nickname, domain, 'drokk', domain_full,
|
follow_person(base_dir, nickname, domain, 'drokk', domain_full,
|
||||||
federation_list, False, False)
|
federation_list, False, False)
|
||||||
followerOfPerson(base_dir, nickname, domain, 'drokk', domain_full,
|
followerOfPerson(base_dir, nickname, domain, 'drokk', domain_full,
|
||||||
federation_list, False, False)
|
federation_list, False, False)
|
||||||
|
|
|
@ -20,7 +20,7 @@ from utils import domainPermitted
|
||||||
from utils import getDomainFromActor
|
from utils import getDomainFromActor
|
||||||
from utils import getNicknameFromActor
|
from utils import getNicknameFromActor
|
||||||
from utils import getStatusNumber
|
from utils import getStatusNumber
|
||||||
from utils import followPerson
|
from utils import follow_person
|
||||||
from posts import sendSignedJson
|
from posts import sendSignedJson
|
||||||
from posts import getPersonBox
|
from posts import getPersonBox
|
||||||
from utils import load_json
|
from utils import load_json
|
||||||
|
@ -213,9 +213,10 @@ def followerOfPerson(base_dir: str, nickname: str, domain: str,
|
||||||
group_account: bool) -> bool:
|
group_account: bool) -> bool:
|
||||||
"""Adds a follower of the given person
|
"""Adds a follower of the given person
|
||||||
"""
|
"""
|
||||||
return followPerson(base_dir, nickname, domain,
|
return follow_person(base_dir, nickname, domain,
|
||||||
followerNickname, followerDomain,
|
followerNickname, followerDomain,
|
||||||
federation_list, debug, group_account, 'followers.txt')
|
federation_list, debug, group_account,
|
||||||
|
'followers.txt')
|
||||||
|
|
||||||
|
|
||||||
def getFollowerDomains(base_dir: str, nickname: str, domain: str) -> []:
|
def getFollowerDomains(base_dir: str, nickname: str, domain: str) -> []:
|
||||||
|
|
36
tests.py
36
tests.py
|
@ -74,7 +74,7 @@ from utils import validNickname
|
||||||
from utils import first_paragraph_from_string
|
from utils import first_paragraph_from_string
|
||||||
from utils import remove_id_ending
|
from utils import remove_id_ending
|
||||||
from utils import updateRecentPostsCache
|
from utils import updateRecentPostsCache
|
||||||
from utils import followPerson
|
from utils import follow_person
|
||||||
from utils import getNicknameFromActor
|
from utils import getNicknameFromActor
|
||||||
from utils import getDomainFromActor
|
from utils import getDomainFromActor
|
||||||
from utils import copytree
|
from utils import copytree
|
||||||
|
@ -706,7 +706,7 @@ def createServerAlice(path: str, domain: str, port: int,
|
||||||
assert setSkillLevel(path, nickname, domain, 'hacking', 90)
|
assert setSkillLevel(path, nickname, domain, 'hacking', 90)
|
||||||
assert setRole(path, nickname, domain, 'guru')
|
assert setRole(path, nickname, domain, 'guru')
|
||||||
if hasFollows:
|
if hasFollows:
|
||||||
followPerson(path, nickname, domain, 'bob', bobAddress,
|
follow_person(path, nickname, domain, 'bob', bobAddress,
|
||||||
federation_list, False, False)
|
federation_list, False, False)
|
||||||
followerOfPerson(path, nickname, domain, 'bob', bobAddress,
|
followerOfPerson(path, nickname, domain, 'bob', bobAddress,
|
||||||
federation_list, False, False)
|
federation_list, False, False)
|
||||||
|
@ -849,7 +849,7 @@ def createServerBob(path: str, domain: str, port: int,
|
||||||
deleteAllPosts(path, nickname, domain, 'inbox')
|
deleteAllPosts(path, nickname, domain, 'inbox')
|
||||||
deleteAllPosts(path, nickname, domain, 'outbox')
|
deleteAllPosts(path, nickname, domain, 'outbox')
|
||||||
if hasFollows and aliceAddress:
|
if hasFollows and aliceAddress:
|
||||||
followPerson(path, nickname, domain,
|
follow_person(path, nickname, domain,
|
||||||
'alice', aliceAddress, federation_list, False, False)
|
'alice', aliceAddress, federation_list, False, False)
|
||||||
followerOfPerson(path, nickname, domain,
|
followerOfPerson(path, nickname, domain,
|
||||||
'alice', aliceAddress, federation_list, False, False)
|
'alice', aliceAddress, federation_list, False, False)
|
||||||
|
@ -1310,7 +1310,7 @@ def testPostMessageBetweenServers(base_dir: str) -> None:
|
||||||
followerOfPerson(bobDir, 'bob', bobDomain, 'alice',
|
followerOfPerson(bobDir, 'bob', bobDomain, 'alice',
|
||||||
aliceDomainStr, federation_list, False, False)
|
aliceDomainStr, federation_list, False, False)
|
||||||
bobDomainStr = bobDomain + ':' + str(bobPort)
|
bobDomainStr = bobDomain + ':' + str(bobPort)
|
||||||
followPerson(aliceDir, 'alice', aliceDomain, 'bob',
|
follow_person(aliceDir, 'alice', aliceDomain, 'bob',
|
||||||
bobDomainStr, federation_list, False, False)
|
bobDomainStr, federation_list, False, False)
|
||||||
|
|
||||||
sessionBob = createSession(proxy_type)
|
sessionBob = createSession(proxy_type)
|
||||||
|
@ -2459,18 +2459,18 @@ def _testFollowersOfPerson(base_dir: str) -> None:
|
||||||
http_prefix, True, False, password)
|
http_prefix, True, False, password)
|
||||||
|
|
||||||
clearFollows(base_dir, nickname, domain)
|
clearFollows(base_dir, nickname, domain)
|
||||||
followPerson(base_dir, nickname, domain, 'maxboardroom', domain,
|
follow_person(base_dir, nickname, domain, 'maxboardroom', domain,
|
||||||
federation_list, False, False)
|
federation_list, False, False)
|
||||||
followPerson(base_dir, 'drokk', domain, 'ultrapancake', domain,
|
follow_person(base_dir, 'drokk', domain, 'ultrapancake', domain,
|
||||||
federation_list, False, False)
|
federation_list, False, False)
|
||||||
# deliberate duplication
|
# deliberate duplication
|
||||||
followPerson(base_dir, 'drokk', domain, 'ultrapancake', domain,
|
follow_person(base_dir, 'drokk', domain, 'ultrapancake', domain,
|
||||||
federation_list, False, False)
|
federation_list, False, False)
|
||||||
followPerson(base_dir, 'sausagedog', domain, 'ultrapancake', domain,
|
follow_person(base_dir, 'sausagedog', domain, 'ultrapancake', domain,
|
||||||
federation_list, False, False)
|
federation_list, False, False)
|
||||||
followPerson(base_dir, nickname, domain, 'ultrapancake', domain,
|
follow_person(base_dir, nickname, domain, 'ultrapancake', domain,
|
||||||
federation_list, False, False)
|
federation_list, False, False)
|
||||||
followPerson(base_dir, nickname, domain, 'someother', 'randodomain.net',
|
follow_person(base_dir, nickname, domain, 'someother', 'randodomain.net',
|
||||||
federation_list, False, False)
|
federation_list, False, False)
|
||||||
|
|
||||||
followList = get_followers_of_person(base_dir, 'ultrapancake', domain)
|
followList = get_followers_of_person(base_dir, 'ultrapancake', domain)
|
||||||
|
@ -2508,11 +2508,11 @@ def _testNoOfFollowersOnDomain(base_dir: str) -> None:
|
||||||
createPerson(base_dir, 'sausagedog', otherdomain, port,
|
createPerson(base_dir, 'sausagedog', otherdomain, port,
|
||||||
http_prefix, True, False, password)
|
http_prefix, True, False, password)
|
||||||
|
|
||||||
followPerson(base_dir, 'drokk', otherdomain, nickname, domain,
|
follow_person(base_dir, 'drokk', otherdomain, nickname, domain,
|
||||||
federation_list, False, False)
|
federation_list, False, False)
|
||||||
followPerson(base_dir, 'sausagedog', otherdomain, nickname, domain,
|
follow_person(base_dir, 'sausagedog', otherdomain, nickname, domain,
|
||||||
federation_list, False, False)
|
federation_list, False, False)
|
||||||
followPerson(base_dir, 'maxboardroom', otherdomain, nickname, domain,
|
follow_person(base_dir, 'maxboardroom', otherdomain, nickname, domain,
|
||||||
federation_list, False, False)
|
federation_list, False, False)
|
||||||
|
|
||||||
followerOfPerson(base_dir, nickname, domain,
|
followerOfPerson(base_dir, nickname, domain,
|
||||||
|
@ -2607,15 +2607,15 @@ def _testFollows(base_dir: str) -> None:
|
||||||
False, password)
|
False, password)
|
||||||
|
|
||||||
clearFollows(base_dir, nickname, domain)
|
clearFollows(base_dir, nickname, domain)
|
||||||
followPerson(base_dir, nickname, domain, 'badger', 'wild.com',
|
follow_person(base_dir, nickname, domain, 'badger', 'wild.com',
|
||||||
federation_list, False, False)
|
federation_list, False, False)
|
||||||
followPerson(base_dir, nickname, domain, 'squirrel', 'secret.com',
|
follow_person(base_dir, nickname, domain, 'squirrel', 'secret.com',
|
||||||
federation_list, False, False)
|
federation_list, False, False)
|
||||||
followPerson(base_dir, nickname, domain, 'rodent', 'drainpipe.com',
|
follow_person(base_dir, nickname, domain, 'rodent', 'drainpipe.com',
|
||||||
federation_list, False, False)
|
federation_list, False, False)
|
||||||
followPerson(base_dir, nickname, domain, 'batman', 'mesh.com',
|
follow_person(base_dir, nickname, domain, 'batman', 'mesh.com',
|
||||||
federation_list, False, False)
|
federation_list, False, False)
|
||||||
followPerson(base_dir, nickname, domain, 'giraffe', 'trees.com',
|
follow_person(base_dir, nickname, domain, 'giraffe', 'trees.com',
|
||||||
federation_list, False, False)
|
federation_list, False, False)
|
||||||
|
|
||||||
accountDir = acct_dir(base_dir, nickname, domain)
|
accountDir = acct_dir(base_dir, nickname, domain)
|
||||||
|
|
10
utils.py
10
utils.py
|
@ -1128,7 +1128,7 @@ def _setDefaultPetName(base_dir: str, nickname: str, domain: str,
|
||||||
petnamesFile.write(petnameLookupEntry)
|
petnamesFile.write(petnameLookupEntry)
|
||||||
|
|
||||||
|
|
||||||
def followPerson(base_dir: str, nickname: str, domain: str,
|
def follow_person(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,
|
||||||
|
@ -1191,11 +1191,11 @@ def followPerson(base_dir: str, nickname: str, domain: str,
|
||||||
return True
|
return True
|
||||||
# prepend to follow file
|
# prepend to follow file
|
||||||
try:
|
try:
|
||||||
with open(filename, 'r+') as fp:
|
with open(filename, 'r+') as foll_file:
|
||||||
content = fp.read()
|
content = foll_file.read()
|
||||||
if handleToFollow + '\n' not in content:
|
if handleToFollow + '\n' not in content:
|
||||||
fp.seek(0, 0)
|
foll_file.seek(0, 0)
|
||||||
fp.write(handleToFollow + '\n' + content)
|
foll_file.write(handleToFollow + '\n' + content)
|
||||||
print('DEBUG: follow added')
|
print('DEBUG: follow added')
|
||||||
except OSError as ex:
|
except OSError as ex:
|
||||||
print('WARN: Failed to write entry to follow file ' +
|
print('WARN: Failed to write entry to follow file ' +
|
||||||
|
|
Loading…
Reference in New Issue