Variable types

main
bashrc 2026-04-27 21:27:54 +01:00
parent c0379dfda2
commit 7154baeff4
44 changed files with 223 additions and 222 deletions

10
auth.py
View File

@ -203,7 +203,7 @@ def store_basic_credentials(base_dir: str,
return False return False
# create the altered passwords list # create the altered passwords list
passwords_list_new = '' passwords_list_new: str = ''
for login_str in passwords_list: for login_str in passwords_list:
if not login_str.startswith(nickname + ':'): if not login_str.startswith(nickname + ':'):
passwords_list_new += login_str passwords_list_new += login_str
@ -250,7 +250,7 @@ def remove_password(base_dir: str, nickname: str) -> None:
return return
# create the new passwords file # create the new passwords file
passwords_list_new = '' passwords_list_new: str = ''
account_found = False account_found = False
for login_str in passwords_list: for login_str in passwords_list:
if not login_str.startswith(nickname + ':'): if not login_str.startswith(nickname + ':'):
@ -260,18 +260,18 @@ def remove_password(base_dir: str, nickname: str) -> None:
if not account_found: if not account_found:
# the account doesn't exist # the account doesn't exist
passwords_list.clear() passwords_list.clear()
passwords_list_new = '' passwords_list_new: str = ''
return return
# save the new passwords file # save the new passwords file
if not save_string(passwords_list_new, password_file + '.new', if not save_string(passwords_list_new, password_file + '.new',
'EX: unable to remove password from file [ex]'): 'EX: unable to remove password from file [ex]'):
passwords_list.clear() passwords_list.clear()
passwords_list_new = '' passwords_list_new: str = ''
return return
passwords_list.clear() passwords_list.clear()
passwords_list_new = '' passwords_list_new: str = ''
try: try:
os.rename(password_file + '.new', password_file) os.rename(password_file + '.new', password_file)

View File

@ -458,7 +458,7 @@ def _remove_global_block_reason(base_dir: str,
load_string(unblocking_filename, load_string(unblocking_filename,
'EX: unable to read blocking reasons 3') 'EX: unable to read blocking reasons 3')
if reasons_str is None: if reasons_str is None:
reasons_str = '' reasons_str: str = ''
reasons_lines = reasons_str.split('\n') reasons_lines = reasons_str.split('\n')
new_reasons_str: str = '' new_reasons_str: str = ''
for line in reasons_lines: for line in reasons_lines:
@ -936,7 +936,7 @@ def allowed_announce_add(base_dir: str, nickname: str, domain: str,
'EX: unable to read noannounce add: ' + 'EX: unable to read noannounce add: ' +
blocking_filename + ' ' + handle) blocking_filename + ' ' + handle)
if file_text is None: if file_text is None:
file_text = '' file_text: str = ''
new_file_text: str = '' new_file_text: str = ''
file_text_list = file_text.split('\n') file_text_list = file_text.split('\n')
@ -974,7 +974,7 @@ def allowed_announce_remove(base_dir: str, nickname: str, domain: str,
'EX: unable to read noannounce remove: ' + 'EX: unable to read noannounce remove: ' +
blocking_filename + ' ' + handle) blocking_filename + ' ' + handle)
if file_text is None: if file_text is None:
file_text = '' file_text: str = ''
file_text += handle + '\n' file_text += handle + '\n'
save_string(file_text, blocking_filename, save_string(file_text, blocking_filename,
'EX: unable to write noannounce: ' + 'EX: unable to write noannounce: ' +
@ -1000,7 +1000,7 @@ def blocked_quote_toots_add(base_dir: str, nickname: str, domain: str,
'EX: unable to read quotesblocked add: ' + 'EX: unable to read quotesblocked add: ' +
blocking_filename + ' ' + handle) blocking_filename + ' ' + handle)
if file_text is None: if file_text is None:
file_text = '' file_text: str = ''
file_text += handle + '\n' file_text += handle + '\n'
save_string(file_text, blocking_filename, save_string(file_text, blocking_filename,
@ -1027,7 +1027,7 @@ def blocked_quote_toots_remove(base_dir: str, nickname: str, domain: str,
'EX: unable to read quotesblocked remove: ' + 'EX: unable to read quotesblocked remove: ' +
blocking_filename + ' ' + handle) blocking_filename + ' ' + handle)
if file_text is None: if file_text is None:
file_text = '' file_text: str = ''
file_text = file_text.replace(handle + '\n', '') file_text = file_text.replace(handle + '\n', '')
save_string(file_text, blocking_filename, save_string(file_text, blocking_filename,
'EX: unable to write quotesblocked remove: ' + 'EX: unable to write quotesblocked remove: ' +
@ -1738,14 +1738,14 @@ def import_blocking_file(base_dir: str, nickname: str, domain: str,
if not append_blocks: if not append_blocks:
return True return True
text = '' text: str = ''
for new_block in append_blocks: for new_block in append_blocks:
text += new_block + '\n' text += new_block + '\n'
append_string(text, blocking_filename, append_string(text, blocking_filename,
'EX: ' + 'EX: ' +
'unable to append imported blocks to ' + 'unable to append imported blocks to ' +
blocking_filename) blocking_filename)
text = '' text: str = ''
for new_reason in append_reasons: for new_reason in append_reasons:
text += new_reason + '\n' text += new_reason + '\n'
append_string(text, blocking_reasons_filename, append_string(text, blocking_reasons_filename,

10
blog.py
View File

@ -206,7 +206,7 @@ def html_blog_post_gemini_links(content: str) -> str:
return content return content
ctr = 0 ctr = 0
sections = content.split('=> ') sections = content.split('=> ')
new_content = '' new_content: str = ''
for section in sections: for section in sections:
if ctr == 0: if ctr == 0:
new_content = section new_content = section
@ -231,8 +231,8 @@ def html_blog_post_gemini_links(content: str) -> str:
after_web_link = section.split(end_character, 1)[1] after_web_link = section.split(end_character, 1)[1]
else: else:
after_web_link = section.split(web_link_str, 1)[1] after_web_link = section.split(web_link_str, 1)[1]
after_str = '' after_str: str = ''
after_link_str = '' after_link_str: str = ''
if '<' in after_web_link: if '<' in after_web_link:
after_str = after_web_link.split('<', 1)[0] after_str = after_web_link.split('<', 1)[0]
after_link_str = '<' + after_web_link.split('<', 1)[1] after_link_str = '<' + after_web_link.split('<', 1)[1]
@ -241,7 +241,7 @@ def html_blog_post_gemini_links(content: str) -> str:
after_link_str = '\n' + after_web_link.split('\n', 1)[1] after_link_str = '\n' + after_web_link.split('\n', 1)[1]
else: else:
after_str = after_web_link after_str = after_web_link
after_link_str = '' after_link_str: str = ''
after_str = after_str.strip() after_str = after_str.strip()
after_link_str = after_link_str.strip() after_link_str = after_link_str.strip()
if is_image_file(web_link_str) and \ if is_image_file(web_link_str) and \
@ -278,7 +278,7 @@ def html_blog_post_markdown(content: str) -> str:
continue continue
sections = new_content.split(markdown_text) sections = new_content.split(markdown_text)
ctr = 0 ctr = 0
new_content2 = '' new_content2: str = ''
for section in sections: for section in sections:
if ctr == 0: if ctr == 0:
new_content2 = section new_content2 = section

View File

@ -453,7 +453,7 @@ def _update_common_emoji(base_dir: str, emoji_content: str) -> None:
new_common_emoji.append(str(1).zfill(16) + ' ' + emoji_content) new_common_emoji.append(str(1).zfill(16) + ' ' + emoji_content)
new_common_emoji.sort(reverse=True) new_common_emoji.sort(reverse=True)
text = '' text: str = ''
for line in new_common_emoji: for line in new_common_emoji:
text += line + '\n' text += line + '\n'
if not save_string(text, common_emoji_filename, if not save_string(text, common_emoji_filename,
@ -1833,8 +1833,8 @@ def save_media_in_form_post(media_bytes, debug: bool,
def combine_textarea_lines(text: str) -> str: def combine_textarea_lines(text: str) -> str:
"""Combines separate lines """Combines separate lines
""" """
result = '' result: str = ''
ctr = 0 ctr: int = 0
paragraphs = text.split('\n\n') paragraphs = text.split('\n\n')
replacements = { replacements = {
'\n* ': '***BULLET POINT*** ', '\n* ': '***BULLET POINT*** ',
@ -1953,7 +1953,7 @@ def limit_repeated_words(text: str, max_repeats: int) -> str:
new_text = ((prev_word + ' ') * max_repeats).strip() new_text = ((prev_word + ' ') * max_repeats).strip()
replacements[prev_word] = [repeated_text, new_text] replacements[prev_word] = [repeated_text, new_text]
repeat_ctr = 0 repeat_ctr = 0
repeated_text = '' repeated_text: str = ''
prev_word = word prev_word = word
if repeat_ctr > max_repeats: if repeat_ctr > max_repeats:

View File

@ -348,7 +348,7 @@ class EpicyonServer(ThreadingHTTPServer):
signing_priv_key_pem = None signing_priv_key_pem = None
show_node_info_accounts: bool = False show_node_info_accounts: bool = False
show_node_info_version: bool = False show_node_info_version: bool = False
text_mode_banner = '' text_mode_banner: str = ''
access_keys = {} access_keys = {}
rss_timeout_sec = 20 rss_timeout_sec = 20
check_actor_timeout = 2 check_actor_timeout = 2
@ -375,7 +375,7 @@ class EpicyonServer(ThreadingHTTPServer):
blogs_instance: bool = False blogs_instance: bool = False
translate = {} translate = {}
system_language: str = 'en' system_language: str = 'en'
city = '' city: str = ''
voting_time_mins = 30 voting_time_mins = 30
positive_voting: bool = False positive_voting: bool = False
newswire_votes_threshold = 1 newswire_votes_threshold = 1

View File

@ -756,7 +756,7 @@ def daemon_http_get(self) -> None:
('/private_account_notes/' in self.path or ('/private_account_notes/' in self.path or
self.path.endswith('/private_account_notes'))): self.path.endswith('/private_account_notes'))):
nickname = get_nickname_from_actor(self.path) nickname = get_nickname_from_actor(self.path)
handle = '' handle: str = ''
if '/private_account_notes/' in self.path: if '/private_account_notes/' in self.path:
handle = self.path.split('/private_account_notes/', 1)[1] handle = self.path.split('/private_account_notes/', 1)[1]
if nickname: if nickname:
@ -785,7 +785,7 @@ def daemon_http_get(self) -> None:
return return
if authorized and self.path.endswith('/bots.txt'): if authorized and self.path.endswith('/bots.txt'):
known_bots_str = '' known_bots_str: str = ''
for bot_name in self.server.known_bots: for bot_name in self.server.known_bots:
known_bots_str += bot_name + '\n' known_bots_str += bot_name + '\n'
msg = known_bots_str.encode('utf-8') msg = known_bots_str.encode('utf-8')
@ -2066,7 +2066,7 @@ def daemon_http_get(self) -> None:
item_id = self.path.split('?showshare=')[1] item_id = self.path.split('?showshare=')[1]
if '?' in item_id: if '?' in item_id:
item_id = item_id.split('?')[0] item_id = item_id.split('?')[0]
category = '' category: str = ''
if '?category=' in self.path: if '?category=' in self.path:
category = self.path.split('?category=')[1] category = self.path.split('?category=')[1]
if '?' in category: if '?' in category:
@ -4286,7 +4286,7 @@ def daemon_http_get(self) -> None:
in_reply_to_url = None in_reply_to_url = None
reply_to_list: list[str] = [] reply_to_list: list[str] = []
reply_page_number = 1 reply_page_number = 1
reply_category = '' reply_category: str = ''
share_description = None share_description = None
conversation_id = None conversation_id = None
convthread_id = None convthread_id = None
@ -6599,7 +6599,7 @@ def _show_known_crawlers(self, calling_domain: str, path: str,
hits_str = str(item['hits']).zfill(8) hits_str = str(item['hits']).zfill(8)
crawlers_list.append(hits_str + ' ' + ua_str) crawlers_list.append(hits_str + ' ' + ua_str)
crawlers_list.sort(reverse=True) crawlers_list.sort(reverse=True)
msg = '' msg: str = ''
for line_str in crawlers_list: for line_str in crawlers_list:
msg += line_str + '\n' msg += line_str + '\n'
msg = msg.encode('utf-8') msg = msg.encode('utf-8')

View File

@ -82,14 +82,14 @@ def announce_button(self, calling_domain: str, path: str,
repeat_url = path.split('?repeat=')[1] repeat_url = path.split('?repeat=')[1]
if '?' in repeat_url: if '?' in repeat_url:
repeat_url = repeat_url.split('?')[0] repeat_url = repeat_url.split('?')[0]
first_post_id = '' first_post_id: str = ''
if '?firstpost=' in path: if '?firstpost=' in path:
first_post_id = path.split('?firstpost=')[1] first_post_id = path.split('?firstpost=')[1]
if '?' in first_post_id: if '?' in first_post_id:
first_post_id = first_post_id.split('?')[0] first_post_id = first_post_id.split('?')[0]
first_post_id = first_post_id.replace('/', '--') first_post_id = first_post_id.replace('/', '--')
first_post_id = ';firstpost=' + first_post_id.replace('#', '--') first_post_id = ';firstpost=' + first_post_id.replace('#', '--')
timeline_bookmark = '' timeline_bookmark: str = ''
if '?bm=' in path: if '?bm=' in path:
timeline_bookmark = path.split('?bm=')[1] timeline_bookmark = path.split('?bm=')[1]
if '?' in timeline_bookmark: if '?' in timeline_bookmark:
@ -323,7 +323,7 @@ def announce_button_undo(self, calling_domain: str, path: str,
if '?' in repeat_url: if '?' in repeat_url:
repeat_url = repeat_url.split('?')[0] repeat_url = repeat_url.split('?')[0]
first_post_id = '' first_post_id: str = ''
if '?firstpost=' in path: if '?firstpost=' in path:
first_post_id = path.split('?firstpost=')[1] first_post_id = path.split('?firstpost=')[1]
if '?' in first_post_id: if '?' in first_post_id:
@ -331,7 +331,7 @@ def announce_button_undo(self, calling_domain: str, path: str,
first_post_id = first_post_id.replace('/', '--') first_post_id = first_post_id.replace('/', '--')
first_post_id = ';firstpost=' + first_post_id.replace('#', '--') first_post_id = ';firstpost=' + first_post_id.replace('#', '--')
timeline_bookmark = '' timeline_bookmark: str = ''
if '?bm=' in path: if '?bm=' in path:
timeline_bookmark = path.split('?bm=')[1] timeline_bookmark = path.split('?bm=')[1]
if '?' in timeline_bookmark: if '?' in timeline_bookmark:

View File

@ -77,14 +77,14 @@ def bookmark_button(self, calling_domain: str, path: str,
bookmark_url = path.split('?bookmark=')[1] bookmark_url = path.split('?bookmark=')[1]
if '?' in bookmark_url: if '?' in bookmark_url:
bookmark_url = bookmark_url.split('?')[0] bookmark_url = bookmark_url.split('?')[0]
first_post_id = '' first_post_id: str = ''
if '?firstpost=' in path: if '?firstpost=' in path:
first_post_id = path.split('?firstpost=')[1] first_post_id = path.split('?firstpost=')[1]
if '?' in first_post_id: if '?' in first_post_id:
first_post_id = first_post_id.split('?')[0] first_post_id = first_post_id.split('?')[0]
first_post_id = first_post_id.replace('/', '--') first_post_id = first_post_id.replace('/', '--')
first_post_id = ';firstpost=' + first_post_id.replace('#', '--') first_post_id = ';firstpost=' + first_post_id.replace('#', '--')
timeline_bookmark = '' timeline_bookmark: str = ''
if '?bm=' in path: if '?bm=' in path:
timeline_bookmark = path.split('?bm=')[1] timeline_bookmark = path.split('?bm=')[1]
if '?' in timeline_bookmark: if '?' in timeline_bookmark:
@ -305,14 +305,14 @@ def bookmark_button_undo(self, calling_domain: str, path: str,
bookmark_url = path.split('?unbookmark=')[1] bookmark_url = path.split('?unbookmark=')[1]
if '?' in bookmark_url: if '?' in bookmark_url:
bookmark_url = bookmark_url.split('?')[0] bookmark_url = bookmark_url.split('?')[0]
first_post_id = '' first_post_id: str = ''
if '?firstpost=' in path: if '?firstpost=' in path:
first_post_id = path.split('?firstpost=')[1] first_post_id = path.split('?firstpost=')[1]
if '?' in first_post_id: if '?' in first_post_id:
first_post_id = first_post_id.split('?')[0] first_post_id = first_post_id.split('?')[0]
first_post_id = first_post_id.replace('/', '--') first_post_id = first_post_id.replace('/', '--')
first_post_id = ';firstpost=' + first_post_id.replace('#', '--') first_post_id = ';firstpost=' + first_post_id.replace('#', '--')
timeline_bookmark = '' timeline_bookmark: str = ''
if '?bm=' in path: if '?bm=' in path:
timeline_bookmark = path.split('?bm=')[1] timeline_bookmark = path.split('?bm=')[1]
if '?' in timeline_bookmark: if '?' in timeline_bookmark:

View File

@ -79,14 +79,14 @@ def like_button(self, calling_domain: str, path: str,
like_url = path.split('?like=')[1] like_url = path.split('?like=')[1]
if '?' in like_url: if '?' in like_url:
like_url = like_url.split('?')[0] like_url = like_url.split('?')[0]
first_post_id = '' first_post_id: str = ''
if '?firstpost=' in path: if '?firstpost=' in path:
first_post_id = path.split('?firstpost=')[1] first_post_id = path.split('?firstpost=')[1]
if '?' in first_post_id: if '?' in first_post_id:
first_post_id = first_post_id.split('?')[0] first_post_id = first_post_id.split('?')[0]
first_post_id = first_post_id.replace('/', '--') first_post_id = first_post_id.replace('/', '--')
first_post_id = ';firstpost=' + first_post_id.replace('#', '--') first_post_id = ';firstpost=' + first_post_id.replace('#', '--')
timeline_bookmark = '' timeline_bookmark: str = ''
if '?bm=' in path: if '?bm=' in path:
timeline_bookmark = path.split('?bm=')[1] timeline_bookmark = path.split('?bm=')[1]
if '?' in timeline_bookmark: if '?' in timeline_bookmark:
@ -359,14 +359,14 @@ def like_button_undo(self, calling_domain: str, path: str,
like_url = path.split('?unlike=')[1] like_url = path.split('?unlike=')[1]
if '?' in like_url: if '?' in like_url:
like_url = like_url.split('?')[0] like_url = like_url.split('?')[0]
first_post_id = '' first_post_id: str = ''
if '?firstpost=' in path: if '?firstpost=' in path:
first_post_id = path.split('?firstpost=')[1] first_post_id = path.split('?firstpost=')[1]
if '?' in first_post_id: if '?' in first_post_id:
first_post_id = first_post_id.split('?')[0] first_post_id = first_post_id.split('?')[0]
first_post_id = first_post_id.replace('/', '--') first_post_id = first_post_id.replace('/', '--')
first_post_id = ';firstpost=' + first_post_id.replace('#', '--') first_post_id = ';firstpost=' + first_post_id.replace('#', '--')
timeline_bookmark = '' timeline_bookmark: str = ''
if '?bm=' in path: if '?bm=' in path:
timeline_bookmark = path.split('?bm=')[1] timeline_bookmark = path.split('?bm=')[1]
if '?' in timeline_bookmark: if '?' in timeline_bookmark:

View File

@ -67,14 +67,14 @@ def mute_button(self, calling_domain: str, path: str,
mute_url = path.split('?mute=')[1] mute_url = path.split('?mute=')[1]
if '?' in mute_url: if '?' in mute_url:
mute_url = mute_url.split('?')[0] mute_url = mute_url.split('?')[0]
first_post_id = '' first_post_id: str = ''
if '?firstpost=' in path: if '?firstpost=' in path:
first_post_id = path.split('?firstpost=')[1] first_post_id = path.split('?firstpost=')[1]
if '?' in first_post_id: if '?' in first_post_id:
first_post_id = first_post_id.split('?')[0] first_post_id = first_post_id.split('?')[0]
first_post_id = first_post_id.replace('/', '--') first_post_id = first_post_id.replace('/', '--')
first_post_id = ';firstpost=' + first_post_id.replace('#', '--') first_post_id = ';firstpost=' + first_post_id.replace('#', '--')
timeline_bookmark = '' timeline_bookmark: str = ''
if '?bm=' in path: if '?bm=' in path:
timeline_bookmark = path.split('?bm=')[1] timeline_bookmark = path.split('?bm=')[1]
if '?' in timeline_bookmark: if '?' in timeline_bookmark:
@ -257,14 +257,14 @@ def mute_button_undo(self, calling_domain: str, path: str,
mute_url = path.split('?unmute=')[1] mute_url = path.split('?unmute=')[1]
if '?' in mute_url: if '?' in mute_url:
mute_url = mute_url.split('?')[0] mute_url = mute_url.split('?')[0]
first_post_id = '' first_post_id: str = ''
if '?firstpost=' in path: if '?firstpost=' in path:
first_post_id = path.split('?firstpost=')[1] first_post_id = path.split('?firstpost=')[1]
if '?' in first_post_id: if '?' in first_post_id:
first_post_id = first_post_id.split('?')[0] first_post_id = first_post_id.split('?')[0]
first_post_id = first_post_id.replace('/', '--') first_post_id = first_post_id.replace('/', '--')
first_post_id = ';firstpost=' + first_post_id.replace('#', '--') first_post_id = ';firstpost=' + first_post_id.replace('#', '--')
timeline_bookmark = '' timeline_bookmark: str = ''
if '?bm=' in path: if '?bm=' in path:
timeline_bookmark = path.split('?bm=')[1] timeline_bookmark = path.split('?bm=')[1]
if '?' in timeline_bookmark: if '?' in timeline_bookmark:

View File

@ -80,14 +80,14 @@ def reaction_button(self, calling_domain: str, path: str,
reaction_url = path.split('?react=')[1] reaction_url = path.split('?react=')[1]
if '?' in reaction_url: if '?' in reaction_url:
reaction_url = reaction_url.split('?')[0] reaction_url = reaction_url.split('?')[0]
first_post_id = '' first_post_id: str = ''
if '?firstpost=' in path: if '?firstpost=' in path:
first_post_id = path.split('?firstpost=')[1] first_post_id = path.split('?firstpost=')[1]
if '?' in first_post_id: if '?' in first_post_id:
first_post_id = first_post_id.split('?')[0] first_post_id = first_post_id.split('?')[0]
first_post_id = first_post_id.replace('/', '--') first_post_id = first_post_id.replace('/', '--')
first_post_id = ';firstpost=' + first_post_id.replace('#', '--') first_post_id = ';firstpost=' + first_post_id.replace('#', '--')
timeline_bookmark = '' timeline_bookmark: str = ''
if '?bm=' in path: if '?bm=' in path:
timeline_bookmark = path.split('?bm=')[1] timeline_bookmark = path.split('?bm=')[1]
if '?' in timeline_bookmark: if '?' in timeline_bookmark:
@ -386,14 +386,14 @@ def reaction_button_undo(self, calling_domain: str, path: str,
reaction_url = path.split('?unreact=')[1] reaction_url = path.split('?unreact=')[1]
if '?' in reaction_url: if '?' in reaction_url:
reaction_url = reaction_url.split('?')[0] reaction_url = reaction_url.split('?')[0]
first_post_id = '' first_post_id: str = ''
if '?firstpost=' in path: if '?firstpost=' in path:
first_post_id = path.split('?firstpost=')[1] first_post_id = path.split('?firstpost=')[1]
if '?' in first_post_id: if '?' in first_post_id:
first_post_id = first_post_id.split('?')[0] first_post_id = first_post_id.split('?')[0]
first_post_id = first_post_id.replace('/', '--') first_post_id = first_post_id.replace('/', '--')
first_post_id = ';firstpost=' + first_post_id.replace('#', '--') first_post_id = ';firstpost=' + first_post_id.replace('#', '--')
timeline_bookmark = '' timeline_bookmark: str = ''
if '?bm=' in path: if '?bm=' in path:
timeline_bookmark = path.split('?bm=')[1] timeline_bookmark = path.split('?bm=')[1]
if '?' in timeline_bookmark: if '?' in timeline_bookmark:

View File

@ -498,7 +498,7 @@ def show_new_post(self, edit_post_params: {},
nickname, nickname,
domain_full, domain_full,
person_cache) person_cache)
default_buy_site = '' default_buy_site: str = ''
msg = \ msg = \
html_new_post(edit_post_params, media_instance, html_new_post(edit_post_params, media_instance,
translate, translate,

View File

@ -53,11 +53,11 @@ def reaction_picker2(self, calling_domain: str, path: str,
instance_software: {}) -> None: instance_software: {}) -> None:
"""Press the emoji reaction picker icon at the bottom of the post """Press the emoji reaction picker icon at the bottom of the post
""" """
page_number = 1 page_number: int = 1
reaction_url = path.split('?selreact=')[1] reaction_url = path.split('?selreact=')[1]
if '?' in reaction_url: if '?' in reaction_url:
reaction_url = reaction_url.split('?')[0] reaction_url = reaction_url.split('?')[0]
timeline_bookmark = '' timeline_bookmark: str = ''
if '?bm=' in path: if '?bm=' in path:
timeline_bookmark = path.split('?bm=')[1] timeline_bookmark = path.split('?bm=')[1]
if '?' in timeline_bookmark: if '?' in timeline_bookmark:

View File

@ -97,7 +97,7 @@ def get_rss2site(self, calling_domain: str, path: str,
http_404(self, 23) http_404(self, 23)
return return
msg = '' msg: str = ''
dir_str = data_dir(base_dir) dir_str = data_dir(base_dir)
for _, dirs, _ in os.walk(dir_str): for _, dirs, _ in os.walk(dir_str):
for acct in dirs: for acct in dirs:

View File

@ -1739,7 +1739,7 @@ def show_mod_timeline(self, authorized: bool,
True, True,
0, positive_voting, 0, positive_voting,
voting_time_mins) voting_time_mins)
moderation_action_str = '' moderation_action_str: str = ''
if key_shortcuts.get(nickname): if key_shortcuts.get(nickname):
access_keys = key_shortcuts[nickname] access_keys = key_shortcuts[nickname]

View File

@ -36,7 +36,7 @@ def set_hashtag_category2(self, calling_domain: str, cookie: str,
the category for that tag the category for that tag
""" """
users_path = path.replace('/sethashtagcategory', '') users_path = path.replace('/sethashtagcategory', '')
hashtag = '' hashtag: str = ''
if '/tags/' not in users_path: if '/tags/' not in users_path:
# no hashtag is specified within the path # no hashtag is specified within the path
http_404(self, 14) http_404(self, 14)

View File

@ -229,7 +229,7 @@ def post_login_screen(self, calling_domain: str, cookie: str,
login_str = login_params login_str = login_params
if '=' in login_params: if '=' in login_params:
login_params_list = login_params.split('=') login_params_list = login_params.split('=')
login_str = '' login_str: str = ''
skip_param = False skip_param = False
for login_prm in login_params_list: for login_prm in login_params_list:
if not skip_param: if not skip_param:
@ -238,7 +238,7 @@ def post_login_screen(self, calling_domain: str, cookie: str,
len_str = login_prm.split('&')[0] len_str = login_prm.split('&')[0]
if len_str: if len_str:
login_str += login_prm + '*' login_str += login_prm + '*'
len_str = '' len_str: str = ''
if '&' in login_prm: if '&' in login_prm:
login_str += \ login_str += \
'&' + login_prm.split('&')[1] + '=' '&' + login_prm.split('&')[1] + '='

View File

@ -128,9 +128,9 @@ def moderator_actions(self, path: str, calling_domain: str, cookie: str,
search_handle = \ search_handle = \
search_nickname + '@' + search_domain search_nickname + '@' + search_domain
else: else:
search_handle = '' search_handle: str = ''
else: else:
search_handle = '' search_handle: str = ''
if '@' not in search_handle or \ if '@' not in search_handle or \
'/@/' in search_handle: '/@/' in search_handle:
if string_starts_with(search_handle, if string_starts_with(search_handle,
@ -145,9 +145,9 @@ def moderator_actions(self, path: str, calling_domain: str, cookie: str,
search_nickname + '@' + \ search_nickname + '@' + \
search_domain search_domain
else: else:
search_handle = '' search_handle: str = ''
else: else:
search_handle = '' search_handle: str = ''
if '@' not in search_handle: if '@' not in search_handle:
# is this a local nickname on this instance? # is this a local nickname on this instance?
local_handle = \ local_handle = \
@ -156,9 +156,9 @@ def moderator_actions(self, path: str, calling_domain: str, cookie: str,
if os.path.isdir(dir_str + '/' + local_handle): if os.path.isdir(dir_str + '/' + local_handle):
search_handle = local_handle search_handle = local_handle
else: else:
search_handle = '' search_handle: str = ''
if search_handle is None: if search_handle is None:
search_handle = '' search_handle: str = ''
if '@' in search_handle: if '@' in search_handle:
msg = \ msg = \
html_account_info(translate, html_account_info(translate,

View File

@ -286,7 +286,7 @@ def citations_update(self, calling_domain: str, cookie: str,
citations.append(fields[field_name]) citations.append(fields[field_name])
if citations: if citations:
citations_str = '' citations_str: str = ''
for citation_date in citations: for citation_date in citations:
citations_str += citation_date + '\n' citations_str += citation_date + '\n'
# save citations dates, so that they can be added when # save citations dates, so that they can be added when

View File

@ -192,7 +192,7 @@ def _person_options_receive_notes(self, options_confirm_params: str,
print('Change person notes') print('Change person notes')
handle = options_nickname + '@' + options_domain_full handle = options_nickname + '@' + options_domain_full
if not person_notes: if not person_notes:
person_notes = '' person_notes: str = ''
set_person_notes(base_dir, set_person_notes(base_dir,
chooser_nickname, chooser_nickname,
domain, domain,
@ -952,7 +952,7 @@ def _person_options_dm(self, options_confirm_params: str,
default_post_language2 = system_language default_post_language2 = system_language
if default_post_language.get(nickname): if default_post_language.get(nickname):
default_post_language2 = default_post_language[nickname] default_post_language2 = default_post_language[nickname]
default_buy_site = '' default_buy_site: str = ''
searchable_by_default = 'yourself' searchable_by_default = 'yourself'
msg = \ msg = \
html_new_post({}, False, translate, html_new_post({}, False, translate,
@ -1206,7 +1206,7 @@ def _person_options_report(self, options_confirm_params: str,
default_post_language2 = system_language default_post_language2 = system_language
if default_post_language.get(nickname): if default_post_language.get(nickname):
default_post_language2 = default_post_language[nickname] default_post_language2 = default_post_language[nickname]
default_buy_site = '' default_buy_site: str = ''
searchable_by_default = 'yourself' searchable_by_default = 'yourself'
msg = \ msg = \
html_new_post({}, False, translate, html_new_post({}, False, translate,

View File

@ -310,7 +310,7 @@ def _profile_post_block_federated(base_dir: str, fields: {}, self) -> None:
def _profile_post_robots_txt(base_dir: str, fields: {}, self) -> None: def _profile_post_robots_txt(base_dir: str, fields: {}, self) -> None:
""" HTTP POST save robots.txt file """ HTTP POST save robots.txt file
""" """
new_robots_txt = '' new_robots_txt: str = ''
if fields.get('robotsTxt'): if fields.get('robotsTxt'):
new_robots_txt = fields['robotsTxt'] new_robots_txt = fields['robotsTxt']
if str(self.server.robots_txt) != str(new_robots_txt): if str(self.server.robots_txt) != str(new_robots_txt):
@ -381,7 +381,7 @@ def _profile_post_crawlers_allowed(base_dir: str, fields: {}, self) -> None:
crawlers_allowed.append(uagent.strip()) crawlers_allowed.append(uagent.strip())
if str(self.server.crawlers_allowed) != str(crawlers_allowed): if str(self.server.crawlers_allowed) != str(crawlers_allowed):
self.server.crawlers_allowed = crawlers_allowed self.server.crawlers_allowed = crawlers_allowed
crawlers_allowed_str = '' crawlers_allowed_str: str = ''
for uagent in crawlers_allowed: for uagent in crawlers_allowed:
if crawlers_allowed_str: if crawlers_allowed_str:
crawlers_allowed_str += ',' crawlers_allowed_str += ','
@ -403,7 +403,7 @@ def _profile_post_blocked_user_agents(base_dir: str, fields: {}, self) -> None:
user_agents_blocked.append(uagent.strip()) user_agents_blocked.append(uagent.strip())
if str(self.server.user_agents_blocked) != str(user_agents_blocked): if str(self.server.user_agents_blocked) != str(user_agents_blocked):
self.server.user_agents_blocked = user_agents_blocked self.server.user_agents_blocked = user_agents_blocked
user_agents_blocked_str = '' user_agents_blocked_str: str = ''
for uagent in user_agents_blocked: for uagent in user_agents_blocked:
if user_agents_blocked_str: if user_agents_blocked_str:
user_agents_blocked_str += ',' user_agents_blocked_str += ','
@ -415,7 +415,7 @@ def _profile_post_blocked_user_agents(base_dir: str, fields: {}, self) -> None:
def _profile_post_cw_lists(fields: {}, self) -> None: def _profile_post_cw_lists(fields: {}, self) -> None:
""" HTTP POST set selected content warning lists """ HTTP POST set selected content warning lists
""" """
new_lists_enabled = '' new_lists_enabled: str = ''
for name, _ in self.server.cw_lists.items(): for name, _ in self.server.cw_lists.items():
list_var_name = get_cw_list_variable(name) list_var_name = get_cw_list_variable(name)
if fields.get(list_var_name): if fields.get(list_var_name):
@ -1424,12 +1424,12 @@ def _profile_post_shared_item_federation_domains(base_dir: str, fields: {},
""" HTTP POST shared item federation domains """ HTTP POST shared item federation domains
""" """
# shared item federation domains # shared item federation domains
si_domain_updated = False si_domain_updated: bool = False
fed_domains_variable = "sharedItemsFederatedDomains" fed_domains_variable: str = "sharedItemsFederatedDomains"
fed_domains_str = get_config_param(base_dir, fed_domains_variable) fed_domains_str: str = get_config_param(base_dir, fed_domains_variable)
if not fed_domains_str: if not fed_domains_str:
fed_domains_str = '' fed_domains_str: str = ''
shared_items_form_str = '' shared_items_form_str: str = ''
if fields.get('shareDomainList'): if fields.get('shareDomainList'):
shared_it_list = fed_domains_str.split(',') shared_it_list = fed_domains_str.split(',')
for shared_federated_domain in shared_it_list: for shared_federated_domain in shared_it_list:
@ -1564,8 +1564,8 @@ def _profile_post_alsoknownas(actor_json: {}, fields: {},
if actor_json.get('alsoKnownAs'): if actor_json.get('alsoKnownAs'):
also_known_as = actor_json['alsoKnownAs'] also_known_as = actor_json['alsoKnownAs']
if fields.get('alsoKnownAs'): if fields.get('alsoKnownAs'):
also_known_as_str = '' also_known_as_str: str = ''
also_known_as_ctr = 0 also_known_as_ctr: int = 0
for alt_actor in also_known_as: for alt_actor in also_known_as:
if also_known_as_ctr > 0: if also_known_as_ctr > 0:
also_known_as_str += ', ' also_known_as_str += ', '
@ -1639,7 +1639,7 @@ def _profile_post_moved(actor_json: {}, fields: {},
""" """
fieldnames = ('movedTo', 'copiedTo') fieldnames = ('movedTo', 'copiedTo')
for fieldname in fieldnames: for fieldname in fieldnames:
moved_to = '' moved_to: str = ''
if actor_json.get(fieldname): if actor_json.get(fieldname):
if isinstance(actor_json[fieldname], str): if isinstance(actor_json[fieldname], str):
moved_to = remove_html(actor_json[fieldname]) moved_to = remove_html(actor_json[fieldname])
@ -1869,7 +1869,7 @@ def _profile_post_birthday(fields: {}, actor_json: {},
actor_changed: bool) -> bool: actor_changed: bool) -> bool:
""" HTTP POST birthday on edit profile screen """ HTTP POST birthday on edit profile screen
""" """
birth_date = '' birth_date: str = ''
if actor_json.get('vcard:bday'): if actor_json.get('vcard:bday'):
birth_date = actor_json['vcard:bday'] birth_date = actor_json['vcard:bday']
if fields.get('birthDate'): if fields.get('birthDate'):
@ -2883,7 +2883,7 @@ def profile_edit(self, calling_domain: str, cookie: str,
post_image_filename) post_image_filename)
post_bytes_str = post_bytes.decode('utf-8') post_bytes_str = post_bytes.decode('utf-8')
redirect_path = '' redirect_path: str = ''
check_name_and_bio = False check_name_and_bio = False
on_final_welcome_screen = False on_final_welcome_screen = False
if 'name="previewAvatar"' in post_bytes_str: if 'name="previewAvatar"' in post_bytes_str:

View File

@ -50,7 +50,7 @@ def receive_vote(self, calling_domain: str, cookie: str,
auto_cw_cache: {}) -> None: auto_cw_cache: {}) -> None:
"""Receive a vote on a question via POST """Receive a vote on a question via POST
""" """
first_post_id = '' first_post_id: str = ''
if '?firstpost=' in path: if '?firstpost=' in path:
first_post_id = path.split('?firstpost=')[1] first_post_id = path.split('?firstpost=')[1]
path = path.split('?firstpost=')[0] path = path.split('?firstpost=')[0]
@ -65,7 +65,7 @@ def receive_vote(self, calling_domain: str, cookie: str,
first_post_id = first_post_id.replace('/', '--') first_post_id = first_post_id.replace('/', '--')
first_post_id = ';firstpost=' + first_post_id.replace('#', '--') first_post_id = ';firstpost=' + first_post_id.replace('#', '--')
last_post_id = '' last_post_id: str = ''
if '?lastpost=' in path: if '?lastpost=' in path:
last_post_id = path.split('?lastpost=')[1] last_post_id = path.split('?lastpost=')[1]
path = path.split('?lastpost=')[0] path = path.split('?lastpost=')[0]
@ -225,12 +225,12 @@ def _send_reply_to_question(self, base_dir: str,
event_date = None event_date = None
event_time = None event_time = None
event_end_time = None event_end_time = None
event_category = '' event_category: str = ''
location = None location = None
conversation_id = None conversation_id = None
convthread_id = None convthread_id = None
buy_url = '' buy_url: str = ''
chat_url = '' chat_url: str = ''
city = get_spoofed_city(city_name, base_dir, nickname, domain) city = get_spoofed_city(city_name, base_dir, nickname, domain)
languages_understood = \ languages_understood = \
get_understood_languages(base_dir, http_prefix, get_understood_languages(base_dir, http_prefix,

View File

@ -155,10 +155,10 @@ def _receive_new_post_process_newpost(self, fields: {},
if '://' not in media_license_url: if '://' not in media_license_url:
media_license_url = \ media_license_url = \
license_link_from_name(media_license_url) license_link_from_name(media_license_url)
media_creator = '' media_creator: str = ''
if fields.get('mediaCreator'): if fields.get('mediaCreator'):
media_creator = fields['mediaCreator'] media_creator = fields['mediaCreator']
video_transcript = '' video_transcript: str = ''
if fields.get('videoTranscript'): if fields.get('videoTranscript'):
video_transcript = fields['videoTranscript'] video_transcript = fields['videoTranscript']
if fields.get('searchableByDropdown'): if fields.get('searchableByDropdown'):
@ -168,7 +168,7 @@ def _receive_new_post_process_newpost(self, fields: {},
# Append the address to the location if needed # Append the address to the location if needed
if fields.get('locationAddress'): if fields.get('locationAddress'):
location_str += ' <address>' + fields['locationAddress'] + '</address>' location_str += ' <address>' + fields['locationAddress'] + '</address>'
event_category = '' event_category: str = ''
if fields.get('eventCategory'): if fields.get('eventCategory'):
event_category = fields['eventCategory'] event_category = fields['eventCategory']
message_json = \ message_json = \
@ -337,10 +337,10 @@ def _receive_new_post_process_newblog(self, fields: {},
if '://' not in media_license_url: if '://' not in media_license_url:
media_license_url = \ media_license_url = \
license_link_from_name(media_license_url) license_link_from_name(media_license_url)
media_creator = '' media_creator: str = ''
if fields.get('mediaCreator'): if fields.get('mediaCreator'):
media_creator = fields['mediaCreator'] media_creator = fields['mediaCreator']
video_transcript = '' video_transcript: str = ''
if fields.get('videoTranscript'): if fields.get('videoTranscript'):
video_transcript = fields['videoTranscript'] video_transcript = fields['videoTranscript']
if fields.get('searchableByDropdown'): if fields.get('searchableByDropdown'):
@ -350,7 +350,7 @@ def _receive_new_post_process_newblog(self, fields: {},
# Append the address to the location if needed # Append the address to the location if needed
if fields.get('locationAddress'): if fields.get('locationAddress'):
location_str += ' <address>' + fields['locationAddress'] + '</address>' location_str += ' <address>' + fields['locationAddress'] + '</address>'
event_category = '' event_category: str = ''
if fields.get('eventCategory'): if fields.get('eventCategory'):
event_category = fields['eventCategory'] event_category = fields['eventCategory']
message_json = \ message_json = \
@ -463,10 +463,10 @@ def _receive_new_post_process_editblog(self, fields: {},
content_map[system_language] = \ content_map[system_language] = \
fields['message'] fields['message']
img_description = '' img_description: str = ''
if fields.get('imageDescription'): if fields.get('imageDescription'):
img_description = fields['imageDescription'] img_description = fields['imageDescription']
video_transcript = '' video_transcript: str = ''
if fields.get('videoTranscript'): if fields.get('videoTranscript'):
video_transcript = fields['videoTranscript'] video_transcript = fields['videoTranscript']
@ -479,7 +479,7 @@ def _receive_new_post_process_editblog(self, fields: {},
if '://' not in license_url: if '://' not in license_url:
license_url = \ license_url = \
license_link_from_name(license_url) license_link_from_name(license_url)
creator = '' creator: str = ''
if fields.get('mediaCreator'): if fields.get('mediaCreator'):
creator = fields['mediaCreator'] creator = fields['mediaCreator']
post_json_object['object'] = \ post_json_object['object'] = \
@ -590,17 +590,17 @@ def _receive_new_post_process_newunlisted(self, fields: {},
if '://' not in media_license_url: if '://' not in media_license_url:
media_license_url = \ media_license_url = \
license_link_from_name(media_license_url) license_link_from_name(media_license_url)
media_creator = '' media_creator: str = ''
if fields.get('mediaCreator'): if fields.get('mediaCreator'):
media_creator = fields['mediaCreator'] media_creator = fields['mediaCreator']
video_transcript = '' video_transcript: str = ''
if fields.get('videoTranscript'): if fields.get('videoTranscript'):
video_transcript = fields['videoTranscript'] video_transcript = fields['videoTranscript']
location_str = fields['location'] location_str = fields['location']
# Append the address to the location if needed # Append the address to the location if needed
if fields.get('locationAddress'): if fields.get('locationAddress'):
location_str += ' <address>' + fields['locationAddress'] + '</address>' location_str += ' <address>' + fields['locationAddress'] + '</address>'
event_category = '' event_category: str = ''
if fields.get('eventCategory'): if fields.get('eventCategory'):
event_category = fields['eventCategory'] event_category = fields['eventCategory']
message_json = \ message_json = \
@ -764,10 +764,10 @@ def _receive_new_post_process_newfollowers(self, fields: {},
if '://' not in media_license_url: if '://' not in media_license_url:
media_license_url = \ media_license_url = \
license_link_from_name(media_license_url) license_link_from_name(media_license_url)
media_creator = '' media_creator: str = ''
if fields.get('mediaCreator'): if fields.get('mediaCreator'):
media_creator = fields['mediaCreator'] media_creator = fields['mediaCreator']
video_transcript = '' video_transcript: str = ''
if fields.get('videoTranscript'): if fields.get('videoTranscript'):
video_transcript = fields['videoTranscript'] video_transcript = fields['videoTranscript']
if fields.get('searchableByDropdown'): if fields.get('searchableByDropdown'):
@ -777,7 +777,7 @@ def _receive_new_post_process_newfollowers(self, fields: {},
# Append the address to the location if needed # Append the address to the location if needed
if fields.get('locationAddress'): if fields.get('locationAddress'):
location_str += ' <address>' + fields['locationAddress'] + '</address>' location_str += ' <address>' + fields['locationAddress'] + '</address>'
event_category = '' event_category: str = ''
if fields.get('eventCategory'): if fields.get('eventCategory'):
event_category = fields['eventCategory'] event_category = fields['eventCategory']
message_json = \ message_json = \
@ -954,10 +954,10 @@ def _receive_new_post_process_newdm(self, fields: {},
if '://' not in media_license_url: if '://' not in media_license_url:
media_license_url = \ media_license_url = \
license_link_from_name(media_license_url) license_link_from_name(media_license_url)
media_creator = '' media_creator: str = ''
if fields.get('mediaCreator'): if fields.get('mediaCreator'):
media_creator = fields['mediaCreator'] media_creator = fields['mediaCreator']
video_transcript = '' video_transcript: str = ''
if fields.get('videoTranscript'): if fields.get('videoTranscript'):
video_transcript = fields['videoTranscript'] video_transcript = fields['videoTranscript']
location_str = fields['location'] location_str = fields['location']
@ -965,7 +965,7 @@ def _receive_new_post_process_newdm(self, fields: {},
if fields.get('locationAddress'): if fields.get('locationAddress'):
location_str += \ location_str += \
' <address>' + fields['locationAddress'] + '</address>' ' <address>' + fields['locationAddress'] + '</address>'
event_category = '' event_category: str = ''
if fields.get('eventCategory'): if fields.get('eventCategory'):
event_category = fields['eventCategory'] event_category = fields['eventCategory']
message_json = \ message_json = \
@ -1130,11 +1130,11 @@ def _receive_new_post_process_newreminder(self, fields: {}, nickname: str,
get_understood_languages(base_dir, http_prefix, get_understood_languages(base_dir, http_prefix,
nickname, domain_full, nickname, domain_full,
person_cache) person_cache)
media_license_url = '' media_license_url: str = ''
media_creator = '' media_creator: str = ''
if fields.get('mediaCreator'): if fields.get('mediaCreator'):
media_creator = fields['mediaCreator'] media_creator = fields['mediaCreator']
video_transcript = '' video_transcript: str = ''
if fields.get('videoTranscript'): if fields.get('videoTranscript'):
video_transcript = fields['videoTranscript'] video_transcript = fields['videoTranscript']
location_str = fields['location'] location_str = fields['location']
@ -1142,7 +1142,7 @@ def _receive_new_post_process_newreminder(self, fields: {}, nickname: str,
if fields.get('locationAddress'): if fields.get('locationAddress'):
location_str += \ location_str += \
' <address>' + fields['locationAddress'] + '</address>' ' <address>' + fields['locationAddress'] + '</address>'
event_category = '' event_category: str = ''
if fields.get('eventCategory'): if fields.get('eventCategory'):
event_category = fields['eventCategory'] event_category = fields['eventCategory']
message_json = \ message_json = \
@ -1268,10 +1268,10 @@ def _receive_new_post_process_newreport(self, fields: {},
if '://' not in media_license_url: if '://' not in media_license_url:
media_license_url = \ media_license_url = \
license_link_from_name(media_license_url) license_link_from_name(media_license_url)
media_creator = '' media_creator: str = ''
if fields.get('mediaCreator'): if fields.get('mediaCreator'):
media_creator = fields['mediaCreator'] media_creator = fields['mediaCreator']
video_transcript = '' video_transcript: str = ''
if fields.get('videoTranscript'): if fields.get('videoTranscript'):
video_transcript = fields['videoTranscript'] video_transcript = fields['videoTranscript']
message_json = \ message_json = \
@ -1369,10 +1369,10 @@ def _receive_new_post_process_newquestion(self, fields: {},
if '://' not in media_license_url: if '://' not in media_license_url:
media_license_url = \ media_license_url = \
license_link_from_name(media_license_url) license_link_from_name(media_license_url)
media_creator = '' media_creator: str = ''
if fields.get('mediaCreator'): if fields.get('mediaCreator'):
media_creator = fields['mediaCreator'] media_creator = fields['mediaCreator']
video_transcript = '' video_transcript: str = ''
if fields.get('videoTranscript'): if fields.get('videoTranscript'):
video_transcript = fields['videoTranscript'] video_transcript = fields['videoTranscript']
message_json = \ message_json = \
@ -1482,10 +1482,10 @@ def _receive_new_post_process_newreading(self, fields: {},
if '://' not in media_license_url: if '://' not in media_license_url:
media_license_url = \ media_license_url = \
license_link_from_name(media_license_url) license_link_from_name(media_license_url)
media_creator = '' media_creator: str = ''
if fields.get('mediaCreator'): if fields.get('mediaCreator'):
media_creator = fields['mediaCreator'] media_creator = fields['mediaCreator']
video_transcript = '' video_transcript: str = ''
if fields.get('videoTranscript'): if fields.get('videoTranscript'):
video_transcript = fields['videoTranscript'] video_transcript = fields['videoTranscript']
conversation_id = None conversation_id = None
@ -1505,7 +1505,7 @@ def _receive_new_post_process_newreading(self, fields: {},
if fields.get('locationAddress'): if fields.get('locationAddress'):
location_str += \ location_str += \
' <address>' + fields['locationAddress'] + '</address>' ' <address>' + fields['locationAddress'] + '</address>'
event_category = '' event_category: str = ''
if fields.get('eventCategory'): if fields.get('eventCategory'):
event_category = fields['eventCategory'] event_category = fields['eventCategory']
# reading status # reading status
@ -2034,7 +2034,7 @@ def _receive_new_post_process(self, post_type: str, path: str, headers: {},
'EX: _receive_new_post_process unable to write ' + 'EX: _receive_new_post_process unable to write ' +
last_used_filename) last_used_filename)
mentions_str = '' mentions_str: str = ''
if fields.get('mentions'): if fields.get('mentions'):
mentions_str = fields['mentions'].strip() + ' ' mentions_str = fields['mentions'].strip() + ' '
if not fields.get('commentsEnabled'): if not fields.get('commentsEnabled'):
@ -2042,11 +2042,11 @@ def _receive_new_post_process(self, post_type: str, path: str, headers: {},
else: else:
comments_enabled = True comments_enabled = True
buy_url = '' buy_url: str = ''
if fields.get('buyUrl'): if fields.get('buyUrl'):
buy_url = fields['buyUrl'] buy_url = fields['buyUrl']
chat_url = '' chat_url: str = ''
if fields.get('chatUrl'): if fields.get('chatUrl'):
chat_url = fields['chatUrl'] chat_url = fields['chatUrl']

View File

@ -653,7 +653,7 @@ def show_person_options(self, calling_domain: str, path: str,
curr_session) -> None: curr_session) -> None:
"""Show person options screen """Show person options screen
""" """
back_to_path = '' back_to_path: str = ''
options_str = path.split('?options=')[1] options_str = path.split('?options=')[1]
origin_path_str = path.split('?options=')[0] origin_path_str = path.split('?options=')[0]
if ';' in options_str and '/users/news/' not in path: if ';' in options_str and '/users/news/' not in path:
@ -664,7 +664,7 @@ def show_person_options(self, calling_domain: str, path: str,
options_page_number = 1 options_page_number = 1
if len(options_list) > 1: if len(options_list) > 1:
options_page_number = options_list[1] options_page_number = options_list[1]
options_profile_url = '' options_profile_url: str = ''
if len(options_list) > 2: if len(options_list) > 2:
options_profile_url = options_list[2] options_profile_url = options_list[2]
if ('.' in options_profile_url or if ('.' in options_profile_url or
@ -710,7 +710,7 @@ def show_person_options(self, calling_domain: str, path: str,
deltachat_invite = None deltachat_invite = None
locked_account = False locked_account = False
also_known_as = None also_known_as = None
moved_to = '' moved_to: str = ''
repo_url = None repo_url = None
status = None status = None
actor_json = \ actor_json = \
@ -765,7 +765,7 @@ def show_person_options(self, calling_domain: str, path: str,
status = get_actor_status(actor_json) status = get_actor_status(actor_json)
if status: if status:
if actor_status_expired(actor_json['sm:status']): if actor_status_expired(actor_json['sm:status']):
status = '' status: str = ''
access_keys = self.server.access_keys access_keys = self.server.access_keys
nickname = 'instance' nickname = 'instance'

View File

@ -568,10 +568,10 @@ def _desktop_reply_to_post(session, post_id: str,
event_date = None event_date = None
event_time = None event_time = None
event_end_time = None event_end_time = None
event_category = '' event_category: str = ''
location = None location = None
buy_url = '' buy_url: str = ''
chat_url = '' chat_url: str = ''
video_transcript = None video_transcript = None
auto_cw_cache = {} auto_cw_cache = {}
# TODO searchable status # TODO searchable status
@ -657,10 +657,10 @@ def _desktop_new_post(session,
event_date = None event_date = None
event_time = None event_time = None
event_end_time = None event_end_time = None
event_category = '' event_category: str = ''
location = None location = None
buy_url = '' buy_url: str = ''
chat_url = '' chat_url: str = ''
video_transcript = None video_transcript = None
auto_cw_cache = {} auto_cw_cache = {}
# TODO searchable status # TODO searchable status
@ -730,7 +730,7 @@ def _text_only_content(content: str) -> str:
def _get_image_description(post_json_object: {}) -> str: def _get_image_description(post_json_object: {}) -> str:
"""Returns a image description/s on a post """Returns a image description/s on a post
""" """
image_description = '' image_description: str = ''
post_attachments = get_post_attachments(post_json_object) post_attachments = get_post_attachments(post_json_object)
if not post_attachments: if not post_attachments:
return image_description return image_description
@ -1014,7 +1014,7 @@ def _desktop_show_actor(http_prefix: str,
say_str = 'Copied to ' + remove_html(moved_url) say_str = 'Copied to ' + remove_html(moved_url)
_say_command(say_str, say_str, screenreader, system_language, espeak) _say_command(say_str, say_str, screenreader, system_language, espeak)
if actor_json.get('alsoKnownAs'): if actor_json.get('alsoKnownAs'):
also_known_as_str = '' also_known_as_str: str = ''
ctr = 0 ctr = 0
for alt_actor in actor_json['alsoKnownAs']: for alt_actor in actor_json['alsoKnownAs']:
if ctr > 0: if ctr > 0:
@ -1184,7 +1184,7 @@ def _desktop_show_box(indent: str,
_desktop_clear_screen() _desktop_clear_screen()
_desktop_show_banner() _desktop_show_banner()
notification_icons = '' notification_icons: str = ''
if box_name.startswith('tl'): if box_name.startswith('tl'):
box_name_str = box_name[2:] box_name_str = box_name[2:]
else: else:
@ -1499,10 +1499,10 @@ def _desktop_new_dm_base(session, to_handle: str,
event_date = None event_date = None
event_time = None event_time = None
event_end_time = None event_end_time = None
event_category = '' event_category: str = ''
location = None location = None
buy_url = '' buy_url: str = ''
chat_url = '' chat_url: str = ''
video_transcript = None video_transcript = None
say_str = 'Sending' say_str = 'Sending'
@ -1611,7 +1611,7 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0' content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0'
media_license_url = 'https://creativecommons.org/licenses/by-nc/4.0' media_license_url = 'https://creativecommons.org/licenses/by-nc/4.0'
media_creator = '' media_creator: str = ''
blocked_cache = {} blocked_cache = {}
block_federated: list[str] = [] block_federated: list[str] = []
@ -1620,7 +1620,7 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
indent = ' ' indent = ' '
if show_new_posts: if show_new_posts:
indent = '' indent: str = ''
_desktop_clear_screen() _desktop_clear_screen()
_desktop_show_banner() _desktop_show_banner()
@ -1654,10 +1654,10 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
post_json_object = {} post_json_object = {}
original_screen_reader = screenreader original_screen_reader = screenreader
sounds_dir = 'theme/default/sounds/' sounds_dir = 'theme/default/sounds/'
# prev_say = '' # prev_say: str = ''
# prev_calendar = False # prev_calendar = False
# prev_follow = False # prev_follow = False
# prev_like = '' # prev_like: str = ''
# prev_share = False # prev_share = False
dm_sound_filename = sounds_dir + 'dm.ogg' dm_sound_filename = sounds_dir + 'dm.ogg'
reply_sound_filename = sounds_dir + 'reply.ogg' reply_sound_filename = sounds_dir + 'reply.ogg'
@ -1701,7 +1701,7 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
"repliesNotify": False, "repliesNotify": False,
"repliesNotifyChanged": False "repliesNotifyChanged": False
} }
prev_timeline_first_id = '' prev_timeline_first_id: str = ''
desktop_shown = False desktop_shown = False
while (1): while (1):
if not pgp_key_upload: if not pgp_key_upload:
@ -1789,6 +1789,7 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
print('You may need to run the desktop client ' + print('You may need to run the desktop client ' +
'with the --http option') 'with the --http option')
command_str: str = ''
# wait for a while, or until a key is pressed # wait for a while, or until a key is pressed
if no_key_press: if no_key_press:
time.sleep(10) time.sleep(10)
@ -1808,7 +1809,7 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
break break
if command_str.startswith('show dm'): if command_str.startswith('show dm'):
page_number = 1 page_number = 1
prev_timeline_first_id = '' prev_timeline_first_id: str = ''
curr_timeline = 'dm' curr_timeline = 'dm'
box_json = c2s_box_json(session, nickname, password, box_json = c2s_box_json(session, nickname, password,
domain, port, http_prefix, domain, port, http_prefix,
@ -1823,7 +1824,7 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
page_number) page_number)
elif command_str.startswith('show rep'): elif command_str.startswith('show rep'):
page_number = 1 page_number = 1
prev_timeline_first_id = '' prev_timeline_first_id: str = ''
curr_timeline = 'tlreplies' curr_timeline = 'tlreplies'
box_json = c2s_box_json(session, nickname, password, box_json = c2s_box_json(session, nickname, password,
domain, port, http_prefix, domain, port, http_prefix,
@ -1838,7 +1839,7 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
page_number) page_number)
elif command_str.startswith('show b'): elif command_str.startswith('show b'):
page_number = 1 page_number = 1
prev_timeline_first_id = '' prev_timeline_first_id: str = ''
curr_timeline = 'tlbookmarks' curr_timeline = 'tlbookmarks'
box_json = c2s_box_json(session, nickname, password, box_json = c2s_box_json(session, nickname, password,
domain, port, http_prefix, domain, port, http_prefix,
@ -1854,7 +1855,7 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
elif string_starts_with(command_str, elif string_starts_with(command_str,
('show sen', 'show out')): ('show sen', 'show out')):
page_number = 1 page_number = 1
prev_timeline_first_id = '' prev_timeline_first_id: str = ''
curr_timeline = 'outbox' curr_timeline = 'outbox'
box_json = c2s_box_json(session, nickname, password, box_json = c2s_box_json(session, nickname, password,
domain, port, http_prefix, domain, port, http_prefix,
@ -1870,17 +1871,17 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
elif (command_str == 'show' or command_str.startswith('show in') or elif (command_str == 'show' or command_str.startswith('show in') or
command_str == 'clear'): command_str == 'clear'):
page_number = 1 page_number = 1
prev_timeline_first_id = '' prev_timeline_first_id: str = ''
curr_timeline = 'inbox' curr_timeline = 'inbox'
refresh_timeline = True refresh_timeline = True
elif command_str.startswith('next'): elif command_str.startswith('next'):
page_number += 1 page_number += 1
prev_timeline_first_id = '' prev_timeline_first_id: str = ''
refresh_timeline = True refresh_timeline = True
elif command_str.startswith('prev'): elif command_str.startswith('prev'):
page_number -= 1 page_number -= 1
page_number = max(page_number, 1) page_number = max(page_number, 1)
prev_timeline_first_id = '' prev_timeline_first_id: str = ''
box_json = c2s_box_json(session, nickname, password, box_json = c2s_box_json(session, nickname, password,
domain, port, http_prefix, domain, port, http_prefix,
curr_timeline, page_number, curr_timeline, page_number,
@ -1928,7 +1929,7 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
_say_command(say_str2, say_str, _say_command(say_str2, say_str,
screenreader, system_language, espeak) screenreader, system_language, espeak)
input() input()
prev_timeline_first_id = '' prev_timeline_first_id: str = ''
refresh_timeline = True refresh_timeline = True
print('') print('')
elif (command_str.startswith('profile ') or elif (command_str.startswith('profile ') or
@ -1972,7 +1973,7 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
_say_command(say_str2, say_str, _say_command(say_str2, say_str,
screenreader, system_language, espeak) screenreader, system_language, espeak)
input() input()
prev_timeline_first_id = '' prev_timeline_first_id: str = ''
refresh_timeline = True refresh_timeline = True
elif not actor_json and box_json: elif not actor_json and box_json:
_desktop_clear_screen() _desktop_clear_screen()
@ -1994,15 +1995,15 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
_say_command(say_str2, say_str, _say_command(say_str2, say_str,
screenreader, system_language, espeak) screenreader, system_language, espeak)
input() input()
prev_timeline_first_id = '' prev_timeline_first_id: str = ''
refresh_timeline = True refresh_timeline = True
print('') print('')
elif command_str in ('reply', 'r'): elif command_str in ('reply', 'r'):
if post_json_object: if post_json_object:
post_content = '' post_content: str = ''
if post_json_object['object'].get('content'): if post_json_object['object'].get('content'):
post_content = post_json_object['object']['content'] post_content = post_json_object['object']['content']
post_summary = '' post_summary: str = ''
if post_json_object['object'].get('summary'): if post_json_object['object'].get('summary'):
post_summary = post_json_object['object']['summary'] post_summary = post_json_object['object']['summary']
if not disallow_reply(post_summary + ' ' + post_content): if not disallow_reply(post_summary + ' ' + post_content):
@ -2464,10 +2465,10 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
post_json_object = \ post_json_object = \
_desktop_get_box_post_object(box_json, curr_index) _desktop_get_box_post_object(box_json, curr_index)
if post_json_object: if post_json_object:
post_content = '' post_content: str = ''
if post_json_object['object'].get('content'): if post_json_object['object'].get('content'):
post_content = post_json_object['object']['content'] post_content = post_json_object['object']['content']
post_summary = '' post_summary: str = ''
if post_json_object['object'].get('summary'): if post_json_object['object'].get('summary'):
post_summary = post_json_object['object']['summary'] post_summary = post_json_object['object']['summary']
attachment = get_post_attachments(post_json_object) attachment = get_post_attachments(post_json_object)
@ -2620,7 +2621,7 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
if actor_json: if actor_json:
follow_handle = actor_json['id'] follow_handle = actor_json['id']
else: else:
follow_handle = '' follow_handle: str = ''
else: else:
follow_handle = command_str.replace('follow ', '').strip() follow_handle = command_str.replace('follow ', '').strip()
if follow_handle.startswith('@'): if follow_handle.startswith('@'):
@ -2893,7 +2894,7 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
_say_command(say_str2, say_str, _say_command(say_str2, say_str,
screenreader, system_language, espeak) screenreader, system_language, espeak)
input() input()
prev_timeline_first_id = '' prev_timeline_first_id: str = ''
refresh_timeline = True refresh_timeline = True
elif (command_str in ('delete', 'rm') or elif (command_str in ('delete', 'rm') or
string_starts_with(command_str, ('delete ', 'rm '))): string_starts_with(command_str, ('delete ', 'rm '))):

View File

@ -1286,7 +1286,7 @@ def _command_options() -> None:
argb.language = 'en' argb.language = 'en'
if not argb.domain: if not argb.domain:
argb.domain = get_config_param(base_dir, 'domain') argb.domain = get_config_param(base_dir, 'domain')
domain = '' domain: str = ''
if argb.domain: if argb.domain:
domain = argb.domain domain = argb.domain
signing_priv_key_pem = None signing_priv_key_pem = None
@ -1371,7 +1371,7 @@ def _command_options() -> None:
} }
if not argb.domain: if not argb.domain:
argb.domain = get_config_param(base_dir, 'domain') argb.domain = get_config_param(base_dir, 'domain')
domain = '' domain: str = ''
if argb.domain: if argb.domain:
domain = argb.domain domain = argb.domain
signing_priv_key_pem = get_instance_actor_key(base_dir, domain) signing_priv_key_pem = get_instance_actor_key(base_dir, domain)
@ -1449,13 +1449,13 @@ def _command_options() -> None:
session = create_session(proxy_type) session = create_session(proxy_type)
if not argb.domain: if not argb.domain:
argb.domain = get_config_param(base_dir, 'domain') argb.domain = get_config_param(base_dir, 'domain')
domain = '' domain: str = ''
if argb.domain: if argb.domain:
domain = argb.domain domain = argb.domain
if not domain: if not domain:
print('Please specify a domain with the --domain option') print('Please specify a domain with the --domain option')
sys.exit() sys.exit()
nickname = '' nickname: str = ''
if argb.nickname: if argb.nickname:
nickname = argb.nickname nickname = argb.nickname
if not nickname: if not nickname:
@ -1479,7 +1479,7 @@ def _command_options() -> None:
} }
if not argb.domain: if not argb.domain:
argb.domain = get_config_param(base_dir, 'domain') argb.domain = get_config_param(base_dir, 'domain')
domain = '' domain: str = ''
if argb.domain: if argb.domain:
domain = argb.domain domain = argb.domain
signing_priv_key_pem = get_instance_actor_key(base_dir, domain) signing_priv_key_pem = get_instance_actor_key(base_dir, domain)
@ -1502,7 +1502,7 @@ def _command_options() -> None:
session = create_session(None) session = create_session(None)
if not argb.domain: if not argb.domain:
argb.domain = get_config_param(base_dir, 'domain') argb.domain = get_config_param(base_dir, 'domain')
domain = '' domain: str = ''
if argb.domain: if argb.domain:
domain = argb.domain domain = argb.domain
test_vcard = get_vcard(False, session, argb.vcard, test_vcard = get_vcard(False, session, argb.vcard,
@ -1516,7 +1516,7 @@ def _command_options() -> None:
session = create_session(None) session = create_session(None)
if not argb.domain: if not argb.domain:
argb.domain = get_config_param(base_dir, 'domain') argb.domain = get_config_param(base_dir, 'domain')
domain = '' domain: str = ''
if argb.domain: if argb.domain:
domain = argb.domain domain = argb.domain
test_vcard = get_vcard(True, session, argb.xmlvcard, test_vcard = get_vcard(True, session, argb.xmlvcard,
@ -1534,7 +1534,7 @@ def _command_options() -> None:
} }
if not argb.domain: if not argb.domain:
argb.domain = get_config_param(base_dir, 'domain') argb.domain = get_config_param(base_dir, 'domain')
domain = '' domain: str = ''
if argb.domain: if argb.domain:
domain = argb.domain domain = argb.domain
signing_priv_key_pem = get_instance_actor_key(base_dir, domain) signing_priv_key_pem = get_instance_actor_key(base_dir, domain)
@ -1565,7 +1565,7 @@ def _command_options() -> None:
} }
if not argb.domain: if not argb.domain:
argb.domain = get_config_param(base_dir, 'domain') argb.domain = get_config_param(base_dir, 'domain')
domain = '' domain: str = ''
if argb.domain: if argb.domain:
domain = argb.domain domain = argb.domain
if not domain: if not domain:
@ -3959,7 +3959,7 @@ def _command_options() -> None:
test_event_date = None test_event_date = None
test_event_time = None test_event_time = None
test_event_end_time = None test_event_end_time = None
test_event_category = '' test_event_category: str = ''
test_location = None test_location = None
test_is_article = False test_is_article = False
conversation_id = None conversation_id = None
@ -3967,10 +3967,10 @@ def _command_options() -> None:
low_bandwidth = False low_bandwidth = False
languages_understood = [argb.language] languages_understood = [argb.language]
translate = {} translate = {}
buy_url = '' buy_url: str = ''
chat_url = '' chat_url: str = ''
auto_cw_cache = {} auto_cw_cache = {}
test_video_transcript = '' test_video_transcript: str = ''
searchable_by: list[str] = [] searchable_by: list[str] = []
curr_session = None curr_session = None
@ -4165,7 +4165,7 @@ def _command_options() -> None:
if no_of_books: if no_of_books:
argb.no_of_books = int(no_of_books) argb.no_of_books = int(no_of_books)
content_license_url = '' content_license_url: str = ''
if argb.content_license_url: if argb.content_license_url:
content_license_url = argb.content_license_url content_license_url = argb.content_license_url
set_config_param(base_dir, 'contentLicenseUrl', content_license_url) set_config_param(base_dir, 'contentLicenseUrl', content_license_url)
@ -4347,7 +4347,7 @@ def _command_options() -> None:
for crawlers_allowed_str2 in crawlers_allowed_list: for crawlers_allowed_str2 in crawlers_allowed_list:
crawlers_allowed.append(crawlers_allowed_str2.strip()) crawlers_allowed.append(crawlers_allowed_str2.strip())
lists_enabled = '' lists_enabled: str = ''
if argb.lists_enabled: if argb.lists_enabled:
lists_enabled = argb.lists_enabled lists_enabled = argb.lists_enabled
set_config_param(base_dir, 'listsEnabled', lists_enabled) set_config_param(base_dir, 'listsEnabled', lists_enabled)

View File

@ -281,7 +281,7 @@ def is_follower_of_person(base_dir: str, nickname: str, domain: str,
'EX: is_follower_of_person ' + 'EX: is_follower_of_person ' +
followers_file) followers_file)
if followers_str is None: if followers_str is None:
followers_str = '' followers_str: str = ''
if handle in followers_str: if handle in followers_str:
already_following = True already_following = True
@ -668,7 +668,7 @@ def store_follow_request(base_dir: str,
load_string(followers_filename, load_string(followers_filename,
'EX: store_follow_request ' + followers_filename) 'EX: store_follow_request ' + followers_filename)
if followers_str is None: if followers_str is None:
followers_str = '' followers_str: str = ''
if approve_handle in followers_str: if approve_handle in followers_str:
already_following = True already_following = True
@ -1557,7 +1557,7 @@ def remove_follower(base_dir: str,
handle = remove_nickname + '@' + remove_domain handle = remove_nickname + '@' + remove_domain
handle = handle.lower() handle = handle.lower()
new_followers_str = '' new_followers_str: str = ''
found = False found = False
for handle2 in followers_list: for handle2 in followers_list:
if not handle2: if not handle2:

View File

@ -43,7 +43,7 @@ def _get_followers_for_domain(base_dir: str,
'EX: get_followers_for_domain unable to read followers ' + 'EX: get_followers_for_domain unable to read followers ' +
followers_filename) followers_filename)
if foll_text is None: if foll_text is None:
foll_text = '' foll_text: str = ''
if search_domain not in foll_text: if search_domain not in foll_text:
return [] return []
lines = foll_text.splitlines() lines = foll_text.splitlines()

View File

@ -118,7 +118,7 @@ def _receive_calendar_events(base_dir: str, nickname: str, domain: str,
load_string(calendar_filename, load_string(calendar_filename,
'EX: _receive_calendar_events ' + calendar_filename) 'EX: _receive_calendar_events ' + calendar_filename)
if following_handles is None: if following_handles is None:
following_handles = '' following_handles: str = ''
else: else:
# create a new calendar file from the following file # create a new calendar file from the following file
print('Creating calendar file ' + calendar_filename) print('Creating calendar file ' + calendar_filename)
@ -139,7 +139,7 @@ def _receive_calendar_events(base_dir: str, nickname: str, domain: str,
# already added # already added
return return
# remove from calendar file # remove from calendar file
new_following_handles = '' new_following_handles: str = ''
following_handles_list = following_handles.split('\n') following_handles_list = following_handles.split('\n')
handle_lower = handle.lower() handle_lower = handle.lower()
for followed in following_handles_list: for followed in following_handles_list:

View File

@ -87,7 +87,7 @@ def get_image_formats() -> str:
""" """
image_ext = get_image_extensions() image_ext = get_image_extensions()
image_formats = '' image_formats: str = ''
for ext in image_ext: for ext in image_ext:
if image_formats: if image_formats:
image_formats += ', ' image_formats += ', '
@ -101,7 +101,7 @@ def get_media_formats() -> str:
""" """
media_ext = get_media_extensions() media_ext = get_media_extensions()
media_formats = '' media_formats: str = ''
for ext in media_ext: for ext in media_ext:
if media_formats: if media_formats:
media_formats += ', ' media_formats += ', '

View File

@ -61,7 +61,7 @@ def blog_to_gemini(base_dir: str, nickname: str, domain: str,
if '://' in content_text: if '://' in content_text:
sections = content_text.split('://') sections = content_text.split('://')
ctr = 0 ctr = 0
prev_section = '' prev_section: str = ''
for section in sections: for section in sections:
if ctr > 0: if ctr > 0:
link_str = section link_str = section
@ -100,7 +100,7 @@ def blog_to_gemini(base_dir: str, nickname: str, domain: str,
# get attachments # get attachments
post_attachments = get_post_attachments(message_json) post_attachments = get_post_attachments(message_json)
if post_attachments: if post_attachments:
descriptions = '' descriptions: str = ''
for attach in post_attachments: for attach in post_attachments:
if not isinstance(attach, dict): if not isinstance(attach, dict):
continue continue

4
git.py
View File

@ -103,7 +103,7 @@ def _get_patch_description(patch_str: str) -> str:
"""Returns the description from a given patch """Returns the description from a given patch
""" """
patch_lines = patch_str.split('\n') patch_lines = patch_str.split('\n')
description = '' description: str = ''
started = False started = False
for line in patch_lines: for line in patch_lines:
if started: if started:
@ -167,7 +167,7 @@ def _git_add_from_handle(patch_str: str, handle: str) -> str:
return patch_str return patch_str
patch_lines = patch_str.split('\n') patch_lines = patch_str.split('\n')
patch_str = '' patch_str: str = ''
for line in patch_lines: for line in patch_lines:
patch_str += line + '\n' patch_str += line + '\n'
if line.startswith('From:'): if line.startswith('From:'):

View File

@ -420,13 +420,13 @@ def _icalendar_day(base_dir: str, nickname: str, domain: str,
day_events: [], person_cache: {}) -> str: day_events: [], person_cache: {}) -> str:
"""Returns a day's events in icalendar format """Returns a day's events in icalendar format
""" """
ical_str = '' ical_str: str = ''
print('icalendar: ' + str(day_events)) print('icalendar: ' + str(day_events))
for event_post in day_events: for event_post in day_events:
event_description = None event_description = None
event_place = None event_place = None
post_id = None post_id = None
sender_name = '' sender_name: str = ''
sender_actor = None sender_actor = None
event_is_public = False event_is_public = False
event_start = None event_start = None
@ -979,7 +979,7 @@ def _dav_store_event(base_dir: str, nickname: str, domain: str,
if not end_time: if not end_time:
return False return False
post_id = '' post_id: str = ''
post_context = get_individual_post_context() post_context = get_individual_post_context()
# create the status number from DTSTAMP # create the status number from DTSTAMP
status_number, published = get_status_number(published) status_number, published = get_status_number(published)
@ -1056,7 +1056,7 @@ def _dav_store_event(base_dir: str, nickname: str, domain: str,
} }
if location: if location:
# get the location link # get the location link
location_url = '' location_url: str = ''
if '://' in location: if '://' in location:
location_words = location.split(' ') location_words = location.split(' ')
for loc_wrd in location_words: for loc_wrd in location_words:
@ -1200,7 +1200,7 @@ def dav_report_response(base_dir: str, nickname: str, domain: str,
query_end_time_str = end_time_str.split('"')[1] query_end_time_str = end_time_str.split('"')[1]
query_end_time = _dav_date_from_string(query_end_time_str) query_end_time = _dav_date_from_string(query_end_time_str)
text_match = '' text_match: str = ''
if ':text-match' in xml_str_lower: if ':text-match' in xml_str_lower:
match_str = xml_str_lower.split(':text-match')[1] match_str = xml_str_lower.split(':text-match')[1]
if '>' in match_str and '<' in match_str: if '>' in match_str and '<' in match_str:
@ -1208,12 +1208,12 @@ def dav_report_response(base_dir: str, nickname: str, domain: str,
if '<' in text_match: if '<' in text_match:
text_match = text_match.split('<')[0] text_match = text_match.split('<')[0]
else: else:
text_match = '' text_match: str = ''
ical_events = None ical_events = None
etag = None etag = None
events_href = '' events_href: str = ''
responses = '' responses: str = ''
search_date = datetime.now() search_date = datetime.now()
if query_start_time and query_end_time: if query_start_time and query_end_time:
query_start_year = int(query_start_time.split('-')[0]) query_start_year = int(query_start_time.split('-')[0])
@ -1297,7 +1297,7 @@ def dav_report_response(base_dir: str, nickname: str, domain: str,
' </d:propstat>\n' + \ ' </d:propstat>\n' + \
' </d:response>\n' ' </d:response>\n'
if not responses: if not responses:
all_events = '' all_events: str = ''
for year in range(query_start_year, query_end_year+1): for year in range(query_start_year, query_end_year+1):
if query_start_year == query_end_year: if query_start_year == query_end_year:
start_month_number = query_start_month start_month_number = query_start_month

View File

@ -113,7 +113,7 @@ def sign_post_headers(date_str: str, private_key_pem: str,
# }) # })
# build a digest for signing # build a digest for signing
signed_header_keys = headers.keys() signed_header_keys = headers.keys()
signed_header_text = '' signed_header_text: str = ''
for header_key in signed_header_keys: for header_key in signed_header_keys:
signed_header_text += f'{header_key}: {headers[header_key]}\n' signed_header_text += f'{header_key}: {headers[header_key]}\n'
# strip the trailing linefeed # strip the trailing linefeed
@ -198,7 +198,7 @@ def sign_post_headers_new(date_str: str, private_key_pem: str,
None, backend=default_backend()) None, backend=default_backend())
# build a digest for signing # build a digest for signing
signed_header_keys = headers.keys() signed_header_keys = headers.keys()
signed_header_text = '' signed_header_text: str = ''
for header_key in signed_header_keys: for header_key in signed_header_keys:
signed_header_text += f'{header_key}: {headers[header_key]}\n' signed_header_text += f'{header_key}: {headers[header_key]}\n'
signed_header_text = signed_header_text.strip() signed_header_text = signed_header_text.strip()
@ -208,7 +208,7 @@ def sign_post_headers_new(date_str: str, private_key_pem: str,
signed_header_text + '\nEND\n') signed_header_text + '\nEND\n')
# Sign the digest. Potentially other signing algorithms can be added here. # Sign the digest. Potentially other signing algorithms can be added here.
signature = '' signature: str = ''
if algorithm == 'rsa-sha512': if algorithm == 'rsa-sha512':
header_digest = get_sha_512(signed_header_text.encode('ascii')) header_digest = get_sha_512(signed_header_text.encode('ascii'))
raw_signature = key.sign(header_digest, raw_signature = key.sign(header_digest,
@ -557,7 +557,7 @@ def verify_post_headers(http_prefix: str,
header_digest = get_sha_512(signed_header_text.encode('ascii')) header_digest = get_sha_512(signed_header_text.encode('ascii'))
else: else:
print('Unknown http digest algorithm: ' + digest_algorithm) print('Unknown http digest algorithm: ' + digest_algorithm)
header_digest = '' header_digest: str = ''
padding_str = padding.PKCS1v15() padding_str = padding.PKCS1v15()
try: try:

View File

@ -597,7 +597,7 @@ def save_post_to_inbox_queue(base_dir: str, http_prefix: str,
curr_time = date_utcnow() curr_time = date_utcnow()
post_id = None post_id = None
published = '' published: str = ''
if post_json_object.get('id'): if post_json_object.get('id'):
post_id = remove_id_ending(post_json_object['id']) post_id = remove_id_ending(post_json_object['id'])
published = curr_time.strftime("%Y-%m-%dT%H:%M:%SZ") published = curr_time.strftime("%Y-%m-%dT%H:%M:%SZ")
@ -1200,7 +1200,7 @@ def _send_to_group_members(server, session, session_onion,
else: else:
if group_actor != post_json_object['to']: if group_actor != post_json_object['to']:
return return
cc_str = '' cc_str: str = ''
nickname = handle.split('@')[0].replace('!', '') nickname = handle.split('@')[0].replace('!', '')
# save to the group outbox so that replies will be to the group # save to the group outbox so that replies will be to the group
@ -1406,7 +1406,7 @@ def _bounce_dm(sender_post_id: str, session, http_prefix: str,
comments_enabled = False comments_enabled = False
attach_image_filename = None attach_image_filename = None
media_type = None media_type = None
image_description = '' image_description: str = ''
video_transcript = None video_transcript = None
city = 'London, England' city = 'London, England'
in_reply_to = remove_id_ending(sender_post_id) in_reply_to = remove_id_ending(sender_post_id)
@ -1415,13 +1415,13 @@ def _bounce_dm(sender_post_id: str, session, http_prefix: str,
event_date = None event_date = None
event_time = None event_time = None
event_end_time = None event_end_time = None
event_category = '' event_category: str = ''
location = None location = None
conversation_id = None conversation_id = None
convthread_id = None convthread_id = None
low_bandwidth = False low_bandwidth = False
buy_url = '' buy_url: str = ''
chat_url = '' chat_url: str = ''
auto_cw_cache = {} auto_cw_cache = {}
post_json_object = \ post_json_object = \
create_direct_message_post(base_dir, nickname, domain, port, create_direct_message_post(base_dir, nickname, domain, port,
@ -4077,7 +4077,7 @@ def run_inbox_queue(server,
inbox_start_time = time.time() inbox_start_time = time.time()
lists_enabled = get_config_param(base_dir, "listsEnabled") lists_enabled = get_config_param(base_dir, "listsEnabled")
dm_license_url = '' dm_license_url: str = ''
fitness_performance(inbox_start_time, server.fitness, fitness_performance(inbox_start_time, server.fitness,
'INBOX', 'distribute_post', 'INBOX', 'distribute_post',

View File

@ -302,7 +302,7 @@ def _person_receive_update(base_dir: str,
get_person_avatar_url(base_dir, person_json['id'], get_person_avatar_url(base_dir, person_json['id'],
person_cache) person_cache)
if prev_avatar_url is None: if prev_avatar_url is None:
prev_avatar_url = '' prev_avatar_url: str = ''
_notify_moved(base_dir, domain_full, _notify_moved(base_dir, domain_full,
prev_nickname + '@' + prev_domain_full, prev_nickname + '@' + prev_domain_full,
new_nickname + '@' + new_domain_full, new_nickname + '@' + new_domain_full,

View File

@ -28,7 +28,7 @@ def get_actor_languages(actor_json: {}) -> str:
lang_list = get_actor_languages_list(actor_json) lang_list = get_actor_languages_list(actor_json)
if not lang_list: if not lang_list:
return '' return ''
languages_str = '' languages_str: str = ''
for lang in lang_list: for lang in lang_list:
if languages_str: if languages_str:
languages_str += ' / ' + lang languages_str += ' / ' + lang
@ -65,7 +65,7 @@ def set_actor_languages(actor_json: {}, languages_str: str) -> None:
lang_list = languages_str.lower().split(separator) lang_list = languages_str.lower().split(separator)
else: else:
lang_list = [languages_str.lower()] lang_list = [languages_str.lower()]
lang_list2 = '' lang_list2: str = ''
for lang in lang_list: for lang in lang_list:
lang = lang.strip() lang = lang.strip()
if lang_list2: if lang_list2:
@ -169,7 +169,7 @@ def libretranslate_languages(url: str, api_key: str) -> []:
req = request.Request(url, data=url_params.encode()) req = request.Request(url, data=url_params.encode())
response_str = '' response_str: str = ''
with request.urlopen(req) as response: with request.urlopen(req) as response:
response_str = response.read().decode() response_str = response.read().decode()

View File

@ -193,7 +193,7 @@ def manual_approve_follow_request(session, session_onion, session_i2p,
return return
# is the handle in the requests file? # is the handle in the requests file?
approve_follows_str = '' approve_follows_str: str = ''
try: try:
with open(approve_follows_filename, 'r', encoding='utf-8') as fp_foll: with open(approve_follows_filename, 'r', encoding='utf-8') as fp_foll:
approve_follows_str = fp_foll.read() approve_follows_str = fp_foll.read()

14
maps.py
View File

@ -74,7 +74,7 @@ def _get_event_dict_from_tags(tags: []) -> str:
def _location_address_from_dict(location: {}) -> str: def _location_address_from_dict(location: {}) -> str:
"""returns location address as a string """returns location address as a string
""" """
location_str = '' location_str: str = ''
address_section_name = ( address_section_name = (
'streetAddress', 'streetAddress',
'addressLocality', 'addressLocality',
@ -129,7 +129,7 @@ def _get_category_from_tags(tags: [], translate: {}) -> str:
if translate.get(category_str): if translate.get(category_str):
return translate[category_str] return translate[category_str]
if isinstance(evnt['category'], list): if isinstance(evnt['category'], list):
category_str = '' category_str: str = ''
for category_item in evnt['category']: for category_item in evnt['category']:
if not isinstance(category_item, str): if not isinstance(category_item, str):
continue continue
@ -359,7 +359,7 @@ def get_location_from_post(post_json_object: {}) -> str:
def get_category_from_post(post_json_object: {}, translate: {}) -> str: def get_category_from_post(post_json_object: {}, translate: {}) -> str:
"""Returns the location category for the given post """Returns the location category for the given post
""" """
catstr = '' catstr: str = ''
# location represented via a tag # location represented via a tag
post_obj = post_json_object post_obj = post_json_object
@ -376,7 +376,7 @@ def get_category_from_post(post_json_object: {}, translate: {}) -> str:
if translate.get(text): if translate.get(text):
catstr = translate[text] catstr = translate[text]
elif isinstance(text, list): elif isinstance(text, list):
catstr = '' catstr: str = ''
for cat_text in text: for cat_text in text:
if not isinstance(cat_text, str): if not isinstance(cat_text, str):
continue continue
@ -1005,7 +1005,7 @@ def get_map_links_from_post_content(content: str, session) -> []:
continue continue
if ',' not in link_str: if ',' not in link_str:
continue continue
coords_str = '' coords_str: str = ''
for char in link_str: for char in link_str:
if not char.isnumeric() and char not in (',', '-', '.'): if not char.isnumeric() and char not in (',', '-', '.'):
break break
@ -1058,7 +1058,7 @@ def add_tag_map_links(tag_maps_dir: str, tag_name: str,
# sort the list of map links # sort the list of map links
existing_map_links.sort(reverse=True) existing_map_links.sort(reverse=True)
map_links_str = '' map_links_str: str = ''
ctr = 0 ctr = 0
for link in existing_map_links: for link in existing_map_links:
if not link: if not link:
@ -1264,7 +1264,7 @@ def html_hashtag_maps(base_dir: str, tag_name: str,
time_period = _get_tagmaps_time_periods() time_period = _get_tagmaps_time_periods()
html_str = '' html_str: str = ''
map_str = None map_str = None
ua_str_lower = ua_str.lower() ua_str_lower = ua_str.lower()
for period_str, hours in time_period.items(): for period_str, hours in time_period.items():

View File

@ -2017,7 +2017,7 @@ def _remove_post_id_from_tag_index(tag_index_filename: str,
tag_index_filename) tag_index_filename)
if not lines: if not lines:
return return
newlines = '' newlines: str = ''
for file_line in lines: for file_line in lines:
if post_id in file_line: if post_id in file_line:
# skip over the deleted post # skip over the deleted post

View File

@ -89,8 +89,8 @@ def html_welcome_screen(base_dir: str, nickname: str,
welcome_text = welcome_text.replace('INSTANCE', instance_title) welcome_text = welcome_text.replace('INSTANCE', instance_title)
welcome_text = markdown_to_html(remove_html(welcome_text)) welcome_text = markdown_to_html(remove_html(welcome_text))
else: else:
welcome_text = '' welcome_text: str = ''
welcome_form = '' welcome_form: str = ''
css_filename = base_dir + '/epicyon-welcome.css' css_filename = base_dir + '/epicyon-welcome.css'
if os.path.isfile(base_dir + '/welcome.css'): if os.path.isfile(base_dir + '/welcome.css'):
css_filename = base_dir + '/welcome.css' css_filename = base_dir + '/welcome.css'

View File

@ -60,9 +60,9 @@ def html_welcome_final(base_dir: str, nickname: str,
final_text = final_text.replace('INSTANCE', instance_title) final_text = final_text.replace('INSTANCE', instance_title)
final_text = markdown_to_html(remove_html(final_text)) final_text = markdown_to_html(remove_html(final_text))
else: else:
final_text = '' final_text: str = ''
final_form = '' final_form: str = ''
css_filename = base_dir + '/epicyon-welcome.css' css_filename = base_dir + '/epicyon-welcome.css'
if os.path.isfile(base_dir + '/welcome.css'): if os.path.isfile(base_dir + '/welcome.css'):
css_filename = base_dir + '/welcome.css' css_filename = base_dir + '/welcome.css'

View File

@ -68,9 +68,9 @@ def html_welcome_profile(base_dir: str, nickname: str, domain: str,
profile_text = profile_text.replace('INSTANCE', instance_title) profile_text = profile_text.replace('INSTANCE', instance_title)
profile_text = markdown_to_html(remove_html(profile_text)) profile_text = markdown_to_html(remove_html(profile_text))
else: else:
profile_text = '' profile_text: str = ''
profile_form = '' profile_form: str = ''
css_filename = base_dir + '/epicyon-welcome.css' css_filename = base_dir + '/epicyon-welcome.css'
if os.path.isfile(base_dir + '/welcome.css'): if os.path.isfile(base_dir + '/welcome.css'):
css_filename = base_dir + '/welcome.css' css_filename = base_dir + '/welcome.css'
@ -120,7 +120,7 @@ def html_welcome_profile(base_dir: str, nickname: str, domain: str,
edit_text_field(translate['Nickname'], 'displayNickname', edit_text_field(translate['Nickname'], 'displayNickname',
display_nickname) display_nickname)
bio_str = '' bio_str: str = ''
if actor_json.get('summary'): if actor_json.get('summary'):
replacements = { replacements = {
'<p>': '', '<p>': '',

View File

@ -299,7 +299,7 @@ def wellknown_protocol_handler(path: str, http_prefix: str,
domain_and_path = domain_full domain_and_path = domain_full
# not an open redirect # not an open redirect
if domain_and_path.startswith(domain_full): if domain_and_path.startswith(domain_full):
command = '' command: str = ''
if '/' in nickname: if '/' in nickname:
command = nickname.split('/')[0] command = nickname.split('/')[0]
nickname = nickname.split('/')[1] nickname = nickname.split('/')[1]