Variable types

main
bashrc 2026-04-27 23:37:42 +01:00
parent a400bcf21f
commit 0e8c586bfd
22 changed files with 305 additions and 306 deletions

View File

@ -237,7 +237,7 @@ def remove_markup_tag(html: str, tag: str) -> str:
return html
section = html.split('<' + tag)
result = ''
result: str = ''
for text in section:
if not result:
if html.startswith('<' + tag) and '>' in text:
@ -249,7 +249,7 @@ def remove_markup_tag(html: str, tag: str) -> str:
html = result
section = html.split('</' + tag)
result = ''
result: str = ''
for text in section:
if not result:
if html.startswith('</' + tag) and '>' in text:
@ -292,8 +292,8 @@ def get_content_from_post(post_json_object: {}, system_language: str,
if not this_post_json.get(content_type) and \
not has_contentmap_dict:
return ''
content = ''
replacements = {
content: str = ''
replacements: dict = {
'&amp;': '&',
'<u>': '',
'</u>': ''
@ -378,7 +378,7 @@ def get_media_descriptions_from_post(post_json_object: {}) -> str:
post_attachments = get_post_attachments(post_json_object)
if not post_attachments:
return ''
descriptions = ''
descriptions: str = ''
for attach in post_attachments:
if not isinstance(attach, dict):
print('WARN: attachment is not a dict ' + str(attach))
@ -426,7 +426,7 @@ def get_summary_from_post(post_json_object: {}, system_language: str,
if summary_str:
summary_str = summary_str.strip()
if not _valid_summary(summary_str):
summary_str = ''
summary_str: str = ''
return summary_str
@ -626,7 +626,7 @@ def remove_html(content: str) -> str:
'<br>': '\n'
}
content = replace_strings(content, replacements)
result = ''
result: str = ''
for char in content:
if char == '<':
removing = True
@ -639,7 +639,7 @@ def remove_html(content: str) -> str:
# insert spaces after full stops
str_len = len(plain_text)
result = ''
result: str = ''
for i in range(str_len):
result += plain_text[i]
if plain_text[i] == '.' and i < str_len - 1:
@ -668,8 +668,8 @@ def remove_style_within_html(content: str) -> str:
if ' style="' not in content:
return content
sections = content.split(' style="')
result = ''
ctr = 0
result: str = ''
ctr: int = 0
for section_text in sections:
if ctr > 0:
result += section_text.split('"', 1)[1]
@ -701,7 +701,7 @@ def get_memorials(base_dir: str) -> str:
memorial_str = load_string(memorial_file,
'EX: unable to read ' + memorial_file)
if memorial_str is None:
memorial_str = ''
memorial_str: str = ''
return memorial_str
@ -710,7 +710,7 @@ def set_memorials(base_dir: str, domain: str, memorial_str) -> None:
"""
# check that the accounts exist
memorial_list = memorial_str.split('\n')
new_memorial_str = ''
new_memorial_str: str = ''
for memorial_item in memorial_list:
memorial_nick = memorial_item.strip()
check_dir = acct_dir(base_dir, memorial_nick, domain)
@ -1600,7 +1600,7 @@ def follow_person(base_dir: str, nickname: str, domain: str,
if os.path.isfile(unfollowed_filename):
if text_in_file(handle_to_follow, unfollowed_filename):
# remove them from the unfollowed file
new_lines = ''
new_lines: str = ''
lines: list[str] = \
load_list(unfollowed_filename,
'EX: follow_person unable to read ' +
@ -1804,7 +1804,7 @@ def _remove_attachment(base_dir: str, http_prefix: str,
load_string(account_media_log_filename,
'EX: _remove unable to read media log for ' + nickname)
if media_log_text is None:
media_log_text = ''
media_log_text: str = ''
if search_filename + '\n' in media_log_text:
media_log_text = media_log_text.replace(search_filename + '\n', '')
save_string(media_log_text, account_media_log_filename,
@ -2106,7 +2106,7 @@ def _delete_conversation_post(base_dir: str, nickname: str, domain: str,
'EX: _delete_conversation_post unable to read ' +
conversation_filename)
if conversation_str is None:
conversation_str = ''
conversation_str: str = ''
if post_id + '\n' not in conversation_str:
return False
conversation_str = conversation_str.replace(post_id + '\n', '')
@ -2182,7 +2182,7 @@ def _is_remote_dm(domain_full: str, post_json_object: {}) -> bool:
def get_gemini_blog_title(message_json: dict, system_language: str) -> str:
"""Returns the title for a gemini blog post
"""
title_text = ''
title_text: str = ''
title_str = get_summary_from_post(message_json, system_language, [])
if title_str:
title_text = remove_html(title_str)
@ -2540,7 +2540,7 @@ def get_nickname_validation_pattern() -> str:
"""Returns a html text input validation pattern for nickname
"""
reserved_names = _get_reserved_words()
pattern = ''
pattern: str = ''
for word in reserved_names:
if pattern:
pattern += '(?!.*\\b' + word + '\\b)'
@ -2706,7 +2706,7 @@ def camel_case_split(text: str) -> str:
'(?<=[A-Z])(?=[A-Z][a-z])|$)', text)
if not matches:
return text
result_str = ''
result_str: str = ''
for word in matches:
result_str += word.group(0) + ' '
return result_str.strip()
@ -2723,9 +2723,9 @@ def _convert_to_camel_case(text: str) -> str:
"""
if '_' not in text:
return text
words = text.split('_')
result = ''
ctr = 0
words: list = text.split('_')
result: str = ''
ctr: int = 0
for wrd in words:
if ctr > 0:
result += wrd.title()
@ -2842,7 +2842,7 @@ def user_agent_domain(user_agent: str, debug: bool) -> str:
"""
if 'https://' not in user_agent and 'http://' not in user_agent:
return None
agent_domain = ''
agent_domain: str = ''
if 'https://' in user_agent:
agent_domain = user_agent.split('https://')[1].strip()
else:
@ -2950,7 +2950,7 @@ def get_port_from_domain(domain: str) -> int:
if ':' in domain:
if domain.startswith('did:'):
return None
port_str = ''
port_str: str = ''
if ']:' not in domain:
if '[' not in domain:
port_str = domain.split(':')[1]
@ -4148,8 +4148,8 @@ def get_image_file(base_dir: str, name: str, directory: str,
"""returns the filenames for an image with the given name
"""
banner_extensions = get_image_extensions()
banner_file = ''
banner_filename = ''
banner_file: str = ''
banner_filename: str = ''
im_name = name
for ext in banner_extensions:
banner_file_test = im_name + '.' + ext

View File

@ -41,7 +41,7 @@ def html_about(base_dir: str, http_prefix: str,
if about_text:
about_text = markdown_to_html(about_text)
about_form = ''
about_form: str = ''
css_filename = base_dir + '/epicyon-profile.css'
if os.path.isfile(base_dir + '/epicyon.css'):
css_filename = base_dir + '/epicyon.css'

View File

@ -59,7 +59,7 @@ def html_access_keys(base_dir: str,
timeline_key = access_keys['menuTimeline']
submit_key = access_keys['submitButton']
access_keys_form = ''
access_keys_form: str = ''
css_filename = base_dir + '/epicyon-profile.css'
if os.path.isfile(base_dir + '/epicyon.css'):
css_filename = base_dir + '/epicyon.css'

View File

@ -189,14 +189,14 @@ def _html_calendar_day(person_cache: {}, translate: {},
event_time = None
event_time_markup = None
event_end_time = None
start_time_str = ''
end_time_str = ''
start_time_str: str = ''
end_time_str: str = ''
event_description = None
event_language = system_language
event_place = None
event_address = None
post_id = None
sender_name = ''
sender_name: str = ''
sender_actor = None
event_is_public = False
# get the time place and description
@ -271,7 +271,7 @@ def _html_calendar_day(person_cache: {}, translate: {},
event_description = \
translate['Reminder'] + ': ' + event_description
delete_button_str = ''
delete_button_str: str = ''
if post_id:
delete_button_str = \
'<td class="calendar__day__icons"><a href="' + \
@ -398,12 +398,12 @@ def html_calendar(person_cache: {}, translate: {},
"""
domain = remove_domain_port(domain_full)
text_match = ''
default_year = 1970
default_month = 0
text_match: str = ''
default_year: int = 1970
default_month: int = 0
month_number = default_month
day_number = None
year = default_year
year: int = default_year
actor = http_prefix + '://' + domain_full + path.replace('/calendar', '')
only_show_reminders = False
if '?' in actor:

View File

@ -129,12 +129,12 @@ def get_left_column_content(base_dir: str, nickname: str, domain_full: str,
known_epicyon_instances: []) -> str:
"""Returns html content for the left column
"""
html_str = ''
html_str: str = ''
separator_str = html_post_separator(base_dir, 'left')
domain = remove_domain_port(domain_full)
edit_image_class = ''
edit_image_class: str = ''
if show_header_image:
left_image_file, left_column_image_filename = \
get_left_image_file(base_dir, nickname, domain, theme)
@ -386,7 +386,7 @@ def html_links_mobile(base_dir: str,
known_epicyon_instances: []) -> str:
"""Show the left column links within mobile view
"""
html_str = ''
html_str: str = ''
# the css filename
css_filename = base_dir + '/epicyon-profile.css'
@ -514,13 +514,13 @@ def html_edit_links(translate: {}, base_dir: str, path: str,
' </div>\n'
links_filename = data_dir(base_dir) + '/links.txt'
links_str = ''
links_str: str = ''
if os.path.isfile(links_filename):
links_str = load_string(links_filename,
'EX: html_edit_links unable to read ' +
links_filename)
if links_str is None:
links_str = ''
links_str: str = ''
edit_links_form += \
'<div class="container">'
@ -542,14 +542,14 @@ def html_edit_links(translate: {}, base_dir: str, path: str,
if admin_nickname:
if nickname == admin_nickname:
about_filename = data_dir(base_dir) + '/about.md'
about_str = ''
about_str: str = ''
if os.path.isfile(about_filename):
about_str = \
load_string(about_filename,
'EX: html_edit_links unable to read 2 ' +
about_filename)
if about_str is None:
about_str = ''
about_str: str = ''
edit_links_form += \
'<div class="container">'
@ -565,13 +565,13 @@ def html_edit_links(translate: {}, base_dir: str, path: str,
'</div>'
tos_filename = data_dir(base_dir) + '/tos.md'
tos_str = ''
tos_str: str = ''
if os.path.isfile(tos_filename):
tos_str = load_string(tos_filename,
'EX: html_edit_links unable to read 3 ' +
tos_filename)
if tos_str is None:
tos_str = ''
tos_str: str = ''
edit_links_form += \
'<div class="container">'
@ -587,14 +587,14 @@ def html_edit_links(translate: {}, base_dir: str, path: str,
'</div>'
specification_filename = data_dir(base_dir) + '/activitypub.md'
specification_str = ''
specification_str: str = ''
if os.path.isfile(specification_filename):
specification_str = \
load_string(specification_filename,
'EX: html_edit_links unable to read 4 ' +
specification_filename)
if specification_str is None:
specification_str = ''
specification_str: str = ''
edit_links_form += \
'<div class="container">'

View File

@ -68,7 +68,7 @@ def get_right_column_content(base_dir: str, nickname: str, domain_full: str,
access_keys: {}) -> str:
"""Returns html content for the right column
"""
html_str = ''
html_str: str = ''
domain = remove_domain_port(domain_full)
@ -98,7 +98,7 @@ def get_right_column_content(base_dir: str, nickname: str, domain_full: str,
html_str += '<center>' + publish_button_str + '</center>'
# show a column header image, eg. title of the theme or newswire banner
edit_image_class = ''
edit_image_class: str = ''
if show_header_image:
right_image_file, right_column_image_filename = \
get_right_image_file(base_dir, nickname, domain, theme)
@ -236,12 +236,12 @@ def _html_newswire(base_dir: str, newswire: {}, nickname: str, moderator: bool,
"""Converts a newswire dict into html
"""
separator_str = html_post_separator(base_dir, 'right')
html_str = ''
replacements1 = {
html_str: str = ''
replacements1: dict = {
'T': ' ',
'Z': ''
}
replacements2 = {
replacements2: dict = {
' ': '__',
':': 'aa'
}
@ -265,7 +265,7 @@ def _html_newswire(base_dir: str, newswire: {}, nickname: str, moderator: bool,
date_str_link = replace_strings(date_str, replacements1)
url = item[1]
favicon_url = get_newswire_favicon_url(url)
favicon_link = ''
favicon_link: str = ''
if favicon_url:
cached_favicon_filename = \
get_fav_filename_from_url(base_dir, favicon_url)
@ -302,7 +302,7 @@ def _html_newswire(base_dir: str, newswire: {}, nickname: str, moderator: bool,
html_str += separator_str
if moderated_item and 'vote:' + nickname in item[2]:
total_votes_str = ''
total_votes_str: str = ''
total_votes = 0
if moderator:
total_votes = votes_on_newswire_item(item[2])
@ -330,7 +330,7 @@ def _html_newswire(base_dir: str, newswire: {}, nickname: str, moderator: bool,
html_str += ' <span class="newswireDateVotedOn">'
html_str += date_shown + '</span></p>\n'
else:
total_votes_str = ''
total_votes_str: str = ''
total_votes = 0
if moderator:
if moderated_item:
@ -376,7 +376,7 @@ def html_citations(base_dir: str, nickname: str, domain: str,
theme: str) -> str:
"""Show the citations screen when creating a blog
"""
html_str = ''
html_str: str = ''
# create a list of dates for citations
# these can then be used to re-select checkboxes later
@ -430,12 +430,12 @@ def html_citations(base_dir: str, nickname: str, domain: str,
html_str += translate['Choose newswire items ' +
'referenced in your article'] + '<br>'
if blog_title is None:
blog_title = ''
blog_title: str = ''
html_str += \
' <input type="hidden" name="blogTitle" value="' + \
blog_title + '">\n'
if blog_content is None:
blog_content = ''
blog_content: str = ''
html_str += \
' <input type="hidden" name="blogContent" value="' + \
blog_content + '">\n'
@ -460,7 +460,7 @@ def html_citations(base_dir: str, nickname: str, domain: str,
if ']' in item[0]:
item[0] = item[0].split(']')[0]
# should this checkbox be selected?
selected_str = ''
selected_str: str = ''
if date_str in citations_selected:
selected_str = ' checked'
@ -502,7 +502,7 @@ def html_newswire_mobile(base_dir: str, nickname: str,
ua_str: str) -> str:
"""Shows the mobile version of the newswire right column
"""
html_str = ''
html_str: str = ''
# the css filename
css_filename = base_dir + '/epicyon-profile.css'
@ -637,14 +637,14 @@ def html_edit_newswire(translate: {}, base_dir: str, path: str,
' </div>\n'
newswire_filename = data_dir(base_dir) + '/newswire.txt'
newswire_str = ''
newswire_str: str = ''
if os.path.isfile(newswire_filename):
newswire_str = \
load_string(newswire_filename,
'EX: html_edit_newswire unable to read ' +
newswire_filename)
if newswire_str is None:
newswire_str = ''
newswire_str: str = ''
edit_newswire_form += \
'<div class="container">'
@ -661,7 +661,7 @@ def html_edit_newswire(translate: {}, base_dir: str, path: str,
'style="height:80vh" spellcheck="false">' + \
newswire_str + '</textarea>'
filter_str = ''
filter_str: str = ''
filter_filename = \
data_dir(base_dir) + '/news@' + domain + '/filters.txt'
if os.path.isfile(filter_filename):
@ -670,7 +670,7 @@ def html_edit_newswire(translate: {}, base_dir: str, path: str,
'EX: html_edit_newswire unable to read 2 ' +
filter_filename)
if filter_str is None:
filter_str = ''
filter_str: str = ''
edit_newswire_form += \
' <br><b><label class="labels">' + \
@ -681,7 +681,7 @@ def html_edit_newswire(translate: {}, base_dir: str, path: str,
'name="filteredWordsNewswire" style="height:50vh" ' + \
'spellcheck="true">' + filter_str + '</textarea>\n'
dogwhistle_str = ''
dogwhistle_str: str = ''
for whistle, category in dogwhistles.items():
if not category:
continue
@ -697,7 +697,7 @@ def html_edit_newswire(translate: {}, base_dir: str, path: str,
'name="dogwhistleWords" style="height:50vh" ' + \
'spellcheck="true">' + dogwhistle_str + '</textarea>\n'
hashtag_rules_str = ''
hashtag_rules_str: str = ''
hashtag_rules_filename = data_dir(base_dir) + '/hashtagrules.txt'
if os.path.isfile(hashtag_rules_filename):
hashtag_rules_str = \
@ -705,7 +705,7 @@ def html_edit_newswire(translate: {}, base_dir: str, path: str,
'EX: html_edit_newswire unable to read 3 ' +
hashtag_rules_filename)
if hashtag_rules_str is None:
hashtag_rules_str = ''
hashtag_rules_str: str = ''
edit_newswire_form += \
' <br><b><label class="labels">' + \

View File

@ -85,7 +85,7 @@ def html_conversation_view(authorized: bool, post_id: str,
get_config_param(base_dir, 'instanceTitle')
preload_images: list[str] = []
metadata_str = ''
metadata_str: str = ''
if post_id:
# https://swicg.github.io/activitypub-html-discovery/#html-link-element
# link to the activitypub post
@ -119,7 +119,7 @@ def html_conversation_view(authorized: bool, post_id: str,
minimize_all_images = False
if nickname in min_images_for_accounts:
minimize_all_images = True
current_reading_str = ''
current_reading_str: str = ''
for post_json_object in conv_posts:
show_individual_post_icons = True
# if not authorized then only show public posts
@ -180,7 +180,7 @@ def html_conversation_view(authorized: bool, post_id: str,
separator_str + post_str
# show separator at the current reading point
current_reading_str = ''
current_reading_str: str = ''
if post_json_object.get('id'):
if isinstance(post_json_object['id'], str):
id_str = remove_id_ending(post_json_object['id'])

View File

@ -231,7 +231,7 @@ def _remove_initial_mentions_from_content(content: str) -> str:
if not content.startswith('@'):
return content
words = content.split(' ')
new_content = ''
new_content: str = ''
for wrd in words:
if wrd.startswith('@'):
continue
@ -291,7 +291,7 @@ def html_new_post(edit_post_params: {},
"""
# get the json if this is an edited post
edited_post_json = None
edited_published = ''
edited_published: str = ''
if edit_post_params:
if edit_post_params.get('post_url'):
edited_post_filename = \
@ -328,13 +328,13 @@ def html_new_post(edit_post_params: {},
edited_post_json['object']['published']
# default subject line or content warning
default_subject = ''
default_subject: str = ''
if share_description:
default_subject = share_description
default_location = ''
default_start_time = ''
default_end_time = ''
default_location: str = ''
default_start_time: str = ''
default_end_time: str = ''
if default_month and default_year:
default_month_str = str(default_month)
if default_month < 10:
@ -358,7 +358,7 @@ def html_new_post(edit_post_params: {},
default_start_time, default_end_time = \
_get_date_from_tags(edited_post_json['object']['tag'])
reply_str = ''
reply_str: str = ''
is_new_reminder = False
if path.endswith('/newreminder'):
@ -373,12 +373,12 @@ def html_new_post(edit_post_params: {},
# select a date and time for this post
date_and_time_str += '<label class="labels">' + \
translate['Date'] + ': </label>\n'
date_default = ''
time_default = ''
date_default: str = ''
time_default: str = ''
if default_start_time:
date_default = ' value="' + default_start_time.split('T')[0] + '"'
time_default = ' value="' + default_start_time.split('T')[1] + '"'
end_time_default = ''
end_time_default: str = ''
if default_end_time:
end_time_default = ' value="' + default_end_time.split('T')[1] + '"'
date_and_time_str += \
@ -410,7 +410,7 @@ def html_new_post(edit_post_params: {},
new_post_text = '<h1>' + \
translate['Write your post text below.'] + '</h1>\n'
else:
new_post_text = ''
new_post_text: str = ''
if category != 'accommodation':
new_post_text = \
'<p class="new-post-text">' + \
@ -572,7 +572,7 @@ def html_new_post(edit_post_params: {},
'EX: html_new_post unable to read ' +
dir_str + '/report.txt [ex]')
if custom_report_text is None:
custom_report_text = ''
custom_report_text: str = ''
if '</p>' not in custom_report_text:
custom_report_text = \
'<p class="login-subtext">' + \
@ -615,7 +615,7 @@ def html_new_post(edit_post_params: {},
'EX: html_new_post unable to read ' +
dir_str + '/newpost.txt')
if new_post_text is None:
new_post_text = ''
new_post_text: str = ''
css_filename = base_dir + '/epicyon-profile.css'
if os.path.isfile(base_dir + '/epicyon.css'):
@ -664,7 +664,7 @@ def html_new_post(edit_post_params: {},
'" spellcheck="true" autocomplete="on"></textarea>\n'
new_post_image_section += end_edit_section()
new_post_emoji_section = ''
new_post_emoji_section: str = ''
if not path.endswith('/newreadingstatus'):
common_emoji_str = html_common_emoji(base_dir, 16)
if common_emoji_str:
@ -686,11 +686,11 @@ def html_new_post(edit_post_params: {},
else:
placeholder_subject = \
translate['Subject or Content Warning (optional)'] + '...'
placeholder_mentions = ''
placeholder_mentions: str = ''
if in_reply_to:
placeholder_mentions = \
translate['Replying to'] + '...'
placeholder_message = ''
placeholder_message: str = ''
if category != 'accommodation':
if default_timeline == 'tlfeatures':
placeholder_message = translate['Write your news report'] + '...'
@ -700,7 +700,7 @@ def html_new_post(edit_post_params: {},
idx = 'Introduce yourself and specify the date ' + \
'and time when you wish to stay'
placeholder_message = translate[idx]
extra_fields = ''
extra_fields: str = ''
premium = is_premium_account(base_dir, nickname, domain)
endpoint = 'newpost'
if path.endswith('/newblog'):
@ -927,7 +927,7 @@ def html_new_post(edit_post_params: {},
'bookrating', '', 1, 5, None)
extra_fields += '</div>\n'
citations_str = ''
citations_str: str = ''
if endpoint == 'newblog':
citations_filename = \
acct_dir(base_dir, nickname, domain) + '/.citations.txt'
@ -956,8 +956,8 @@ def html_new_post(edit_post_params: {},
citations_str += ' </ul>\n'
citations_str += '</div>\n'
replies_section = ''
date_and_location = ''
replies_section: str = ''
date_and_location: str = ''
if endpoint not in ('newshare', 'newwanted', 'newreport',
'newquestion', 'newreadingstatus'):
@ -1159,7 +1159,7 @@ def html_new_post(edit_post_params: {},
banner_path + '" alt="" /></a>\n' + \
'</header>\n'
mentions_str = ''
mentions_str: str = ''
for ment in mentions:
mention_nickname = get_nickname_from_actor(ment)
if not mention_nickname:
@ -1186,13 +1186,13 @@ def html_new_post(edit_post_params: {},
dropdown_reminder_suffix = '/newreminder'
dropdown_report_suffix = '/newreport'
if in_reply_to or mentions:
dropdown_new_post_suffix = ''
dropdown_new_blog_suffix = ''
dropdown_unlisted_suffix = ''
dropdown_followers_suffix = ''
dropdown_dm_suffix = ''
dropdown_reminder_suffix = ''
dropdown_report_suffix = ''
dropdown_new_post_suffix: str = ''
dropdown_new_blog_suffix: str = ''
dropdown_unlisted_suffix: str = ''
dropdown_followers_suffix: str = ''
dropdown_dm_suffix: str = ''
dropdown_reminder_suffix: str = ''
dropdown_report_suffix: str = ''
if in_reply_to:
dropdown_new_post_suffix += '?replyto=' + in_reply_to
dropdown_new_blog_suffix += '?replyto=' + in_reply_to
@ -1224,7 +1224,7 @@ def html_new_post(edit_post_params: {},
dropdown_followers_suffix += '?convthreadId=' + convthread_id
dropdown_dm_suffix += '?convthreadId=' + convthread_id
drop_down_content = ''
drop_down_content: str = ''
if not report_url and not share_description:
account_dir = acct_dir(base_dir, nickname, domain)
drop_down_content = \
@ -1352,7 +1352,7 @@ def html_new_post(edit_post_params: {},
html_following_data_list(base_dir, nickname, domain, domain_full,
'following', True)
new_post_form += ''
selected_str = ''
selected_str: str = ''
if endpoint != 'newreadingstatus':
new_post_form += \
@ -1366,7 +1366,7 @@ def html_new_post(edit_post_params: {},
message_box_height = 800
# get the default message text
default_message = ''
default_message: str = ''
if edited_post_json:
content_str = \
get_content_from_post(edited_post_json, system_language,

View File

@ -55,10 +55,10 @@ def _html_front_screen_posts(recent_posts_cache: {}, max_recent_posts: int,
which is the blog timeline of the news actor
"""
separator_str = html_post_separator(base_dir, None)
profile_str = ''
max_items = 4
ctr = 0
curr_page = 1
profile_str: str = ''
max_items: int = 4
ctr: int = 0
curr_page: int = 1
box_name = 'tlfeatures'
authorized = True
while ctr < max_items and curr_page < 4:
@ -210,7 +210,7 @@ def html_front_screen(signing_priv_key_pem: str,
if os.path.isfile(base_dir + '/epicyon.css'):
css_filename = base_dir + '/epicyon.css'
license_str = ''
license_str: str = ''
banner_file, _ = \
get_banner_file(base_dir, nickname, domain, theme)
profile_str += \

View File

@ -67,7 +67,7 @@ def get_hashtag_categories_feed(base_dir: str,
rss_str += \
'<item>\n' + \
' <title>' + escape_text(category_str) + '</title>\n'
list_str = ''
list_str: str = ''
for hashtag in hashtag_list:
if ':' in hashtag:
continue
@ -104,7 +104,7 @@ def html_hash_tag_swarm(base_dir: str, actor: str, translate: {}) -> str:
# Load the blocked hashtags into memory.
# This avoids needing to repeatedly load the blocked file for each hashtag
blocked_str = ''
blocked_str: str = ''
global_blocking_filename = data_dir(base_dir) + '/blocking.txt'
if os.path.isfile(global_blocking_filename):
blocked_str = \
@ -112,7 +112,7 @@ def html_hash_tag_swarm(base_dir: str, actor: str, translate: {}) -> str:
'EX: html_hash_tag_swarm unable to read ' +
global_blocking_filename)
if blocked_str is None:
blocked_str = ''
blocked_str: str = ''
for _, _, files in os.walk(base_dir + '/tags'):
for fname in files:
@ -215,7 +215,7 @@ def html_hash_tag_swarm(base_dir: str, actor: str, translate: {}) -> str:
tag_swarm.sort()
# swarm of categories
category_swarm_str = ''
category_swarm_str: str = ''
if category_swarm:
if len(category_swarm) > 3:
category_swarm.sort()
@ -232,7 +232,7 @@ def html_hash_tag_swarm(base_dir: str, actor: str, translate: {}) -> str:
category_swarm_str += '<br>\n'
# swarm of tags
tag_swarm_str = ''
tag_swarm_str: str = ''
for tag_name in tag_swarm:
tag_display_name = tag_name
tag_map_filename = \
@ -382,7 +382,7 @@ def _store_tag_name(base_dir: str, nickname: str,
'EX: store_hash_tags failed to read ' +
tags_filename)
if content is None:
content = ''
content: str = ''
if post_url not in content:
content = tag_line + content
if save_string(content, tags_filename,

View File

@ -197,7 +197,7 @@ def header_buttons_timeline(default_timeline: str,
translate['Inbox'] + '</span></button></a>'
# show todays events buttons on the first inbox page
happening_str = ''
happening_str: str = ''
if box_name == 'inbox' and page_number == 1:
now = datetime.now()
tomorrow = datetime.now() + timedelta(1)

View File

@ -161,7 +161,7 @@ def html_likers_of_post(base_dir: str, nickname: str,
mutuals_list = get_mutuals_of_person(base_dir, nickname, domain)
is_text_mode = text_mode_browser(ua_str)
likers_list = ''
likers_list: str = ''
for like_item in obj[dict_name]['items']:
if not like_item.get('actor'):
continue
@ -189,12 +189,12 @@ def html_likers_of_post(base_dir: str, nickname: str,
liker_avatar_url = \
get_person_avatar_url(base_dir, liker_actor, person_cache)
if not liker_avatar_url:
liker_avatar_url = ''
liker_avatar_url: str = ''
else:
liker_avatar_url = ';' + liker_avatar_url
# get the mutual icon prefix
mutual_prefix = ''
mutual_prefix: str = ''
if liker_username:
liker_domain, _ = get_domain_from_actor(liker_actor)
if liker_domain:

View File

@ -147,14 +147,14 @@ def html_login(translate: {},
'EX: html_login unable to read ' + dir_str +
'/login.txt')
if login_text is None:
login_text = ''
login_text: str = ''
css_filename = base_dir + '/epicyon-login.css'
if os.path.isfile(base_dir + '/login.css'):
css_filename = base_dir + '/login.css'
# show the register button
register_button_str = ''
register_button_str: str = ''
if get_config_param(base_dir, 'registration') == 'open':
remaining = 0
if get_config_param(base_dir, 'registrationsRemaining'):
@ -178,7 +178,7 @@ def html_login(translate: {},
'<p class="login-text"><a href="/terms" tabindex="2">' + \
translate['Terms of Service'] + '</a></p>'
login_button_str = ''
login_button_str: str = ''
if accounts > 0:
login_button_str = \
'<button type="submit" name="submit" tabindex="1">' + \

View File

@ -43,7 +43,7 @@ def html_manual(base_dir: str, http_prefix: str,
md_text = markdown_example_numbers(md_text)
manual_text = markdown_to_html(md_text)
manual_form = ''
manual_form: str = ''
css_filename = base_dir + '/epicyon-profile.css'
if os.path.isfile(base_dir + '/epicyon.css'):
css_filename = base_dir + '/epicyon.css'

View File

@ -188,7 +188,7 @@ def _add_embedded_video_from_sites(content: str,
if '"' in url:
url = url.split('"')[0]
if url:
video_site_settings = ''
video_site_settings: str = ''
if '#' in url:
video_site_settings = '#' + url.split('#', 1)[1]
url = url.split('#')[0]

View File

@ -128,7 +128,7 @@ def html_account_info(translate: {},
signing_priv_key_pem = None
msg_str1 = 'This account interacts with the following instances'
info_form = ''
info_form: str = ''
css_filename = base_dir + '/epicyon-profile.css'
if os.path.isfile(base_dir + '/epicyon.css'):
css_filename = base_dir + '/epicyon.css'
@ -232,7 +232,7 @@ def html_account_info(translate: {},
'target="_blank" rel="nofollow noopener noreferrer">' + \
post_domain + '</a> '
if is_blocked_domain(base_dir, post_domain, None, block_federated):
blocked_posts_links = ''
blocked_posts_links: str = ''
url_ctr = 0
for url in blocked_post_urls:
if url_ctr > 0:
@ -242,7 +242,7 @@ def html_account_info(translate: {},
'target="_blank" rel="nofollow noopener noreferrer">' + \
url + '</a>'
url_ctr += 1
blocked_posts_html = ''
blocked_posts_html: str = ''
if blocked_posts_links:
block_no_str = 'blockNumber' + str(ctr)
blocked_posts_html = \
@ -324,7 +324,7 @@ def html_account_info(translate: {},
if minimum_word_count >= 3:
info_form += '<div class="accountInfoDomains">\n'
info_form += '<h1>' + translate['Word frequencies'] + '</h1>\n'
word_swarm = ''
word_swarm: str = ''
ctr = 0
for word, count in word_frequency.items():
if count >= minimum_word_count:
@ -353,7 +353,7 @@ def html_moderation_info(translate: {}, base_dir: str,
msg_str2 = \
'Any blocks or suspensions made by moderators will be shown here.'
info_form = ''
info_form: str = ''
css_filename = base_dir + '/epicyon-profile.css'
if os.path.isfile(base_dir + '/epicyon.css'):
css_filename = base_dir + '/epicyon.css'
@ -418,8 +418,8 @@ def html_moderation_info(translate: {}, base_dir: str,
if not actor_json:
continue
actor = actor_json['id']
avatar_url = ''
ext = ''
avatar_url: str = ''
ext: str = ''
if actor_json.get('icon'):
url_str = get_person_icon(actor_json)
if url_str:
@ -478,7 +478,7 @@ def html_moderation_info(translate: {}, base_dir: str,
load_list(blocking_filename,
'EX: html_moderation_info unable to read 2 ' +
blocking_filename + ' [ex]')
blocked_str = ''
blocked_str: str = ''
if blocked_lines:
blocked_lines.sort()
for line in blocked_lines:

View File

@ -73,14 +73,14 @@ def _minimize_attached_images(base_dir: str, nickname: str, domain: str,
# get the contents of the minimize file, which is
# a set of handles
minimize_handles = ''
minimize_handles: str = ''
if os.path.isfile(minimize_filename):
print('Minimize file exists')
minimize_handles = \
load_string(minimize_filename,
'EX: minimize_attached_images ' + minimize_filename)
if minimize_handles is None:
minimize_handles = ''
minimize_handles: str = ''
else:
# create a new minimize file from the following file
print('Creating minimize file ' + minimize_filename)
@ -177,7 +177,7 @@ def html_person_options(default_timeline: str,
system_language: str) -> str:
"""Show options for a person: view/follow/block/report
"""
options_link_str = ''
options_link_str: str = ''
options_domain, options_port = get_domain_from_actor(options_actor)
if not options_domain:
return None
@ -243,7 +243,7 @@ def html_person_options(default_timeline: str,
if is_person_snoozed(base_dir, nickname, domain, options_actor):
snooze_button_str = 'Unsnooze'
donate_str = ''
donate_str: str = ''
if donate_url:
donate_str = \
' <a href="' + donate_url + \
@ -312,7 +312,7 @@ def html_person_options(default_timeline: str,
handle_shown += ' 💤'
if offline:
handle_shown += ' [' + translate['offline'].upper() + ']'
mitm_str = ''
mitm_str: str = ''
if options_domain in mitm_servers:
mitm_str = ' ' + mitm_warning_html(translate)
options_str += \
@ -347,7 +347,7 @@ def html_person_options(default_timeline: str,
new_domain, _ = get_domain_from_actor(moved_to)
if new_nickname and new_domain:
new_handle = new_nickname + '@' + new_domain
blocked_icon_str = ''
blocked_icon_str: str = ''
if is_blocked(base_dir, nickname, domain,
new_nickname, new_domain, blocked_cache,
None):
@ -728,7 +728,7 @@ def html_person_options(default_timeline: str,
block_str + '" accesskey="' + access_keys['blockButton'] + '">' + \
translate[block_str] + '</button>\n'
person_notes = ''
person_notes: str = ''
if origin_path_str == '/users/' + nickname:
person_notes = \
get_person_notes(base_dir, nickname, domain, handle)

View File

@ -55,7 +55,7 @@ def _html_podcast_chapters(link_url: str,
chapters_url = podcast_properties[key]['uri']
else:
return ''
html_str = ''
html_str: str = ''
if podcast_properties[key].get('type'):
url_type = podcast_properties[key]['type']
@ -82,7 +82,7 @@ def _html_podcast_chapters(link_url: str,
return ''
if not isinstance(chapters_json['chapters'], list):
return ''
chapters_html = ''
chapters_html: str = ''
for chapter in chapters_json['chapters']:
if not isinstance(chapter, dict):
continue
@ -91,7 +91,7 @@ def _html_podcast_chapters(link_url: str,
if not chapter.get('startTime'):
continue
chapter_title = chapter['title']
chapter_url = ''
chapter_url: str = ''
if chapter.get('url'):
url_str = get_url_from_post(chapter['url'])
chapter_url = remove_html(url_str)
@ -131,8 +131,8 @@ def _html_podcast_transcripts(podcast_properties: {}, translate: {}) -> str:
return ''
if not isinstance(podcast_properties[key], list):
return ''
ctr = 1
html_str = ''
ctr: int = 1
html_str: str = ''
for _ in podcast_properties[key]:
transcript_url = None
if podcast_properties[key].get('url'):
@ -176,7 +176,7 @@ def _html_podcast_social_interactions(podcast_properties: {},
episode_post_url = podcast_properties[key]['text']
else:
return ''
actor_str = ''
actor_str: str = ''
podcast_account_id = None
if podcast_properties[key].get('accountId'):
podcast_account_id = podcast_properties[key]['accountId']
@ -233,11 +233,11 @@ def _html_podcast_performers(podcast_properties: {}) -> str:
performer_title += ', <i>' + performer['group'] + '</i>'
performer_title = remove_html(performer_title)
performer_url = ''
performer_url: str = ''
if performer.get('href'):
performer_url = remove_html(performer['href'])
performer_img = ''
performer_img: str = ''
if performer.get('img'):
performer_img = performer['img']
@ -336,7 +336,7 @@ def html_podcast_episode(translate: {},
preload_images)
podcast_properties = newswire_item[8]
image_url = ''
image_url: str = ''
image_src = 'src'
if podcast_properties.get('images'):
if podcast_properties['images'].get('srcset'):
@ -483,7 +483,7 @@ def html_podcast_episode(translate: {},
'" rel="donation"><button class="donateButton">' + \
translate['Donate'] + '</button></a></span></p>\n'
fediverse_handle = ''
fediverse_handle: str = ''
if len(newswire_item) > 9:
fediverse_handle = newswire_item[9]
podcast_nickname = get_nickname_from_actor(fediverse_handle)
@ -497,7 +497,7 @@ def html_podcast_episode(translate: {},
if len(newswire_item) > 10:
extra_links = newswire_item[10]
if extra_links:
links_text = ''
links_text: str = ''
for link_str in extra_links:
link_str = remove_html(link_str)
if not resembles_url(link_str):
@ -518,7 +518,7 @@ def html_podcast_episode(translate: {},
podcast_str += links_text
if podcast_properties['categories']:
tags_str = ''
tags_str: str = ''
for tag in podcast_properties['categories']:
tag = tag.replace('#', '')
if not tag:

View File

@ -407,7 +407,7 @@ def prepare_html_post_nickname(nickname: str, post_html: str) -> str:
user_found = True
post_str = post_html
new_post_str = ''
new_post_str: str = ''
while user_found:
if users_str not in post_str:
new_post_str += post_str
@ -439,7 +439,7 @@ def replace_link_variable(link: str, variable_name: str, value: str,
return link
curr_str = link
result = ''
result: str = ''
while full_var in curr_str:
prefix = curr_str.split(full_var, 1)[0] + full_var
next_str = curr_str.split(full_var, 1)[1]
@ -449,7 +449,7 @@ def replace_link_variable(link: str, variable_name: str, value: str,
curr_str = next_str
else:
result += prefix + value
curr_str = ''
curr_str: str = ''
return result + curr_str
@ -461,7 +461,7 @@ def _prepare_media_post_from_html_cache(post_html: str,
'this tag is not supported in your browser'
"""
sections = post_html.split('<' + media_type)
new_post_html = ''
new_post_html: str = ''
for section_str in sections:
ending_tag = '</' + media_type + '>'
if ending_tag not in section_str:
@ -469,8 +469,8 @@ def _prepare_media_post_from_html_cache(post_html: str,
continue
markup = section_str.split(ending_tag)[0]
ending = section_str.split(ending_tag)[1]
url = ''
description = ''
url: str = ''
description: str = ''
# get the video/audio url if it exists
if ' src="' in markup:
url = markup.split(' src="')[1]
@ -534,7 +534,7 @@ def prepare_post_from_html_cache(nickname: str, post_html: str, box_name: str,
# add first post in the timeline
if first_post_id is None:
first_post_id = ''
first_post_id: str = ''
first_post_id = first_post_id.replace('#', '/')
if '?firstpost=' in with_page_number:
@ -657,7 +657,7 @@ def _get_avatar_image_html(show_avatar_options: bool,
if avatar_url.endswith('.svg'):
avatar_url = '/icons/avatar_default.png'
avatar_link = ''
avatar_link: str = ''
if '/users/news/' not in avatar_url:
avatar_link = \
' <a class="imageAnchor" href="' + \
@ -710,7 +710,7 @@ def _get_reply_icon_html(base_dir: str, nickname: str, domain: str,
conversation_id: str, convthread_id: str) -> str:
"""Returns html for the reply icon/button
"""
reply_str = ''
reply_str: str = ''
if not (show_icons and comments_enabled):
return reply_str
@ -759,11 +759,11 @@ def _get_reply_icon_html(base_dir: str, nickname: str, domain: str,
reply_to_link += page_number_param
reply_str = ''
reply_str: str = ''
reply_to_this_post_str = 'Reply to this post'
if translate.get(reply_to_this_post_str):
reply_to_this_post_str = translate[reply_to_this_post_str]
conversation_str = ''
conversation_str: str = ''
if conversation_id:
if isinstance(conversation_id, str):
conversation_str = '?conversationId=' + conversation_id
@ -819,7 +819,7 @@ def _get_edit_icon_html(base_dir: str, nickname: str, domain_full: str,
first_post_id: str) -> str:
"""Returns html for the edit icon/button
"""
edit_str = ''
edit_str: str = ''
actor = get_actor_from_post(post_json_object)
# This should either be a post which you created,
# or it could be generated from the newswire (see
@ -834,12 +834,12 @@ def _get_edit_icon_html(base_dir: str, nickname: str, domain_full: str,
if '/statuses/' not in post_id:
return edit_str
reply_to = ''
reply_to: str = ''
reply_id = get_reply_to(post_json_object['object'])
if reply_id:
reply_to = ';replyTo=' + reply_id
first_post_str = ''
first_post_str: str = ''
if first_post_id:
first_post_str = ';firstpost=' + first_post_id
@ -978,7 +978,7 @@ def _get_announce_icon_html(is_announced: bool,
first_post_id: str) -> str:
"""Returns html for announce icon/button at the bottom of the post
"""
announce_str = ''
announce_str: str = ''
if not show_repeat_icon:
return announce_str
@ -989,17 +989,17 @@ def _get_announce_icon_html(is_announced: bool,
# don't allow announce/repeat of your own posts
announce_icon = 'repeat_inactive.png'
announce_link = 'repeat'
announce_emoji = ''
announce_emoji: str = ''
if not is_public_repeat:
announce_link = 'repeatprivate'
repeat_this_post_str = 'Repeat this post'
if translate.get(repeat_this_post_str):
repeat_this_post_str = translate[repeat_this_post_str]
announce_title = repeat_this_post_str
unannounce_link_str = ''
unannounce_link_str: str = ''
announce_count = no_of_announces(post_json_object)
announce_count_str = ''
announce_count_str: str = ''
if announce_count > 0:
if announce_count <= max_announce_count:
announce_count_str = ' (' + str(announce_count) + ')'
@ -1009,7 +1009,7 @@ def _get_announce_icon_html(is_announced: bool,
post_actor, nickname, domain_full):
if announce_count == 1:
# announced by the reader only
announce_count_str = ''
announce_count_str: str = ''
announce_icon = 'repeat.png'
announce_emoji = '🔁 '
announce_link = 'unrepeat'
@ -1027,7 +1027,7 @@ def _get_announce_icon_html(is_announced: bool,
remove_hash_from_post_id(post_json_object['object']['id'])
announce_post_id = remove_id_ending(announce_post_id)
announce_str = ''
announce_str: str = ''
if announce_count_str:
announcers_post_id = announce_post_id.replace('/', '--')
announcers_screen_link = \
@ -1042,7 +1042,7 @@ def _get_announce_icon_html(is_announced: bool,
announce_count_str.replace('(', '').replace(')', '').strip()
announce_str += '</a></label>\n'
first_post_str = ''
first_post_str: str = ''
if first_post_id:
first_post_str = '?firstpost=' + first_post_id.replace('#', '/')
@ -1079,18 +1079,18 @@ def _get_like_icon_html(nickname: str, domain_full: str,
"""
if not show_like_button or is_moderation_post:
return ''
like_str = ''
like_str: str = ''
like_icon = 'like_inactive.png'
like_link = 'like'
like_title = 'Like this post'
if translate.get(like_title):
like_title = translate[like_title]
like_emoji = ''
like_emoji: str = ''
like_count = no_of_likes(post_json_object)
_log_post_timing(enable_timing_log, post_start_time, '12.1')
like_count_str = ''
like_count_str: str = ''
if like_count > 0:
if like_count <= max_like_count:
like_count_str = ' (' + str(like_count) + ')'
@ -1099,7 +1099,7 @@ def _get_like_icon_html(nickname: str, domain_full: str,
if liked_by_person(post_json_object, nickname, domain_full):
if like_count == 1:
# liked by the reader only
like_count_str = ''
like_count_str: str = ''
like_icon = 'like.png'
like_link = 'unlike'
like_title = 'Undo the like'
@ -1112,7 +1112,7 @@ def _get_like_icon_html(nickname: str, domain_full: str,
like_post_id = remove_hash_from_post_id(post_json_object['id'])
like_post_id = remove_id_ending(like_post_id)
like_str = ''
like_str: str = ''
if like_count_str:
likers_post_id = like_post_id.replace('/', '--')
likers_screen_link = \
@ -1129,7 +1129,7 @@ def _get_like_icon_html(nickname: str, domain_full: str,
like_str += like_count_str.replace('(', '').replace(')', '').strip()
like_str += '</a></label>\n'
first_post_str = ''
first_post_str: str = ''
if first_post_id:
first_post_str = '?firstpost=' + first_post_id.replace('#', '/')
@ -1165,7 +1165,7 @@ def _get_bookmark_icon_html(base_dir: str,
post_url: str) -> str:
"""Returns html for bookmark icon/button
"""
bookmark_str = ''
bookmark_str: str = ''
if is_moderation_post:
return bookmark_str
@ -1175,7 +1175,7 @@ def _get_bookmark_icon_html(base_dir: str,
bookmark_icon = 'bookmark_inactive.png'
bookmark_link = 'bookmark'
bookmark_emoji = ''
bookmark_emoji: str = ''
bookmark_title = 'Bookmark this post'
if translate.get(bookmark_title):
bookmark_title = translate[bookmark_title]
@ -1191,7 +1191,7 @@ def _get_bookmark_icon_html(base_dir: str,
remove_hash_from_post_id(post_json_object['object']['id'])
bookmark_post_id = remove_id_ending(bookmark_post_id)
first_post_str = ''
first_post_str: str = ''
if first_post_id:
first_post_str = '?firstpost=' + first_post_id.replace('#', '/')
@ -1224,7 +1224,7 @@ def _get_reaction_icon_html(nickname: str, post_json_object: {},
first_post_id: str) -> str:
"""Returns html for reaction icon/button
"""
reaction_str = ''
reaction_str: str = ''
if not show_reaction_button or is_moderation_post:
return reaction_str
@ -1238,7 +1238,7 @@ def _get_reaction_icon_html(nickname: str, post_json_object: {},
remove_hash_from_post_id(post_json_object['object']['id'])
reaction_post_id = remove_id_ending(reaction_post_id)
first_post_str = ''
first_post_str: str = ''
if first_post_id:
first_post_str = '?firstpost=' + first_post_id.replace('#', '/')
@ -1271,13 +1271,13 @@ def _get_mute_icon_html(is_muted: bool,
first_post_id: str) -> str:
"""Returns html for mute icon/button
"""
mute_str = ''
mute_str: str = ''
if (allow_deletion or
('/' + domain_full + '/' in post_actor and
message_id.startswith(post_actor))):
return mute_str
first_post_str = ''
first_post_str: str = ''
if first_post_id:
first_post_str = '?firstpost=' + first_post_id.replace('#', '/')
@ -1326,7 +1326,7 @@ def _get_delete_icon_html(nickname: str, domain_full: str,
first_post_id: str) -> str:
"""Returns html for delete icon/button
"""
delete_str = ''
delete_str: str = ''
if (allow_deletion or
('/' + domain_full + '/' in post_actor and
message_id.startswith(post_actor))):
@ -1336,7 +1336,7 @@ def _get_delete_icon_html(nickname: str, domain_full: str,
if translate.get(delete_this_post_str):
delete_this_post_str = translate[delete_this_post_str]
first_post_str = ''
first_post_str: str = ''
if first_post_id:
first_post_str = \
'?firstpost=' + first_post_id.replace('#', '/')
@ -1360,7 +1360,7 @@ def _get_published_date_str(post_json_object: {},
timezone: str) -> str:
"""Return the html for the published date on a post
"""
published_str = ''
published_str: str = ''
if not post_json_object['object'].get('published'):
return published_str
@ -1402,7 +1402,7 @@ def _get_blog_citations_html(box_name: str,
"""Returns blog citations as html
"""
# show blog citations
citations_str = ''
citations_str: str = ''
if box_name not in ('tlblogs', 'tlfeatures'):
return citations_str
@ -1517,8 +1517,8 @@ def _get_post_title_announce_html(base_dir: str,
"""Returns the announce title of a post containing names of participants
x announces y
"""
title_str = ''
reply_avatar_image_in_post = ''
title_str: str = ''
reply_avatar_image_in_post: str = ''
obj_json = post_json_object['object']
# has no attribution
@ -1530,7 +1530,7 @@ def _get_post_title_announce_html(base_dir: str,
attributed_to = get_attributed_to(obj_json['attributedTo'])
if attributed_to is None:
attributed_to = ''
attributed_to: str = ''
# boosting your own post
if attributed_to.startswith(post_actor):
@ -1551,7 +1551,7 @@ def _get_post_title_announce_html(base_dir: str,
announce_domain, _ = get_domain_from_actor(attributed_to)
get_person_from_cache(base_dir, attributed_to, person_cache)
announce_handle = ''
announce_handle: str = ''
if announce_nickname and announce_domain:
announce_handle = announce_nickname + '@' + announce_domain
announce_display_name = \
@ -1577,7 +1577,7 @@ def _get_post_title_announce_html(base_dir: str,
announce_display_name, False,
translate)
# add mutual icon to the display name
mutual_prefix = ''
mutual_prefix: str = ''
if announce_handle in mutuals_list:
mutual_prefix = ''
@ -1606,7 +1606,7 @@ def _get_post_title_announce_html(base_dir: str,
_log_post_timing(enable_timing_log, post_start_time, '13.4')
if not announce_avatar_url:
announce_avatar_url = ''
announce_avatar_url: str = ''
idx = 'Show options for this person'
if '/users/news/' not in announce_avatar_url:
@ -1700,7 +1700,7 @@ def _reply_with_unknown_path_html(translate: {},
post_bookmark = '#' + bookmark_from_id(post_id)
post_link = '/users/' + nickname + '?convthread=' + \
post_id.replace('--', '/') + post_bookmark
mitm_str = ''
mitm_str: str = ''
if post_domain in mitm_servers:
mitm_str = ' ' + mitm_warning_html(translate)
title_str = \
@ -1728,11 +1728,11 @@ def _get_reply_html(translate: {},
"""Returns html title for a reply
"""
# add mutual icon to the display name
mutual_prefix = ''
mutual_prefix: str = ''
if reply_handle in mutuals_list:
mutual_prefix = ''
reply_nickname = ''
reply_nickname: str = ''
if '@' in reply_nickname:
reply_nickname = reply_handle.split('@')[0]
bot_prefix = get_display_name_prefix(actor_type, reply_nickname,
@ -1781,8 +1781,8 @@ def _get_post_title_reply_html(base_dir: str,
"""Returns the reply title of a post containing names of participants
x replies to y
"""
title_str = ''
reply_avatar_image_in_post = ''
title_str: str = ''
reply_avatar_image_in_post: str = ''
obj_json = post_json_object['object']
# not a reply
@ -1877,7 +1877,7 @@ def _get_post_title_reply_html(base_dir: str,
return (title_str, reply_avatar_image_in_post,
container_class_icons, container_class)
reply_handle = ''
reply_handle: str = ''
if reply_nickname and reply_domain:
reply_handle = reply_nickname + '@' + reply_domain
get_person_from_cache(base_dir, reply_actor, person_cache)
@ -2239,7 +2239,7 @@ def _get_buy_footer(buy_links: {}, translate: {}) -> str:
return ''
icon_filename = 'buy.png'
description = translate['Buy']
buy_str = ''
buy_str: str = ''
for _, buy_url in buy_links.items():
buy_str = \
' ' + \
@ -3291,7 +3291,7 @@ def individual_post_as_html(signing_priv_key_pem: str,
translate, session,
session, session, session)
if map_str:
event_category = ''
event_category: str = ''
if category_str:
category_text = 'Category'
if translate.get('Category'):
@ -3304,7 +3304,7 @@ def individual_post_as_html(signing_priv_key_pem: str,
time_text = translate['Time']
time_span_str = \
'<br>' + time_text + ': ' + time_span_str
map_addr_str = ''
map_addr_str: str = ''
if '<br><address>' in location_str:
# append the address after the map
addrstr = location_str.split('<br><address>')[1]
@ -3391,7 +3391,7 @@ def individual_post_as_html(signing_priv_key_pem: str,
map_str += '<p>' + time_text + ': ' + time_span_str + '</p>\n'
if is_muted:
content_str = ''
content_str: str = ''
else:
if not is_patch:
message_class = 'message'
@ -3503,10 +3503,10 @@ def html_individual_post(recent_posts_cache: {}, max_recent_posts: int,
"""Show an individual post as html
"""
original_post_json = post_json_object
post_str = ''
by_str = ''
by_text = ''
by_text_extra = ''
post_str: str = ''
by_str: str = ''
by_text: str = ''
by_text_extra: str = ''
if liked_by:
by_str = liked_by
by_text = 'Liked by'
@ -3532,7 +3532,7 @@ def html_individual_post(recent_posts_cache: {}, max_recent_posts: int,
# get the list of mutuals for the current account
mutuals_list = get_mutuals_of_person(base_dir, nickname, domain)
mutual_prefix = ''
mutual_prefix: str = ''
if by_str_handle in mutuals_list:
if not text_mode_browser(ua_str):
mutual_prefix = ''
@ -3769,7 +3769,7 @@ def html_post_replies(recent_posts_cache: {}, max_recent_posts: int,
block_nostr: {}) -> str:
"""Show the replies to an individual post as html
"""
replies_str = ''
replies_str: str = ''
if replies_json.get('orderedItems'):
minimize_all_images = False
if nickname in min_images_for_accounts:
@ -3812,7 +3812,7 @@ def html_post_replies(recent_posts_cache: {}, max_recent_posts: int,
css_filename = base_dir + '/epicyon.css'
instance_title = get_config_param(base_dir, 'instanceTitle')
metadata = ''
metadata: str = ''
preload_images: list[str] = []
header_str = \
html_header_with_external_style(css_filename, instance_title, metadata,
@ -3888,7 +3888,7 @@ def html_emoji_reaction_picker(recent_posts_cache: {}, max_recent_posts: int,
if not os.path.isfile(reactions_filename):
reactions_filename = base_dir + '/emoji/default_reactions.json'
reactions_json = load_json(reactions_filename)
emoji_picks_str = ''
emoji_picks_str: str = ''
base_url = '/users/' + nickname
post_id = remove_id_ending(post_json_object['id'])
actor_url = get_actor_from_post(post_json_object)
@ -3917,7 +3917,7 @@ def html_emoji_reaction_picker(recent_posts_cache: {}, max_recent_posts: int,
get_banner_file(base_dir, nickname, domain, theme_name)
instance_title = get_config_param(base_dir, 'instanceTitle')
metadata = ''
metadata: str = ''
preload_images: list[str] = []
header_str = \
html_header_with_external_style(css_filename, instance_title, metadata,

View File

@ -167,11 +167,11 @@ def _get_profile_short_description(profile_description: str) -> str:
profile_description_short = profile_description
if '\n' in profile_description:
if len(profile_description.split('\n')) > 6:
profile_description_short = ''
profile_description_short: str = ''
else:
if '<br>' in profile_description:
if len(profile_description.split('<br>')) > 6:
profile_description_short = ''
profile_description_short: str = ''
# keep the profile description short
if len(profile_description_short) > 2048:
profile_description_short = profile_description_short[:2048]
@ -299,7 +299,7 @@ def html_profile_after_search(authorized: bool,
from_domain = i2p_domain
http = True
if yggdrasil_domain:
profile_domain = ''
profile_domain: str = ''
if '@' in profile_handle:
profile_domain = profile_handle.split('@')[1]
else:
@ -333,7 +333,7 @@ def html_profile_after_search(authorized: bool,
return None
search_domain_full = get_full_domain(search_domain, search_port)
profile_str = ''
profile_str: str = ''
css_filename = base_dir + '/epicyon-profile.css'
if os.path.isfile(base_dir + '/epicyon.css'):
css_filename = base_dir + '/epicyon.css'
@ -348,7 +348,7 @@ def html_profile_after_search(authorized: bool,
attached_shared_items = \
actor_attached_shares_as_html(profile_json, max_shares_on_profile)
avatar_url = ''
avatar_url: str = ''
if profile_json.get('icon'):
url_str = get_person_icon(profile_json)
if url_str:
@ -389,7 +389,7 @@ def html_profile_after_search(authorized: bool,
blog_url = get_blog_address(profile_json)
lxmf_address = get_lxmf_address(profile_json)
moved_to = ''
moved_to: str = ''
if profile_json.get('movedTo') or profile_json.get('copiedTo'):
if profile_json.get('movedTo'):
if not isinstance(profile_json['movedTo'], str):
@ -400,7 +400,6 @@ def html_profile_after_search(authorized: bool,
if moved_to:
if '"' in moved_to:
moved_to = moved_to.split('"')[1]
moved_to = moved_to
display_name += ''
you_follow = \
@ -416,7 +415,7 @@ def html_profile_after_search(authorized: bool,
profile_status = get_actor_status(profile_json)
if profile_status:
if actor_status_expired(profile_json['sm:status']):
profile_status = ''
profile_status: str = ''
if profile_status:
profile_status = \
remove_link_trackers_from_content(profile_status)
@ -424,7 +423,7 @@ def html_profile_after_search(authorized: bool,
add_emoji_to_display_name(session, base_dir, http_prefix,
nickname, domain,
profile_status, False, translate)
profile_description = ''
profile_description: str = ''
if profile_json.get('summary'):
if not dangerous_markup(profile_json['summary'],
False, []):
@ -447,7 +446,7 @@ def html_profile_after_search(authorized: bool,
return None
outbox_url = profile_json['outbox']
# profileBackgroundImage = ''
# profileBackgroundImage: str = ''
# if profile_json.get('image'):
# if profile_json['image'].get('url'):
# url_str = get_url_from_post(profile_json['image']['url'])
@ -461,7 +460,7 @@ def html_profile_after_search(authorized: bool,
profile_description_short = \
_get_profile_short_description(profile_description)
# remove formatting from profile description used on title
avatar_description = ''
avatar_description: str = ''
if profile_json.get('summary'):
if isinstance(profile_json['summary'], str):
avatar_description = \
@ -471,7 +470,7 @@ def html_profile_after_search(authorized: bool,
if '<' in avatar_description:
avatar_description = remove_html(avatar_description)
image_url = ''
image_url: str = ''
if profile_json.get('image'):
if profile_json['image'].get('url'):
url_str = get_url_from_post(profile_json['image']['url'])
@ -496,7 +495,7 @@ def html_profile_after_search(authorized: bool,
repo_url = get_repo_url(profile_json)
# is sending posts to this account blocked?
send_blocks_str = ''
send_blocks_str: str = ''
if sending_is_blocked2(base_dir, nickname, domain,
search_domain_full, person_url):
send_block_filename = \
@ -508,7 +507,7 @@ def html_profile_after_search(authorized: bool,
send_block_filename, False):
send_blocks_str = translate['FollowWarning']
birth_date = ''
birth_date: str = ''
if profile_json.get('vcard:bday'):
birth_date = profile_json['vcard:bday']
@ -777,7 +776,7 @@ def _get_profile_header(base_dir: str, http_prefix: str, nickname: str,
' <img loading="lazy" decoding="async" ' + \
'src="' + avatar_url + '" alt="" class="title"></a>\n'
occupation_str = ''
occupation_str: str = ''
if occupation_name:
occupation_str += \
' <b>' + occupation_name + '</b><br>\n'
@ -795,7 +794,7 @@ def _get_profile_header(base_dir: str, http_prefix: str, nickname: str,
# show if the actor is proxied
if not actor_proxied:
actor_proxied = ''
actor_proxied: str = ''
else:
actor_proxied = remove_html(actor_proxied)
if resembles_url(actor_proxied):
@ -810,7 +809,7 @@ def _get_profile_header(base_dir: str, http_prefix: str, nickname: str,
actor_proxied = ' [' + actor_proxied + ']'
# show blog icon if this account has a blog
acct_blog_str = ''
acct_blog_str: str = ''
has_blog = account_has_blog(base_dir, nickname, domain)
if has_blog:
acct_blog_str = \
@ -984,7 +983,7 @@ def _get_profile_header_after_search(base_dir: str,
display_name = search_nickname
if not actor_proxied:
actor_proxied = ''
actor_proxied: str = ''
else:
actor_proxied = remove_html(actor_proxied)
if resembles_url(actor_proxied):
@ -1241,7 +1240,7 @@ def html_profile(signing_priv_key_pem: str,
profile_status = get_actor_status(profile_json)
if profile_status:
if actor_status_expired(profile_json['sm:status']):
profile_status = ''
profile_status: str = ''
if profile_status:
profile_status = \
remove_link_trackers_from_content(profile_status)
@ -1291,16 +1290,16 @@ def html_profile(signing_priv_key_pem: str,
# shares_button = 'buttonselected'
# elif selected == 'wanted':
# wanted_button = 'buttonselected'
login_button = ''
login_button: str = ''
follow_approvals_section = ''
follow_approvals_section: str = ''
follow_approvals = False
edit_profile_str = ''
logout_str = ''
edit_profile_str: str = ''
logout_str: str = ''
actor = profile_json['id']
users_path = '/users/' + actor.split('/users/')[1]
donate_section = ''
donate_section: str = ''
donate_url = get_donation_url(profile_json)
website_url = get_website(profile_json, translate)
repo_url = get_repo_url(profile_json)
@ -1538,7 +1537,7 @@ def html_profile(signing_priv_key_pem: str,
# if so then append a new instance indicator
follower_domain, _ = \
get_domain_from_actor(follower_actor)
new_follower_domain = ''
new_follower_domain: str = ''
if follower_domain not in curr_follower_domains:
new_follower_domain = ''
@ -1580,7 +1579,7 @@ def html_profile(signing_priv_key_pem: str,
profile_description_short = \
_get_profile_short_description(profile_description)
# remove formatting from profile description used on title
avatar_description = ''
avatar_description: str = ''
if profile_json.get('summary'):
avatar_description = profile_json['summary'].replace('<br>', '\n')
replacements = {
@ -1589,7 +1588,7 @@ def html_profile(signing_priv_key_pem: str,
}
avatar_description = replace_strings(avatar_description, replacements)
moved_to = ''
moved_to: str = ''
if profile_json.get('movedTo') or profile_json.get('copiedTo'):
if profile_json.get('movedTo'):
if isinstance(profile_json['movedTo'], str):
@ -1601,7 +1600,7 @@ def html_profile(signing_priv_key_pem: str,
if '"' in moved_to:
moved_to = moved_to.split('"')[1]
else:
moved_to = ''
moved_to: str = ''
also_known_as = None
if profile_json.get('alsoKnownAs'):
@ -1641,7 +1640,7 @@ def html_profile(signing_priv_key_pem: str,
attached_shared_items = \
actor_attached_shares_as_html(profile_json, max_shares_on_profile)
birth_date = ''
birth_date: str = ''
if profile_json.get('vcard:bday'):
birth_date = profile_json['vcard:bday']
@ -1977,7 +1976,7 @@ def _html_profile_posts(recent_posts_cache: {}, max_recent_posts: int,
These should only be public posts
"""
separator_str = html_post_separator(base_dir, None)
profile_str = ''
profile_str: str = ''
max_items = max_profile_posts
ctr = 0
curr_page = 1
@ -2064,7 +2063,7 @@ def _html_profile_following(translate: {}, base_dir: str, http_prefix: str,
mitm_servers: []) -> str:
"""Shows following on the profile screen
"""
profile_str = ''
profile_str: str = ''
if authorized and page_number:
if authorized and page_number > 1:
@ -2140,7 +2139,7 @@ def _html_profile_roles(translate: {}, nickname: str, domain: str,
roles_list: []) -> str:
"""Shows roles on the profile screen
"""
profile_str = ''
profile_str: str = ''
profile_str += \
'<div class="roles">\n<div class="roles-inner">\n'
for role in roles_list:
@ -2160,7 +2159,7 @@ def _html_profile_roles(translate: {}, nickname: str, domain: str,
def _html_profile_skills(skills_json: {}) -> str:
"""Shows skills on the profile screen
"""
profile_str = ''
profile_str: str = ''
for skill, level in skills_json.items():
profile_str += \
'<div>' + skill + \
@ -2177,7 +2176,7 @@ def _html_profile_shares(actor: str, translate: {},
shares_file_type: str) -> str:
"""Shows shares on the profile screen
"""
profile_str = ''
profile_str: str = ''
for item in shares_json['orderedItems']:
profile_str += html_individual_share(domain, item['shareId'],
actor, item, translate,
@ -2274,7 +2273,7 @@ def _html_edit_profile_twitter(base_dir: str, translate: {},
'removeTwitter', remove_twitter)
twitter_replacement_domain = get_config_param(base_dir, "twitterdomain")
if not twitter_replacement_domain:
twitter_replacement_domain = ''
twitter_replacement_domain: str = ''
twitter_str += \
edit_text_field(translate['Twitter Replacement Domain'],
'twitterdomain', twitter_replacement_domain)
@ -2416,7 +2415,7 @@ def _html_edit_profile_instance(base_dir: str, translate: {},
' <b><label class="labels">'
# site moderators
moderators = ''
moderators: str = ''
moderators_file = data_dir(base_dir) + '/moderators.txt'
if os.path.isfile(moderators_file):
moderators = \
@ -2424,13 +2423,13 @@ def _html_edit_profile_instance(base_dir: str, translate: {},
'EX: _html_edit_profile_instance unable to read ' +
moderators_file)
if moderators is None:
moderators = ''
moderators: str = ''
subtitle = translate['A list of moderator nicknames. One per line.']
role_assign_str += \
edit_text_area('<b>' + translate['Moderators'] + '</b>', subtitle,
'moderators', moderators, 200, '', False)
# site editors
editors = ''
editors: str = ''
editors_file = data_dir(base_dir) + '/editors.txt'
if os.path.isfile(editors_file):
editors = \
@ -2438,14 +2437,14 @@ def _html_edit_profile_instance(base_dir: str, translate: {},
'EX: _html_edit_profile_instance unable to read ' +
editors_file)
if editors is None:
editors = ''
editors: str = ''
subtitle = translate['A list of editor nicknames. One per line.']
role_assign_str += \
edit_text_area('<b>' + translate['Site Editors'] + '</b>',
subtitle, 'editors', editors, 200, '', False)
# counselors
counselors = ''
counselors: str = ''
counselors_file = data_dir(base_dir) + '/counselors.txt'
if os.path.isfile(counselors_file):
counselors = \
@ -2453,13 +2452,13 @@ def _html_edit_profile_instance(base_dir: str, translate: {},
'EX: _html_edit_profile_instance unable to read ' +
counselors_file)
if counselors is None:
counselors = ''
counselors: str = ''
role_assign_str += \
edit_text_area('<b>' + translate['Counselors'] + '</b>', None,
'counselors', counselors, 200, '', False)
# artists
artists = ''
artists: str = ''
artists_file = data_dir(base_dir) + '/artists.txt'
if os.path.isfile(artists_file):
artists = \
@ -2467,13 +2466,13 @@ def _html_edit_profile_instance(base_dir: str, translate: {},
'EX: _html_edit_profile_instance unable to read ' +
artists_file)
if artists is None:
artists = ''
artists: str = ''
role_assign_str += \
edit_text_area('<b>' + translate['Artists'] + '</b>', None,
'artists', artists, 200, '', False)
# site devops
devops = ''
devops: str = ''
devops_file = data_dir(base_dir) + '/devops.txt'
if os.path.isfile(devops_file):
devops = \
@ -2481,7 +2480,7 @@ def _html_edit_profile_instance(base_dir: str, translate: {},
'EX: _html_edit_profile_instance unable to read ' +
devops_file)
if devops is None:
devops = ''
devops: str = ''
subtitle = translate['A list of devops nicknames. One per line.']
role_assign_str += \
edit_text_area('<b>' + translate['Site DevOps'] + '</b>',
@ -2491,7 +2490,7 @@ def _html_edit_profile_instance(base_dir: str, translate: {},
# Video section
peertube_str = begin_edit_section(translate['Video Settings'])
peertube_instances_str = ''
peertube_instances_str: str = ''
for url in peertube_instances:
peertube_instances_str += url + '\n'
peertube_str += \
@ -2501,7 +2500,7 @@ def _html_edit_profile_instance(base_dir: str, translate: {},
' <br>\n'
yt_replace_domain = get_config_param(base_dir, "youtubedomain")
if not yt_replace_domain:
yt_replace_domain = ''
yt_replace_domain: str = ''
peertube_str += \
edit_text_field(translate['YouTube Replacement Domain'],
'ytdomain', yt_replace_domain)
@ -2556,8 +2555,8 @@ def _html_edit_profile_skills(base_dir: str, nickname: str, domain: str,
"""
system_language = 'en'
skills = get_skills(base_dir, nickname, domain)
skills_str = ''
skill_ctr = 1
skills_str: str = ''
skill_ctr: int = 1
if skills:
for skill_desc, skill_value in skills.items():
if is_filtered(base_dir, nickname, domain, skill_desc,
@ -2597,7 +2596,7 @@ def _html_edit_profile_git_projects(base_dir: str, nickname: str, domain: str,
translate: {}) -> str:
"""git projects section of edit profile screen
"""
git_projects_str = ''
git_projects_str: str = ''
git_projects_filename = \
acct_dir(base_dir, nickname, domain) + '/gitprojects.txt'
if os.path.isfile(git_projects_filename):
@ -2606,7 +2605,7 @@ def _html_edit_profile_git_projects(base_dir: str, nickname: str, domain: str,
'EX: _html_edit_profile_git_projects unable to read ' +
git_projects_filename)
if git_projects_str is None:
git_projects_str = ''
git_projects_str: str = ''
edit_profile_form = begin_edit_section(translate['Git Projects'])
idx = 'List of project names that you wish to receive git patches for'
@ -2620,7 +2619,7 @@ def _html_edit_profile_git_projects(base_dir: str, nickname: str, domain: str,
def _html_edit_profile_shared_items(base_dir: str, translate: {}) -> str:
"""shared items section of edit profile screen
"""
shared_items_str = ''
shared_items_str: str = ''
shared_items_federated_domains_str = \
get_config_param(base_dir, 'sharedItemsFederatedDomains')
if shared_items_federated_domains_str:
@ -2651,7 +2650,7 @@ def _html_edit_profile_filtering(base_dir: str, nickname: str, domain: str,
debug: bool) -> str:
"""Filtering and blocking section of edit profile screen
"""
filter_str = ''
filter_str: str = ''
filter_filename = \
acct_dir(base_dir, nickname, domain) + '/filters.txt'
if os.path.isfile(filter_filename):
@ -2660,9 +2659,9 @@ def _html_edit_profile_filtering(base_dir: str, nickname: str, domain: str,
'EX: _html_edit_profile_filtering unable to read ' +
filter_filename)
if filter_str is None:
filter_str = ''
filter_str: str = ''
filter_bio_str = ''
filter_bio_str: str = ''
filter_bio_filename = \
acct_dir(base_dir, nickname, domain) + '/filters_bio.txt'
if os.path.isfile(filter_bio_filename):
@ -2671,9 +2670,9 @@ def _html_edit_profile_filtering(base_dir: str, nickname: str, domain: str,
'EX: _html_edit_profile_filtering unable to read ' +
filter_bio_filename)
if filter_bio_str is None:
filter_bio_str = ''
filter_bio_str: str = ''
switch_str = ''
switch_str: str = ''
switch_filename = \
acct_dir(base_dir, nickname, domain) + '/replacewords.txt'
if os.path.isfile(switch_filename):
@ -2682,9 +2681,9 @@ def _html_edit_profile_filtering(base_dir: str, nickname: str, domain: str,
'EX: _html_edit_profile_filtering unable to save ' +
switch_filename)
if switch_str is None:
switch_str = ''
switch_str: str = ''
auto_tags = ''
auto_tags: str = ''
auto_tags_filename = \
acct_dir(base_dir, nickname, domain) + '/autotags.txt'
if os.path.isfile(auto_tags_filename):
@ -2693,9 +2692,9 @@ def _html_edit_profile_filtering(base_dir: str, nickname: str, domain: str,
'EX: _html_edit_profile_filtering unable to read ' +
auto_tags_filename)
if auto_tags is None:
auto_tags = ''
auto_tags: str = ''
auto_cw = ''
auto_cw: str = ''
auto_cw_filename = \
acct_dir(base_dir, nickname, domain) + '/autocw.txt'
if os.path.isfile(auto_cw_filename):
@ -2704,11 +2703,11 @@ def _html_edit_profile_filtering(base_dir: str, nickname: str, domain: str,
'EX: _html_edit_profile_filtering unable to read ' +
auto_cw_filename)
if auto_cw is None:
auto_cw = ''
auto_cw: str = ''
blocked_str = get_account_blocks(base_dir, nickname, domain, debug)
dm_allowed_instances_str = ''
dm_allowed_instances_str: str = ''
dm_allowed_instances_filename = \
acct_dir(base_dir, nickname, domain) + '/dmAllowedInstances.txt'
if os.path.isfile(dm_allowed_instances_filename):
@ -2717,9 +2716,9 @@ def _html_edit_profile_filtering(base_dir: str, nickname: str, domain: str,
'EX: _html_edit_profile_filtering unable to read ' +
dm_allowed_instances_filename)
if dm_allowed_instances_str is None:
dm_allowed_instances_str = ''
dm_allowed_instances_str: str = ''
allowed_instances_str = ''
allowed_instances_str: str = ''
allowed_instances_filename = \
acct_dir(base_dir, nickname, domain) + '/allowedinstances.txt'
if os.path.isfile(allowed_instances_filename):
@ -2728,7 +2727,7 @@ def _html_edit_profile_filtering(base_dir: str, nickname: str, domain: str,
'EX: _html_edit_profile_filtering unable to read ' +
allowed_instances_filename)
if allowed_instances_str is None:
allowed_instances_str = ''
allowed_instances_str: str = ''
edit_profile_form = begin_edit_section(translate['Filtering and Blocking'])
@ -2745,7 +2744,7 @@ def _html_edit_profile_filtering(base_dir: str, nickname: str, domain: str,
translate['City for spoofed GPS image metadata'] + \
'</label><br>\n'
city = ''
city: str = ''
city_filename = acct_dir(base_dir, nickname, domain) + '/city.txt'
if os.path.isfile(city_filename):
city1 = \
@ -2769,7 +2768,7 @@ def _html_edit_profile_filtering(base_dir: str, nickname: str, domain: str,
for city_name in cities:
if ':' not in city_name:
continue
city_selected = ''
city_selected: str = ''
city_name = city_name.split(':')[0]
city_name = city_name.lower()
if city:
@ -2845,7 +2844,7 @@ def _html_edit_profile_filtering(base_dir: str, nickname: str, domain: str,
'<a href="/users/' + nickname + '/crawlers">' + \
translate['Known Web Crawlers'] + '</a><br>\n'
user_agents_blocked_str = ''
user_agents_blocked_str: str = ''
for uagent in user_agents_blocked:
if user_agents_blocked_str:
user_agents_blocked_str += '\n'
@ -2859,7 +2858,7 @@ def _html_edit_profile_filtering(base_dir: str, nickname: str, domain: str,
'<a href="/users/' + nickname + '/bots.txt">' + \
translate['Known Search Bots'] + '</a><br>\n'
crawlers_allowed_str = ''
crawlers_allowed_str: str = ''
for uagent in crawlers_allowed:
if crawlers_allowed_str:
crawlers_allowed_str += '\n'
@ -2869,7 +2868,7 @@ def _html_edit_profile_filtering(base_dir: str, nickname: str, domain: str,
'crawlersAllowedStr', crawlers_allowed_str,
200, '', False)
buy_domains_list_str = ''
buy_domains_list_str: str = ''
for buy_icon_text, buy_url in buy_sites.items():
if buy_icon_text != buy_url:
buy_domains_list_str += \
@ -2883,7 +2882,7 @@ def _html_edit_profile_filtering(base_dir: str, nickname: str, domain: str,
'buySitesStr', buy_domains_list_str,
200, '', False)
block_federated_endpoints_list_str = ''
block_federated_endpoints_list_str: str = ''
for block_api_url in block_federated_endpoints:
block_federated_endpoints_list_str += block_api_url.strip() + '\n'
block_federated_str = "Blocking API endpoints"
@ -2894,7 +2893,7 @@ def _html_edit_profile_filtering(base_dir: str, nickname: str, domain: str,
200, '', False)
robots_txt_filename = data_dir(base_dir) + '/robots.txt'
robots_txt = ''
robots_txt: str = ''
if os.path.isfile(robots_txt_filename):
new_robots_txt = \
load_string(robots_txt_filename,
@ -2942,7 +2941,7 @@ def _html_edit_profile_filtering(base_dir: str, nickname: str, domain: str,
edit_profile_form += \
edit_check_box(idx, 'blockNostr', blocknostr)
cw_lists_str = ''
cw_lists_str: str = ''
for name, list_json in cw_lists.items():
variablename = get_cw_list_variable(name)
list_is_enabled = False
@ -3118,7 +3117,7 @@ def _html_edit_notifications(base_dir: str, nickname: str, domain: str,
"""Notifications settings
"""
ntfy_url = "ntfy.sh"
ntfy_topic = ''
ntfy_topic: str = ''
ntfy_url_file = \
acct_dir(base_dir, nickname, domain) + '/.ntfy_url'
@ -3137,7 +3136,7 @@ def _html_edit_notifications(base_dir: str, nickname: str, domain: str,
'EX: _html_edit_notifications unable to read ' +
ntfy_topic_file)
if ntfy_topic is None:
ntfy_topic = ''
ntfy_topic: str = ''
edit_profile_form = begin_edit_section(translate['Notifications'])
edit_profile_form += edit_text_field(translate['ntfy URL'],
@ -3351,7 +3350,7 @@ def _get_supported_languagesSorted(base_dir: str) -> str:
if not lang_list:
return ''
lang_list.sort()
languages_str = ''
languages_str: str = ''
for lang in lang_list:
if languages_str:
languages_str += ' / ' + lang
@ -3386,7 +3385,7 @@ def _html_edit_profile_main(base_dir: str, display_nickname: str,
edit_text_area(translate['Your bio'], None, 'bio', bio_str,
200, '', True)
birth_date = ''
birth_date: str = ''
birth_date_field = 'vcard:bday'
if actor_json.get(birth_date_field):
if '-' in actor_json[birth_date_field]:
@ -3410,7 +3409,7 @@ def _html_edit_profile_main(base_dir: str, display_nickname: str,
' <input type="file" id="avatar" name="avatar"' + \
' accept="' + image_formats + '">\n'
occupation_name = ''
occupation_name: str = ''
if actor_json.get('hasOccupation'):
occupation_name = get_occupation_name(actor_json)
@ -3418,7 +3417,7 @@ def _html_edit_profile_main(base_dir: str, display_nickname: str,
edit_text_field(translate['Occupation'], 'occupationName',
occupation_name)
also_known_as_str = ''
also_known_as_str: str = ''
if actor_json.get('alsoKnownAs'):
also_known_as = actor_json['alsoKnownAs']
ctr = 0
@ -3629,14 +3628,14 @@ def html_edit_profile(server, translate: {},
actor_json['summary'].replace('<p>', '').replace('</p>', '')
if is_filtered(base_dir, nickname, domain, bio_str,
system_language):
bio_str = ''
bio_str: str = ''
bio_str = remove_html(bio_str)
if actor_json.get('manuallyApprovesFollowers'):
if actor_json['manuallyApprovesFollowers']:
manually_approves_followers = 'checked'
else:
manually_approves_followers = ''
reject_spam_actors = ''
manually_approves_followers: str = ''
reject_spam_actors: str = ''
actor_spam_filter_filename = \
acct_dir(base_dir, nickname, domain) + '/.reject_spam_actors'
if os.path.isfile(actor_spam_filter_filename):
@ -3644,10 +3643,10 @@ def html_edit_profile(server, translate: {},
if actor_json.get('type'):
if actor_json['type'] == 'Service':
is_bot = 'checked'
is_group = ''
is_group: str = ''
elif actor_json['type'] == 'Group':
is_group = 'checked'
is_bot = ''
is_bot: str = ''
account_dir = acct_dir(base_dir, nickname, domain)
if os.path.isfile(account_dir + '/.followDMs'):
follow_dms = 'checked'
@ -3684,14 +3683,14 @@ def html_edit_profile(server, translate: {},
if os.path.isfile(base_dir + '/epicyon.css'):
css_filename = base_dir + '/epicyon.css'
instance_str = ''
role_assign_str = ''
peertube_str = ''
libretranslate_str = ''
memorial_str = ''
system_monitor_str = ''
graphics_str = ''
shares_federation_str = ''
instance_str: str = ''
role_assign_str: str = ''
peertube_str: str = ''
libretranslate_str: str = ''
memorial_str: str = ''
system_monitor_str: str = ''
graphics_str: str = ''
shares_federation_str: str = ''
admin_nickname = get_config_param(base_dir, 'admin')
@ -3996,7 +3995,7 @@ def _individual_follow_as_html(signing_priv_key_pem: str,
elif dormant:
title_str += ' 💤'
buttons_str = ''
buttons_str: str = ''
if authorized:
for btn in buttons:
if btn == 'block':

View File

@ -42,7 +42,7 @@ def get_pwa_theme_colors(css_filename: str) -> (str, str):
'EX: get_pwa_theme_colors unable to read ' +
css_filename)
if css_str is None:
css_str = ''
css_str: str = ''
pwa_theme_color = \
_get_variable_from_css(css_str, 'pwa-theme-color')

View File

@ -27,7 +27,7 @@ def insert_question(base_dir: str, translate: {},
message_id = remove_id_ending(post_json_object['id'])
if '#' in message_id:
message_id = message_id.split('#', 1)[0]
page_number_str = ''
page_number_str: str = ''
if page_number:
page_number_str = '?page=' + str(page_number)