Replace file operations with function

main
bashrc 2026-04-28 23:06:35 +01:00
parent 2ba0064cc7
commit 6d99b4e367
1 changed files with 22 additions and 22 deletions

View File

@ -52,6 +52,7 @@ from announce import is_self_announce
from question import is_html_question from question import is_html_question
from question import is_question from question import is_question
from data import load_string from data import load_string
from data import load_list
def _log_timeline_timing(enable_timing_log: bool, timeline_start_time, def _log_timeline_timing(enable_timing_log: bool, timeline_start_time,
@ -664,28 +665,27 @@ def html_timeline(default_timeline: str,
follow_requests_filename = \ follow_requests_filename = \
acct_dir(base_dir, nickname, domain) + '/followrequests.txt' acct_dir(base_dir, nickname, domain) + '/followrequests.txt'
if os.path.isfile(follow_requests_filename): if os.path.isfile(follow_requests_filename):
try: follow_requests_list: list[str] = \
with open(follow_requests_filename, 'r', load_list(follow_requests_filename,
encoding='utf-8') as fp_foll: 'EX: html_timeline unable to read ' +
for line in fp_foll: follow_requests_filename)
if not line: if follow_requests_list is not None:
continue for line in follow_requests_list:
# show follow approvals icon if not line:
follow_approvals = \ continue
'<a href="' + users_path + \ # show follow approvals icon
'/followers#buttonheader" ' + \ follow_approvals = \
'accesskey="' + \ '<a href="' + users_path + \
access_keys['followButton'] + '">' + \ '/followers#buttonheader" ' + \
'<img loading="lazy" decoding="async" ' + \ 'accesskey="' + \
'class="timelineicon" alt="' + \ access_keys['followButton'] + '">' + \
translate['Approve follow requests'] + \ '<img loading="lazy" decoding="async" ' + \
'" title="' + \ 'class="timelineicon" alt="' + \
translate['Approve follow requests'] + \ translate['Approve follow requests'] + \
'" src="/icons/person.png"/></a>\n' '" title="' + \
break translate['Approve follow requests'] + \
except OSError: '" src="/icons/person.png"/></a>\n'
print('EX: html_timeline unable to read ' + break
follow_requests_filename)
_log_timeline_timing(enable_timing_log, timeline_start_time, box_name, '3') _log_timeline_timing(enable_timing_log, timeline_start_time, box_name, '3')