mirror of https://gitlab.com/bashrc2/epicyon
Tidying
parent
1fc36c5305
commit
252cbdda4c
41
follow.py
41
follow.py
|
@ -92,8 +92,7 @@ def _pre_approved_follower(base_dir: str,
|
||||||
approve_handle: str) -> bool:
|
approve_handle: str) -> bool:
|
||||||
"""Is the given handle an already manually approved follower?
|
"""Is the given handle an already manually approved follower?
|
||||||
"""
|
"""
|
||||||
handle = nickname + '@' + domain
|
account_dir = acct_dir(base_dir, nickname, domain)
|
||||||
account_dir = base_dir + '/accounts/' + handle
|
|
||||||
approved_filename = account_dir + '/approved.txt'
|
approved_filename = account_dir + '/approved.txt'
|
||||||
if os.path.isfile(approved_filename):
|
if os.path.isfile(approved_filename):
|
||||||
if text_in_file(approve_handle, approved_filename):
|
if text_in_file(approve_handle, approved_filename):
|
||||||
|
@ -107,13 +106,12 @@ def _remove_from_follow_base(base_dir: str,
|
||||||
debug: bool) -> None:
|
debug: bool) -> None:
|
||||||
"""Removes a handle/actor from follow requests or rejects file
|
"""Removes a handle/actor from follow requests or rejects file
|
||||||
"""
|
"""
|
||||||
handle = nickname + '@' + domain
|
accounts_dir = acct_dir(base_dir, nickname, domain)
|
||||||
accounts_dir = base_dir + '/accounts/' + handle
|
|
||||||
approve_follows_filename = accounts_dir + '/' + follow_file + '.txt'
|
approve_follows_filename = accounts_dir + '/' + follow_file + '.txt'
|
||||||
if not os.path.isfile(approve_follows_filename):
|
if not os.path.isfile(approve_follows_filename):
|
||||||
if debug:
|
if debug:
|
||||||
print('There is no ' + follow_file +
|
print('There is no ' + follow_file +
|
||||||
' to remove ' + handle + ' from')
|
' to remove ' + nickname + '@' + domain + ' from')
|
||||||
return
|
return
|
||||||
accept_deny_actor = None
|
accept_deny_actor = None
|
||||||
if not text_in_file(accept_or_deny_handle, approve_follows_filename):
|
if not text_in_file(accept_or_deny_handle, approve_follows_filename):
|
||||||
|
@ -177,10 +175,10 @@ def is_following_actor(base_dir: str,
|
||||||
The actor can also be a handle: nickname@domain
|
The actor can also be a handle: nickname@domain
|
||||||
"""
|
"""
|
||||||
domain = remove_domain_port(domain)
|
domain = remove_domain_port(domain)
|
||||||
handle = nickname + '@' + domain
|
accounts_dir = acct_dir(base_dir, nickname, domain)
|
||||||
if not os.path.isdir(base_dir + '/accounts/' + handle):
|
if not os.path.isdir(accounts_dir):
|
||||||
return False
|
return False
|
||||||
following_file = base_dir + '/accounts/' + handle + '/following.txt'
|
following_file = accounts_dir + '/following.txt'
|
||||||
if not os.path.isfile(following_file):
|
if not os.path.isfile(following_file):
|
||||||
return False
|
return False
|
||||||
if actor.startswith('@'):
|
if actor.startswith('@'):
|
||||||
|
@ -309,7 +307,8 @@ def unfollow_account(base_dir: str, nickname: str, domain: str,
|
||||||
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)
|
||||||
|
|
||||||
filename = base_dir + '/accounts/' + handle + '/' + follow_file
|
accounts_dir = acct_dir(base_dir, nickname, domain)
|
||||||
|
filename = accounts_dir + '/' + follow_file
|
||||||
if not os.path.isfile(filename):
|
if not os.path.isfile(filename):
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: follow file ' + filename + ' was not found')
|
print('DEBUG: follow file ' + filename + ' was not found')
|
||||||
|
@ -339,7 +338,7 @@ def unfollow_account(base_dir: str, nickname: str, domain: str,
|
||||||
|
|
||||||
# write to an unfollowed file so that if a follow accept
|
# write to an unfollowed file so that if a follow accept
|
||||||
# later arrives then it can be ignored
|
# later arrives then it can be ignored
|
||||||
unfollowed_filename = base_dir + '/accounts/' + handle + '/unfollowed.txt'
|
unfollowed_filename = accounts_dir + '/unfollowed.txt'
|
||||||
if os.path.isfile(unfollowed_filename):
|
if os.path.isfile(unfollowed_filename):
|
||||||
if not text_in_file(handle_to_unfollow_lower,
|
if not text_in_file(handle_to_unfollow_lower,
|
||||||
unfollowed_filename, False):
|
unfollowed_filename, False):
|
||||||
|
@ -374,12 +373,12 @@ def clear_follows(base_dir: str, nickname: str, domain: str,
|
||||||
follow_file: str = 'following.txt') -> None:
|
follow_file: str = 'following.txt') -> None:
|
||||||
"""Removes all follows
|
"""Removes all follows
|
||||||
"""
|
"""
|
||||||
handle = nickname + '@' + domain
|
|
||||||
if not os.path.isdir(base_dir + '/accounts'):
|
if not os.path.isdir(base_dir + '/accounts'):
|
||||||
os.mkdir(base_dir + '/accounts')
|
os.mkdir(base_dir + '/accounts')
|
||||||
if not os.path.isdir(base_dir + '/accounts/' + handle):
|
accounts_dir = acct_dir(base_dir, nickname, domain)
|
||||||
os.mkdir(base_dir + '/accounts/' + handle)
|
if not os.path.isdir(accounts_dir):
|
||||||
filename = base_dir + '/accounts/' + handle + '/' + follow_file
|
os.mkdir(accounts_dir)
|
||||||
|
filename = accounts_dir + '/' + follow_file
|
||||||
if os.path.isfile(filename):
|
if os.path.isfile(filename):
|
||||||
try:
|
try:
|
||||||
os.remove(filename)
|
os.remove(filename)
|
||||||
|
@ -401,8 +400,8 @@ def _get_no_of_follows(base_dir: str, nickname: str, domain: str,
|
||||||
# account holders
|
# account holders
|
||||||
# if not authenticated:
|
# if not authenticated:
|
||||||
# return 9999
|
# return 9999
|
||||||
handle = nickname + '@' + domain
|
accounts_dir = acct_dir(base_dir, nickname, domain)
|
||||||
filename = base_dir + '/accounts/' + handle + '/' + follow_file
|
filename = accounts_dir + '/' + follow_file
|
||||||
if not os.path.isfile(filename):
|
if not os.path.isfile(filename):
|
||||||
return 0
|
return 0
|
||||||
ctr = 0
|
ctr = 0
|
||||||
|
@ -518,8 +517,8 @@ def get_following_feed(base_dir: str, domain: str, port: int, path: str,
|
||||||
|
|
||||||
handle_domain = domain
|
handle_domain = domain
|
||||||
handle_domain = remove_domain_port(handle_domain)
|
handle_domain = remove_domain_port(handle_domain)
|
||||||
handle = nickname + '@' + handle_domain
|
accounts_dir = acct_dir(base_dir, nickname, handle_domain)
|
||||||
filename = base_dir + '/accounts/' + handle + '/' + follow_file + '.txt'
|
filename = accounts_dir + '/' + follow_file + '.txt'
|
||||||
if not os.path.isfile(filename):
|
if not os.path.isfile(filename):
|
||||||
return following
|
return following
|
||||||
curr_page = 1
|
curr_page = 1
|
||||||
|
@ -608,8 +607,7 @@ def no_of_follow_requests(base_dir: str,
|
||||||
follow_type: str) -> int:
|
follow_type: str) -> int:
|
||||||
"""Returns the current number of follow requests
|
"""Returns the current number of follow requests
|
||||||
"""
|
"""
|
||||||
accounts_dir = base_dir + '/accounts/' + \
|
accounts_dir = acct_dir(base_dir, nickname_to_follow, domain_to_follow)
|
||||||
nickname_to_follow + '@' + domain_to_follow
|
|
||||||
approve_follows_filename = accounts_dir + '/followrequests.txt'
|
approve_follows_filename = accounts_dir + '/followrequests.txt'
|
||||||
if not os.path.isfile(approve_follows_filename):
|
if not os.path.isfile(approve_follows_filename):
|
||||||
return 0
|
return 0
|
||||||
|
@ -644,8 +642,7 @@ def store_follow_request(base_dir: str,
|
||||||
group_account: bool) -> bool:
|
group_account: bool) -> bool:
|
||||||
"""Stores the follow request for later use
|
"""Stores the follow request for later use
|
||||||
"""
|
"""
|
||||||
accounts_dir = base_dir + '/accounts/' + \
|
accounts_dir = acct_dir(base_dir, nickname_to_follow, domain_to_follow)
|
||||||
nickname_to_follow + '@' + domain_to_follow
|
|
||||||
if not os.path.isdir(accounts_dir):
|
if not os.path.isdir(accounts_dir):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
|
@ -622,7 +622,10 @@ def save_person_qrcode(base_dir: str,
|
||||||
return
|
return
|
||||||
handle = get_full_domain('@' + nickname + '@' + qrcode_domain, port)
|
handle = get_full_domain('@' + nickname + '@' + qrcode_domain, port)
|
||||||
url = pyqrcode.create(handle)
|
url = pyqrcode.create(handle)
|
||||||
url.png(qrcode_filename, scale)
|
try:
|
||||||
|
url.png(qrcode_filename, scale)
|
||||||
|
except ModuleNotFoundError:
|
||||||
|
print('EX: pyqrcode png module not found')
|
||||||
|
|
||||||
|
|
||||||
def create_person(base_dir: str, nickname: str, domain: str, port: int,
|
def create_person(base_dir: str, nickname: str, domain: str, port: int,
|
||||||
|
|
Loading…
Reference in New Issue