diff --git a/utils.py b/utils.py
index a62205c35..3954852ab 100644
--- a/utils.py
+++ b/utils.py
@@ -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 = {
'&': '&',
'': '',
'': ''
@@ -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:
'
': '\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
diff --git a/webapp_about.py b/webapp_about.py
index f7c19bf65..269aa5ae1 100644
--- a/webapp_about.py
+++ b/webapp_about.py
@@ -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'
diff --git a/webapp_accesskeys.py b/webapp_accesskeys.py
index 5acdebc11..c60265d38 100644
--- a/webapp_accesskeys.py
+++ b/webapp_accesskeys.py
@@ -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'
diff --git a/webapp_calendar.py b/webapp_calendar.py
index 25e96c55e..5a8bfe400 100644
--- a/webapp_calendar.py
+++ b/webapp_calendar.py
@@ -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 = \
'
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,
' \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 += \
''
@@ -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 += \
' '
@@ -565,13 +565,13 @@ def html_edit_links(translate: {}, base_dir: str, path: str,
' '
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 += \
' '
@@ -587,14 +587,14 @@ def html_edit_links(translate: {}, base_dir: str, path: str,
' '
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 += \
' '
diff --git a/webapp_column_right.py b/webapp_column_right.py
index a638c4002..93552d6c4 100644
--- a/webapp_column_right.py
+++ b/webapp_column_right.py
@@ -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 += ' ' + publish_button_str + ''
# 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 += ' '
html_str += date_shown + '\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'] + ' '
if blog_title is None:
- blog_title = ''
+ blog_title: str = ''
html_str += \
' \n'
if blog_content is None:
- blog_content = ''
+ blog_content: str = ''
html_str += \
' \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,
' \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 += \
' '
@@ -661,7 +661,7 @@ def html_edit_newswire(translate: {}, base_dir: str, path: str,
'style="height:80vh" spellcheck="false">' + \
newswire_str + ''
- 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 += \
' \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 += ' \n'
citations_str += ' \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="" />\n' + \
'\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,
diff --git a/webapp_frontscreen.py b/webapp_frontscreen.py
index 84b412008..329858b1b 100644
--- a/webapp_frontscreen.py
+++ b/webapp_frontscreen.py
@@ -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 += \
diff --git a/webapp_hashtagswarm.py b/webapp_hashtagswarm.py
index 21bc29616..301e4931c 100644
--- a/webapp_hashtagswarm.py
+++ b/webapp_hashtagswarm.py
@@ -67,7 +67,7 @@ def get_hashtag_categories_feed(base_dir: str,
rss_str += \
'- \n' + \
' ' + escape_text(category_str) + '\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 += '
\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,
diff --git a/webapp_headerbuttons.py b/webapp_headerbuttons.py
index a09893162..6b118c074 100644
--- a/webapp_headerbuttons.py
+++ b/webapp_headerbuttons.py
@@ -197,7 +197,7 @@ def header_buttons_timeline(default_timeline: str,
translate['Inbox'] + ''
# 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)
diff --git a/webapp_likers.py b/webapp_likers.py
index 85bcafd2a..ed1337257 100644
--- a/webapp_likers.py
+++ b/webapp_likers.py
@@ -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:
diff --git a/webapp_login.py b/webapp_login.py
index a3613e809..17edd9b14 100644
--- a/webapp_login.py
+++ b/webapp_login.py
@@ -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: {},
'' + \
translate['Terms of Service'] + ' '
- login_button_str = ''
+ login_button_str: str = ''
if accounts > 0:
login_button_str = \
' |