mirror of https://gitlab.com/bashrc2/epicyon
parent
bc614fcd3c
commit
4e29c26ad4
4
blog.py
4
blog.py
|
@ -34,7 +34,6 @@ from utils import first_paragraph_from_string
|
|||
from utils import get_actor_property_url
|
||||
from utils import acct_dir
|
||||
from posts import create_blogs_timeline
|
||||
from utils import text_in_file
|
||||
from newswire import rss2header
|
||||
from newswire import rss2footer
|
||||
from cache import get_person_from_cache
|
||||
|
@ -930,7 +929,8 @@ def path_contains_blog_link(base_dir: str,
|
|||
acct_dir(base_dir, nickname, domain) + '/tlblogs.index'
|
||||
if not os.path.isfile(blog_index_filename):
|
||||
return None, None
|
||||
if not text_in_file('#' + user_ending2[1] + '.', blog_index_filename):
|
||||
if '#' + user_ending2[1] + '.' not in open(blog_index_filename,
|
||||
encoding='utf-8').read():
|
||||
return None, None
|
||||
message_id = local_actor_url(http_prefix, nickname, domain_full) + \
|
||||
'/statuses/' + user_ending2[1]
|
||||
|
|
|
@ -28,7 +28,6 @@ from utils import acct_dir
|
|||
from utils import local_actor_url
|
||||
from utils import has_actor
|
||||
from utils import has_object_string_type
|
||||
from utils import text_in_file
|
||||
from posts import get_person_box
|
||||
from session import post_json
|
||||
|
||||
|
@ -72,7 +71,8 @@ def undo_bookmarks_collection_entry(recent_posts_cache: {},
|
|||
else:
|
||||
bookmark_index = post_filename.strip()
|
||||
bookmark_index = bookmark_index.replace('\n', '').replace('\r', '')
|
||||
if not text_in_file(bookmark_index, bookmarks_index_filename):
|
||||
if bookmark_index not in open(bookmarks_index_filename,
|
||||
encoding='utf-8').read():
|
||||
return
|
||||
index_str = ''
|
||||
try:
|
||||
|
@ -238,7 +238,8 @@ def update_bookmarks_collection(recent_posts_cache: {},
|
|||
acct_dir(base_dir, nickname, domain) + '/bookmarks.index'
|
||||
bookmark_index = post_filename.split('/')[-1]
|
||||
if os.path.isfile(bookmarks_index_filename):
|
||||
if not text_in_file(bookmark_index, bookmarks_index_filename):
|
||||
if bookmark_index not in open(bookmarks_index_filename,
|
||||
encoding='utf-8').read():
|
||||
try:
|
||||
with open(bookmarks_index_filename, 'r+',
|
||||
encoding='utf-8') as bmi_file:
|
||||
|
|
|
@ -11,7 +11,6 @@ import os
|
|||
from utils import has_object_dict
|
||||
from utils import acct_dir
|
||||
from utils import remove_id_ending
|
||||
from utils import text_in_file
|
||||
|
||||
|
||||
def _get_conversation_filename(base_dir: str, nickname: str, domain: str,
|
||||
|
@ -51,7 +50,8 @@ def update_conversation(base_dir: str, nickname: str, domain: str,
|
|||
except OSError:
|
||||
print('EX: update_conversation ' +
|
||||
'unable to write to ' + conversation_filename)
|
||||
elif not text_in_file(post_id + '\n', conversation_filename):
|
||||
elif post_id + '\n' not in open(conversation_filename,
|
||||
encoding='utf-8').read():
|
||||
try:
|
||||
with open(conversation_filename, 'a+',
|
||||
encoding='utf-8') as conv_file:
|
||||
|
|
|
@ -9,7 +9,6 @@ __module_group__ = "Moderation"
|
|||
|
||||
import os
|
||||
from utils import acct_dir
|
||||
from utils import text_in_file
|
||||
|
||||
|
||||
def add_filter(base_dir: str, nickname: str, domain: str, words: str) -> bool:
|
||||
|
@ -17,7 +16,7 @@ def add_filter(base_dir: str, nickname: str, domain: str, words: str) -> bool:
|
|||
"""
|
||||
filters_filename = acct_dir(base_dir, nickname, domain) + '/filters.txt'
|
||||
if os.path.isfile(filters_filename):
|
||||
if text_in_file(words, filters_filename):
|
||||
if words in open(filters_filename, encoding='utf-8').read():
|
||||
return False
|
||||
try:
|
||||
with open(filters_filename, 'a+',
|
||||
|
@ -38,7 +37,7 @@ def add_global_filter(base_dir: str, words: str) -> bool:
|
|||
return False
|
||||
filters_filename = base_dir + '/accounts/filters.txt'
|
||||
if os.path.isfile(filters_filename):
|
||||
if text_in_file(words, filters_filename):
|
||||
if words in open(filters_filename, encoding='utf-8').read():
|
||||
return False
|
||||
try:
|
||||
with open(filters_filename, 'a+', encoding='utf-8') as filters_file:
|
||||
|
@ -55,7 +54,7 @@ def remove_filter(base_dir: str, nickname: str, domain: str,
|
|||
filters_filename = acct_dir(base_dir, nickname, domain) + '/filters.txt'
|
||||
if not os.path.isfile(filters_filename):
|
||||
return False
|
||||
if not text_in_file(words, filters_filename):
|
||||
if words not in open(filters_filename, encoding='utf-8').read():
|
||||
return False
|
||||
new_filters_filename = filters_filename + '.new'
|
||||
try:
|
||||
|
@ -80,7 +79,7 @@ def remove_global_filter(base_dir: str, words: str) -> bool:
|
|||
filters_filename = base_dir + '/accounts/filters.txt'
|
||||
if not os.path.isfile(filters_filename):
|
||||
return False
|
||||
if not text_in_file(words, filters_filename):
|
||||
if words not in open(filters_filename, encoding='utf-8').read():
|
||||
return False
|
||||
new_filters_filename = filters_filename + '.new'
|
||||
try:
|
||||
|
|
31
follow.py
31
follow.py
|
@ -30,7 +30,6 @@ from utils import get_user_paths
|
|||
from utils import acct_dir
|
||||
from utils import has_group_type
|
||||
from utils import local_actor_url
|
||||
from utils import text_in_file
|
||||
from acceptreject import create_accept
|
||||
from acceptreject import create_reject
|
||||
from webfinger import webfinger_handle
|
||||
|
@ -95,7 +94,8 @@ def _pre_approved_follower(base_dir: str,
|
|||
account_dir = base_dir + '/accounts/' + handle
|
||||
approved_filename = account_dir + '/approved.txt'
|
||||
if os.path.isfile(approved_filename):
|
||||
if text_in_file(approve_handle, approved_filename):
|
||||
if approve_handle in open(approved_filename,
|
||||
encoding='utf-8').read():
|
||||
return True
|
||||
return False
|
||||
|
||||
|
@ -115,7 +115,8 @@ def _remove_from_follow_base(base_dir: str,
|
|||
' to remove ' + handle + ' from')
|
||||
return
|
||||
accept_deny_actor = None
|
||||
if not text_in_file(accept_or_deny_handle, approve_follows_filename):
|
||||
if accept_or_deny_handle not in open(approve_follows_filename,
|
||||
encoding='utf-8').read():
|
||||
# is this stored in the file as an actor rather than a handle?
|
||||
accept_deny_nickname = accept_or_deny_handle.split('@')[0]
|
||||
accept_deny_domain = accept_or_deny_handle.split('@')[1]
|
||||
|
@ -126,7 +127,8 @@ def _remove_from_follow_base(base_dir: str,
|
|||
for users_name in users_paths:
|
||||
accept_deny_actor = \
|
||||
'://' + accept_deny_domain + users_name + accept_deny_nickname
|
||||
if text_in_file(accept_deny_actor, approve_follows_filename):
|
||||
if accept_deny_actor in open(approve_follows_filename,
|
||||
encoding='utf-8').read():
|
||||
actor_found = True
|
||||
break
|
||||
if not actor_found:
|
||||
|
@ -184,8 +186,7 @@ def is_following_actor(base_dir: str,
|
|||
return False
|
||||
if actor.startswith('@'):
|
||||
actor = actor[1:]
|
||||
actor_lower = actor.lower()
|
||||
if text_in_file(actor_lower, following_file).lower():
|
||||
if actor.lower() in open(following_file, encoding='utf-8').read().lower():
|
||||
return True
|
||||
following_nickname = get_nickname_from_actor(actor)
|
||||
if not following_nickname:
|
||||
|
@ -195,8 +196,8 @@ def is_following_actor(base_dir: str,
|
|||
following_handle = \
|
||||
get_full_domain(following_nickname + '@' + following_domain,
|
||||
following_port)
|
||||
following_handle_lower = following_handle.lower()
|
||||
if text_in_file(following_handle_lower, following_file).lower():
|
||||
if following_handle.lower() in open(following_file,
|
||||
encoding='utf-8').read().lower():
|
||||
return True
|
||||
return False
|
||||
|
||||
|
@ -316,7 +317,8 @@ def unfollow_account(base_dir: str, nickname: str, domain: str,
|
|||
print('DEBUG: follow file ' + filename + ' was not found')
|
||||
return False
|
||||
handle_to_unfollow_lower = handle_to_unfollow.lower()
|
||||
if not text_in_file(handle_to_unfollow_lower, filename):
|
||||
if handle_to_unfollow_lower not in open(filename,
|
||||
encoding='utf-8').read().lower():
|
||||
if debug:
|
||||
print('DEBUG: handle to unfollow ' + handle_to_unfollow +
|
||||
' is not in ' + filename)
|
||||
|
@ -686,7 +688,8 @@ def store_follow_request(base_dir: str,
|
|||
# should this follow be denied?
|
||||
deny_follows_filename = accounts_dir + '/followrejects.txt'
|
||||
if os.path.isfile(deny_follows_filename):
|
||||
if text_in_file(approve_handle, deny_follows_filename):
|
||||
if approve_handle in open(deny_follows_filename,
|
||||
encoding='utf-8').read():
|
||||
remove_from_follow_requests(base_dir, nickname_to_follow,
|
||||
domain_to_follow, approve_handle,
|
||||
debug)
|
||||
|
@ -705,7 +708,8 @@ def store_follow_request(base_dir: str,
|
|||
approve_handle = '!' + approve_handle
|
||||
|
||||
if os.path.isfile(approve_follows_filename):
|
||||
if not text_in_file(approve_handle, approve_follows_filename):
|
||||
if approve_handle not in open(approve_follows_filename,
|
||||
encoding='utf-8').read():
|
||||
try:
|
||||
with open(approve_follows_filename, 'a+',
|
||||
encoding='utf-8') as fp_approve:
|
||||
|
@ -920,7 +924,8 @@ def send_follow_request(session, base_dir: str,
|
|||
unfollowed_filename = \
|
||||
acct_dir(base_dir, nickname, domain) + '/unfollowed.txt'
|
||||
if os.path.isfile(unfollowed_filename):
|
||||
if text_in_file(follow_handle, unfollowed_filename):
|
||||
if follow_handle in open(unfollowed_filename,
|
||||
encoding='utf-8').read():
|
||||
unfollowed_file = None
|
||||
try:
|
||||
with open(unfollowed_filename, 'r',
|
||||
|
@ -1399,7 +1404,7 @@ def get_followers_of_actor(base_dir: str, actor: str, debug: bool) -> {}:
|
|||
if debug:
|
||||
print('DEBUG: checking if ' + actor_handle +
|
||||
' in ' + following_filename)
|
||||
if text_in_file(actor_handle, following_filename):
|
||||
if actor_handle in open(following_filename).read():
|
||||
if debug:
|
||||
print('DEBUG: ' + account +
|
||||
' follows ' + actor_handle)
|
||||
|
|
|
@ -10,20 +10,6 @@ __module_group__ = "Calendar"
|
|||
import os
|
||||
|
||||
|
||||
def _text_in_file2(text: str, filename: str) -> bool:
|
||||
"""is the given text in the given file?
|
||||
"""
|
||||
try:
|
||||
with open(filename, 'r', encoding='utf-8') as file:
|
||||
content = file.read()
|
||||
if content:
|
||||
if text in content:
|
||||
return True
|
||||
except OSError:
|
||||
print('EX: unable to find text in missing file ' + filename)
|
||||
return False
|
||||
|
||||
|
||||
def _dir_acct(base_dir: str, nickname: str, domain: str) -> str:
|
||||
"""Returns the directory of an account
|
||||
"""
|
||||
|
@ -74,7 +60,8 @@ def receiving_calendar_events(base_dir: str, nickname: str, domain: str,
|
|||
fp_cal.write(following_handles)
|
||||
except OSError:
|
||||
print('EX: receiving_calendar_events 2 ' + calendar_filename)
|
||||
return _text_in_file2(handle + '\n', calendar_filename)
|
||||
return handle + '\n' in open(calendar_filename,
|
||||
encoding='utf-8').read()
|
||||
|
||||
|
||||
def _receive_calendar_events(base_dir: str, nickname: str, domain: str,
|
||||
|
@ -95,7 +82,8 @@ def _receive_calendar_events(base_dir: str, nickname: str, domain: str,
|
|||
handle = following_nickname + '@' + following_domain
|
||||
|
||||
# check that you are following this handle
|
||||
if not _text_in_file2(handle + '\n', following_filename):
|
||||
if handle + '\n' not in open(following_filename,
|
||||
encoding='utf-8').read():
|
||||
print('WARN: ' + handle + ' is not in ' + following_filename)
|
||||
return
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@ from utils import get_display_name
|
|||
from utils import delete_post
|
||||
from utils import get_status_number
|
||||
from utils import get_full_domain
|
||||
from utils import text_in_file
|
||||
from filters import is_filtered
|
||||
from context import get_individual_post_context
|
||||
from session import get_method
|
||||
|
@ -71,7 +70,8 @@ def _remove_event_from_timeline(event_id: str,
|
|||
tl_events_filename: str) -> None:
|
||||
"""Removes the given event Id from the timeline
|
||||
"""
|
||||
if not text_in_file(event_id + '\n', tl_events_filename):
|
||||
if event_id + '\n' not in open(tl_events_filename,
|
||||
encoding='utf-8').read():
|
||||
return
|
||||
with open(tl_events_filename, 'r',
|
||||
encoding='utf-8') as fp_tl:
|
||||
|
@ -166,7 +166,8 @@ def save_event_post(base_dir: str, handle: str, post_id: str,
|
|||
|
||||
# Does this event post already exist within the calendar month?
|
||||
if os.path.isfile(calendar_filename):
|
||||
if text_in_file(post_id, calendar_filename):
|
||||
if post_id in open(calendar_filename,
|
||||
encoding='utf-8').read():
|
||||
# Event post already exists
|
||||
return False
|
||||
|
||||
|
@ -759,7 +760,7 @@ def remove_calendar_event(base_dir: str, nickname: str, domain: str,
|
|||
return
|
||||
if '/' in message_id:
|
||||
message_id = message_id.replace('/', '#')
|
||||
if not text_in_file(message_id, calendar_filename):
|
||||
if message_id not in open(calendar_filename, encoding='utf-8').read():
|
||||
return
|
||||
lines = None
|
||||
with open(calendar_filename, 'r', encoding='utf-8') as fp_cal:
|
||||
|
|
10
inbox.py
10
inbox.py
|
@ -18,7 +18,6 @@ from languages import understood_post_language
|
|||
from like import update_likes_collection
|
||||
from reaction import update_reaction_collection
|
||||
from reaction import valid_emoji_content
|
||||
from utils import text_in_file
|
||||
from utils import get_media_descriptions_from_post
|
||||
from utils import get_summary_from_post
|
||||
from utils import delete_cached_html
|
||||
|
@ -2558,7 +2557,8 @@ def populate_replies(base_dir: str, http_prefix: str, domain: str,
|
|||
encoding='utf-8'))
|
||||
if num_lines > max_replies:
|
||||
return False
|
||||
if not text_in_file(message_id, post_replies_filename):
|
||||
if message_id not in open(post_replies_filename,
|
||||
encoding='utf-8').read():
|
||||
try:
|
||||
with open(post_replies_filename, 'a+',
|
||||
encoding='utf-8') as replies_file:
|
||||
|
@ -2875,7 +2875,7 @@ def _like_notify(base_dir: str, domain: str, onion_domain: str,
|
|||
|
||||
like_file = account_dir + '/.newLike'
|
||||
if os.path.isfile(like_file):
|
||||
if not text_in_file('##sent##', like_file):
|
||||
if '##sent##' not in open(like_file).read():
|
||||
return
|
||||
|
||||
liker_nickname = get_nickname_from_actor(actor)
|
||||
|
@ -2937,7 +2937,7 @@ def _reaction_notify(base_dir: str, domain: str, onion_domain: str,
|
|||
|
||||
reaction_file = account_dir + '/.newReaction'
|
||||
if os.path.isfile(reaction_file):
|
||||
if not text_in_file('##sent##', reaction_file):
|
||||
if '##sent##' not in open(reaction_file, encoding='utf-8').read():
|
||||
return
|
||||
|
||||
reaction_nickname = get_nickname_from_actor(actor)
|
||||
|
@ -4816,7 +4816,7 @@ def _receive_follow_request(session, session_onion, session_i2p,
|
|||
print('Updating followers file: ' +
|
||||
followers_filename + ' adding ' + approve_handle)
|
||||
if os.path.isfile(followers_filename):
|
||||
if not text_in_file(approve_handle, followers_filename):
|
||||
if approve_handle not in open(followers_filename).read():
|
||||
group_account = \
|
||||
has_group_type(base_dir,
|
||||
message_json['actor'], person_cache)
|
||||
|
|
|
@ -16,7 +16,6 @@ from utils import remove_domain_port
|
|||
from utils import get_port_from_domain
|
||||
from utils import get_user_paths
|
||||
from utils import acct_dir
|
||||
from utils import text_in_file
|
||||
from threads import thread_with_trace
|
||||
from session import create_session
|
||||
|
||||
|
@ -116,7 +115,7 @@ def _approve_follower_handle(account_dir: str, approve_handle: str) -> None:
|
|||
"""
|
||||
approved_filename = account_dir + '/approved.txt'
|
||||
if os.path.isfile(approved_filename):
|
||||
if not text_in_file(approve_handle, approved_filename):
|
||||
if approve_handle not in open(approved_filename).read():
|
||||
try:
|
||||
with open(approved_filename, 'a+') as approved_file:
|
||||
approved_file.write(approve_handle + '\n')
|
||||
|
@ -281,7 +280,8 @@ def manual_approve_follow_request(session, session_onion, session_i2p,
|
|||
# update the followers
|
||||
print('Manual follow accept: updating ' + followers_filename)
|
||||
if os.path.isfile(followers_filename):
|
||||
if not text_in_file(approve_handle_full, followers_filename):
|
||||
if approve_handle_full not in open(followers_filename,
|
||||
encoding='utf-8').read():
|
||||
try:
|
||||
with open(followers_filename, 'r+',
|
||||
encoding='utf-8') as followers_file:
|
||||
|
|
|
@ -34,7 +34,6 @@ from utils import get_status_number
|
|||
from utils import clear_from_post_caches
|
||||
from utils import dangerous_markup
|
||||
from utils import local_actor_url
|
||||
from utils import text_in_file
|
||||
from inbox import store_hash_tags
|
||||
from session import create_session
|
||||
|
||||
|
@ -47,7 +46,7 @@ def _update_feeds_outbox_index(base_dir: str, domain: str,
|
|||
index_filename = base_path + '/outbox.index'
|
||||
|
||||
if os.path.isfile(index_filename):
|
||||
if not text_in_file(post_id, index_filename):
|
||||
if post_id not in open(index_filename, encoding='utf-8').read():
|
||||
try:
|
||||
with open(index_filename, 'r+') as feeds_file:
|
||||
content = feeds_file.read()
|
||||
|
|
|
@ -10,7 +10,6 @@ __module_group__ = "Calendar"
|
|||
import os
|
||||
from utils import remove_domain_port
|
||||
from utils import acct_dir
|
||||
from utils import text_in_file
|
||||
|
||||
|
||||
def _notify_on_post_arrival(base_dir: str, nickname: str, domain: str,
|
||||
|
@ -31,7 +30,8 @@ def _notify_on_post_arrival(base_dir: str, nickname: str, domain: str,
|
|||
handle = following_nickname + '@' + following_domain
|
||||
|
||||
# check that you are following this handle
|
||||
if not text_in_file(handle + '\n', following_filename):
|
||||
if handle + '\n' not in open(following_filename,
|
||||
encoding='utf-8').read():
|
||||
print('WARN: ' + handle + ' is not in ' + following_filename)
|
||||
return
|
||||
|
||||
|
|
|
@ -38,7 +38,6 @@ from roles import set_role
|
|||
from roles import set_rolesFromList
|
||||
from roles import get_actor_roles_list
|
||||
from media import process_meta_data
|
||||
from utils import text_in_file
|
||||
from utils import get_attachment_property_value
|
||||
from utils import get_nickname_from_actor
|
||||
from utils import remove_html
|
||||
|
@ -1208,7 +1207,7 @@ def _remove_tags_for_nickname(base_dir: str, nickname: str,
|
|||
continue
|
||||
if not os.path.isfile(tag_filename):
|
||||
continue
|
||||
if not text_in_file(match_str, tag_filename):
|
||||
if match_str not in open(tag_filename, encoding='utf-8').read():
|
||||
continue
|
||||
lines = []
|
||||
with open(tag_filename, 'r', encoding='utf-8') as fp_tag:
|
||||
|
@ -1359,7 +1358,8 @@ def is_person_snoozed(base_dir: str, nickname: str, domain: str,
|
|||
snoozed_filename = acct_dir(base_dir, nickname, domain) + '/snoozed.txt'
|
||||
if not os.path.isfile(snoozed_filename):
|
||||
return False
|
||||
if not text_in_file(snooze_actor + ' ', snoozed_filename):
|
||||
if snooze_actor + ' ' not in open(snoozed_filename,
|
||||
encoding='utf-8').read():
|
||||
return False
|
||||
# remove the snooze entry if it has timed out
|
||||
replace_str = None
|
||||
|
@ -1428,7 +1428,8 @@ def person_unsnooze(base_dir: str, nickname: str, domain: str,
|
|||
snoozed_filename = account_dir + '/snoozed.txt'
|
||||
if not os.path.isfile(snoozed_filename):
|
||||
return
|
||||
if not text_in_file(snooze_actor + ' ', snoozed_filename):
|
||||
if snooze_actor + ' ' not in open(snoozed_filename,
|
||||
encoding='utf-8').read():
|
||||
return
|
||||
replace_str = None
|
||||
with open(snoozed_filename, 'r', encoding='utf-8') as snoozed_file:
|
||||
|
|
6
posts.py
6
posts.py
|
@ -32,7 +32,6 @@ from webfinger import webfinger_handle
|
|||
from httpsig import create_signed_header
|
||||
from siteactive import site_is_active
|
||||
from languages import understood_post_language
|
||||
from utils import text_in_file
|
||||
from utils import get_media_descriptions_from_post
|
||||
from utils import valid_hash_tag
|
||||
from utils import get_audio_extensions
|
||||
|
@ -969,7 +968,7 @@ def _update_hashtags_index(base_dir: str, tag: {}, new_post_id: str) -> None:
|
|||
tags_filename)
|
||||
else:
|
||||
# prepend to tags index file
|
||||
if not text_in_file(tagline, tags_filename):
|
||||
if tagline not in open(tags_filename, encoding='utf-8').read():
|
||||
try:
|
||||
with open(tags_filename, 'r+', encoding='utf-8') as tags_file:
|
||||
content = tags_file.read()
|
||||
|
@ -991,7 +990,8 @@ def _add_schedule_post(base_dir: str, nickname: str, domain: str,
|
|||
|
||||
index_str = event_date_str + ' ' + post_id.replace('/', '#')
|
||||
if os.path.isfile(schedule_index_filename):
|
||||
if not text_in_file(index_str, schedule_index_filename):
|
||||
if index_str not in open(schedule_index_filename,
|
||||
encoding='utf-8').read():
|
||||
try:
|
||||
with open(schedule_index_filename, 'r+',
|
||||
encoding='utf-8') as schedule_file:
|
||||
|
|
|
@ -12,7 +12,6 @@ from utils import locate_post
|
|||
from utils import load_json
|
||||
from utils import save_json
|
||||
from utils import has_object_dict
|
||||
from utils import text_in_file
|
||||
|
||||
|
||||
def question_update_votes(base_dir: str, nickname: str, domain: str,
|
||||
|
@ -75,7 +74,8 @@ def question_update_votes(base_dir: str, nickname: str, domain: str,
|
|||
except OSError:
|
||||
print('EX: unable to write voters file ' + voters_filename)
|
||||
else:
|
||||
if not text_in_file(reply_json['actor'], voters_filename):
|
||||
if reply_json['actor'] not in open(voters_filename,
|
||||
encoding='utf-8').read():
|
||||
# append to the voters file
|
||||
try:
|
||||
with open(voters_filename, 'a+',
|
||||
|
|
4
roles.py
4
roles.py
|
@ -13,7 +13,6 @@ from utils import save_json
|
|||
from utils import get_status_number
|
||||
from utils import remove_domain_port
|
||||
from utils import acct_dir
|
||||
from utils import text_in_file
|
||||
|
||||
|
||||
def _clear_role_status(base_dir: str, role: str) -> None:
|
||||
|
@ -29,7 +28,8 @@ def _clear_role_status(base_dir: str, role: str) -> None:
|
|||
if not filename.endswith(".json"):
|
||||
continue
|
||||
filename = os.path.join(base_dir + '/accounts/', filename)
|
||||
if not text_in_file('"' + role + '"', filename):
|
||||
if '"' + role + '"' not in open(filename,
|
||||
encoding='utf-8').read():
|
||||
continue
|
||||
actor_json = load_json(filename)
|
||||
if not actor_json:
|
||||
|
|
27
tests.py
27
tests.py
|
@ -54,7 +54,6 @@ from follow import clear_followers
|
|||
from follow import send_follow_request_via_server
|
||||
from follow import send_unfollow_request_via_server
|
||||
from siteactive import site_is_active
|
||||
from utils import text_in_file
|
||||
from utils import convert_published_to_local_timezone
|
||||
from utils import convert_to_snake_case
|
||||
from utils import get_sha_256
|
||||
|
@ -2325,7 +2324,8 @@ def test_group_follow(base_dir: str) -> None:
|
|||
alice_domain, alice_port)
|
||||
assert 'alice@' + alice_domain in open(testgroup_followers_filename,
|
||||
encoding='utf-8').read()
|
||||
assert not text_in_file('!alice@' + alice_domain, testgroup_followers_filename)
|
||||
assert '!alice@' + alice_domain not in \
|
||||
open(testgroup_followers_filename, encoding='utf-8').read()
|
||||
|
||||
testgroup_webfinger_filename = \
|
||||
testgroup_dir + '/wfendpoints/testgroup@' + \
|
||||
|
@ -2404,9 +2404,10 @@ def test_group_follow(base_dir: str) -> None:
|
|||
assert valid_inbox(testgroup_dir, 'testgroup', testgroup_domain)
|
||||
assert valid_inbox_filenames(testgroup_dir, 'testgroup', testgroup_domain,
|
||||
bob_domain, bob_port)
|
||||
assert text_in_file('bob@' + bob_domain, testgroup_followers_filename)
|
||||
assert not text_in_file('!bob@' + bob_domain,
|
||||
testgroup_followers_filename)
|
||||
assert 'bob@' + bob_domain in open(testgroup_followers_filename,
|
||||
encoding='utf-8').read()
|
||||
assert '!bob@' + bob_domain not in \
|
||||
open(testgroup_followers_filename, encoding='utf-8').read()
|
||||
|
||||
testgroup_webfinger_filename = \
|
||||
testgroup_dir + '/wfendpoints/testgroup@' + \
|
||||
|
@ -3457,19 +3458,19 @@ def test_client_to_server(base_dir: str):
|
|||
cached_webfingers, person_cache,
|
||||
True, __version__, signing_priv_key_pem)
|
||||
for _ in range(10):
|
||||
test_str = 'alice@' + alice_domain + ':' + str(alice_port)
|
||||
if not text_in_file(test_str, bob_followers_filename):
|
||||
test_str = 'bob@' + bob_domain + ':' + str(bob_port)
|
||||
if not text_in_file(test_str, alice_following_filename):
|
||||
if 'alice@' + alice_domain + ':' + str(alice_port) not in \
|
||||
open(bob_followers_filename, encoding='utf-8').read():
|
||||
if 'bob@' + bob_domain + ':' + str(bob_port) not in \
|
||||
open(alice_following_filename, encoding='utf-8').read():
|
||||
break
|
||||
time.sleep(1)
|
||||
|
||||
assert os.path.isfile(bob_followers_filename)
|
||||
assert os.path.isfile(alice_following_filename)
|
||||
test_str = 'alice@' + alice_domain + ':' + str(alice_port)
|
||||
assert not text_in_file(test_str, bob_followers_filename)
|
||||
test_str = 'bob@' + bob_domain + ':' + str(bob_port)
|
||||
assert not text_in_file(test_str, alice_following_filename)
|
||||
assert 'alice@' + alice_domain + ':' + str(alice_port) \
|
||||
not in open(bob_followers_filename, encoding='utf-8').read()
|
||||
assert 'bob@' + bob_domain + ':' + str(bob_port) \
|
||||
not in open(alice_following_filename, encoding='utf-8').read()
|
||||
assert valid_inbox(bob_dir, 'bob', bob_domain)
|
||||
assert valid_inbox_filenames(bob_dir, 'bob', bob_domain,
|
||||
alice_domain, alice_port)
|
||||
|
|
Loading…
Reference in New Issue