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
# create the altered passwords list
passwords_list_new = ''
passwords_list_new: str = ''
for login_str in passwords_list:
if not login_str.startswith(nickname + ':'):
passwords_list_new += login_str
@ -250,7 +250,7 @@ def remove_password(base_dir: str, nickname: str) -> None:
return
# create the new passwords file
passwords_list_new = ''
passwords_list_new: str = ''
account_found = False
for login_str in passwords_list:
if not login_str.startswith(nickname + ':'):
@ -260,18 +260,18 @@ def remove_password(base_dir: str, nickname: str) -> None:
if not account_found:
# the account doesn't exist
passwords_list.clear()
passwords_list_new = ''
passwords_list_new: str = ''
return
# save the new passwords file
if not save_string(passwords_list_new, password_file + '.new',
'EX: unable to remove password from file [ex]'):
passwords_list.clear()
passwords_list_new = ''
passwords_list_new: str = ''
return
passwords_list.clear()
passwords_list_new = ''
passwords_list_new: str = ''
try:
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,
'EX: unable to read blocking reasons 3')
if reasons_str is None:
reasons_str = ''
reasons_str: str = ''
reasons_lines = reasons_str.split('\n')
new_reasons_str: str = ''
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: ' +
blocking_filename + ' ' + handle)
if file_text is None:
file_text = ''
file_text: str = ''
new_file_text: str = ''
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: ' +
blocking_filename + ' ' + handle)
if file_text is None:
file_text = ''
file_text: str = ''
file_text += handle + '\n'
save_string(file_text, blocking_filename,
'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: ' +
blocking_filename + ' ' + handle)
if file_text is None:
file_text = ''
file_text: str = ''
file_text += handle + '\n'
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: ' +
blocking_filename + ' ' + handle)
if file_text is None:
file_text = ''
file_text: str = ''
file_text = file_text.replace(handle + '\n', '')
save_string(file_text, blocking_filename,
'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:
return True
text = ''
text: str = ''
for new_block in append_blocks:
text += new_block + '\n'
append_string(text, blocking_filename,
'EX: ' +
'unable to append imported blocks to ' +
blocking_filename)
text = ''
text: str = ''
for new_reason in append_reasons:
text += new_reason + '\n'
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
ctr = 0
sections = content.split('=> ')
new_content = ''
new_content: str = ''
for section in sections:
if ctr == 0:
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]
else:
after_web_link = section.split(web_link_str, 1)[1]
after_str = ''
after_link_str = ''
after_str: str = ''
after_link_str: str = ''
if '<' in after_web_link:
after_str = after_web_link.split('<', 1)[0]
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]
else:
after_str = after_web_link
after_link_str = ''
after_link_str: str = ''
after_str = after_str.strip()
after_link_str = after_link_str.strip()
if is_image_file(web_link_str) and \
@ -278,7 +278,7 @@ def html_blog_post_markdown(content: str) -> str:
continue
sections = new_content.split(markdown_text)
ctr = 0
new_content2 = ''
new_content2: str = ''
for section in sections:
if ctr == 0:
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.sort(reverse=True)
text = ''
text: str = ''
for line in new_common_emoji:
text += line + '\n'
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:
"""Combines separate lines
"""
result = ''
ctr = 0
result: str = ''
ctr: int = 0
paragraphs = text.split('\n\n')
replacements = {
'\n* ': '***BULLET POINT*** ',
@ -1953,7 +1953,7 @@ def limit_repeated_words(text: str, max_repeats: int) -> str:
new_text = ((prev_word + ' ') * max_repeats).strip()
replacements[prev_word] = [repeated_text, new_text]
repeat_ctr = 0
repeated_text = ''
repeated_text: str = ''
prev_word = word
if repeat_ctr > max_repeats:

View File

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

View File

@ -756,7 +756,7 @@ def daemon_http_get(self) -> None:
('/private_account_notes/' in self.path or
self.path.endswith('/private_account_notes'))):
nickname = get_nickname_from_actor(self.path)
handle = ''
handle: str = ''
if '/private_account_notes/' in self.path:
handle = self.path.split('/private_account_notes/', 1)[1]
if nickname:
@ -785,7 +785,7 @@ def daemon_http_get(self) -> None:
return
if authorized and self.path.endswith('/bots.txt'):
known_bots_str = ''
known_bots_str: str = ''
for bot_name in self.server.known_bots:
known_bots_str += bot_name + '\n'
msg = known_bots_str.encode('utf-8')
@ -2066,7 +2066,7 @@ def daemon_http_get(self) -> None:
item_id = self.path.split('?showshare=')[1]
if '?' in item_id:
item_id = item_id.split('?')[0]
category = ''
category: str = ''
if '?category=' in self.path:
category = self.path.split('?category=')[1]
if '?' in category:
@ -4286,7 +4286,7 @@ def daemon_http_get(self) -> None:
in_reply_to_url = None
reply_to_list: list[str] = []
reply_page_number = 1
reply_category = ''
reply_category: str = ''
share_description = None
conversation_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)
crawlers_list.append(hits_str + ' ' + ua_str)
crawlers_list.sort(reverse=True)
msg = ''
msg: str = ''
for line_str in crawlers_list:
msg += line_str + '\n'
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]
if '?' in repeat_url:
repeat_url = repeat_url.split('?')[0]
first_post_id = ''
first_post_id: str = ''
if '?firstpost=' in path:
first_post_id = path.split('?firstpost=')[1]
if '?' in first_post_id:
first_post_id = first_post_id.split('?')[0]
first_post_id = first_post_id.replace('/', '--')
first_post_id = ';firstpost=' + first_post_id.replace('#', '--')
timeline_bookmark = ''
timeline_bookmark: str = ''
if '?bm=' in path:
timeline_bookmark = path.split('?bm=')[1]
if '?' in timeline_bookmark:
@ -323,7 +323,7 @@ def announce_button_undo(self, calling_domain: str, path: str,
if '?' in repeat_url:
repeat_url = repeat_url.split('?')[0]
first_post_id = ''
first_post_id: str = ''
if '?firstpost=' in path:
first_post_id = path.split('?firstpost=')[1]
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 = ';firstpost=' + first_post_id.replace('#', '--')
timeline_bookmark = ''
timeline_bookmark: str = ''
if '?bm=' in path:
timeline_bookmark = path.split('?bm=')[1]
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]
if '?' in bookmark_url:
bookmark_url = bookmark_url.split('?')[0]
first_post_id = ''
first_post_id: str = ''
if '?firstpost=' in path:
first_post_id = path.split('?firstpost=')[1]
if '?' in first_post_id:
first_post_id = first_post_id.split('?')[0]
first_post_id = first_post_id.replace('/', '--')
first_post_id = ';firstpost=' + first_post_id.replace('#', '--')
timeline_bookmark = ''
timeline_bookmark: str = ''
if '?bm=' in path:
timeline_bookmark = path.split('?bm=')[1]
if '?' in timeline_bookmark:
@ -305,14 +305,14 @@ def bookmark_button_undo(self, calling_domain: str, path: str,
bookmark_url = path.split('?unbookmark=')[1]
if '?' in bookmark_url:
bookmark_url = bookmark_url.split('?')[0]
first_post_id = ''
first_post_id: str = ''
if '?firstpost=' in path:
first_post_id = path.split('?firstpost=')[1]
if '?' in first_post_id:
first_post_id = first_post_id.split('?')[0]
first_post_id = first_post_id.replace('/', '--')
first_post_id = ';firstpost=' + first_post_id.replace('#', '--')
timeline_bookmark = ''
timeline_bookmark: str = ''
if '?bm=' in path:
timeline_bookmark = path.split('?bm=')[1]
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]
if '?' in like_url:
like_url = like_url.split('?')[0]
first_post_id = ''
first_post_id: str = ''
if '?firstpost=' in path:
first_post_id = path.split('?firstpost=')[1]
if '?' in first_post_id:
first_post_id = first_post_id.split('?')[0]
first_post_id = first_post_id.replace('/', '--')
first_post_id = ';firstpost=' + first_post_id.replace('#', '--')
timeline_bookmark = ''
timeline_bookmark: str = ''
if '?bm=' in path:
timeline_bookmark = path.split('?bm=')[1]
if '?' in timeline_bookmark:
@ -359,14 +359,14 @@ def like_button_undo(self, calling_domain: str, path: str,
like_url = path.split('?unlike=')[1]
if '?' in like_url:
like_url = like_url.split('?')[0]
first_post_id = ''
first_post_id: str = ''
if '?firstpost=' in path:
first_post_id = path.split('?firstpost=')[1]
if '?' in first_post_id:
first_post_id = first_post_id.split('?')[0]
first_post_id = first_post_id.replace('/', '--')
first_post_id = ';firstpost=' + first_post_id.replace('#', '--')
timeline_bookmark = ''
timeline_bookmark: str = ''
if '?bm=' in path:
timeline_bookmark = path.split('?bm=')[1]
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]
if '?' in mute_url:
mute_url = mute_url.split('?')[0]
first_post_id = ''
first_post_id: str = ''
if '?firstpost=' in path:
first_post_id = path.split('?firstpost=')[1]
if '?' in first_post_id:
first_post_id = first_post_id.split('?')[0]
first_post_id = first_post_id.replace('/', '--')
first_post_id = ';firstpost=' + first_post_id.replace('#', '--')
timeline_bookmark = ''
timeline_bookmark: str = ''
if '?bm=' in path:
timeline_bookmark = path.split('?bm=')[1]
if '?' in timeline_bookmark:
@ -257,14 +257,14 @@ def mute_button_undo(self, calling_domain: str, path: str,
mute_url = path.split('?unmute=')[1]
if '?' in mute_url:
mute_url = mute_url.split('?')[0]
first_post_id = ''
first_post_id: str = ''
if '?firstpost=' in path:
first_post_id = path.split('?firstpost=')[1]
if '?' in first_post_id:
first_post_id = first_post_id.split('?')[0]
first_post_id = first_post_id.replace('/', '--')
first_post_id = ';firstpost=' + first_post_id.replace('#', '--')
timeline_bookmark = ''
timeline_bookmark: str = ''
if '?bm=' in path:
timeline_bookmark = path.split('?bm=')[1]
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]
if '?' in reaction_url:
reaction_url = reaction_url.split('?')[0]
first_post_id = ''
first_post_id: str = ''
if '?firstpost=' in path:
first_post_id = path.split('?firstpost=')[1]
if '?' in first_post_id:
first_post_id = first_post_id.split('?')[0]
first_post_id = first_post_id.replace('/', '--')
first_post_id = ';firstpost=' + first_post_id.replace('#', '--')
timeline_bookmark = ''
timeline_bookmark: str = ''
if '?bm=' in path:
timeline_bookmark = path.split('?bm=')[1]
if '?' in timeline_bookmark:
@ -386,14 +386,14 @@ def reaction_button_undo(self, calling_domain: str, path: str,
reaction_url = path.split('?unreact=')[1]
if '?' in reaction_url:
reaction_url = reaction_url.split('?')[0]
first_post_id = ''
first_post_id: str = ''
if '?firstpost=' in path:
first_post_id = path.split('?firstpost=')[1]
if '?' in first_post_id:
first_post_id = first_post_id.split('?')[0]
first_post_id = first_post_id.replace('/', '--')
first_post_id = ';firstpost=' + first_post_id.replace('#', '--')
timeline_bookmark = ''
timeline_bookmark: str = ''
if '?bm=' in path:
timeline_bookmark = path.split('?bm=')[1]
if '?' in timeline_bookmark:

View File

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

View File

@ -53,11 +53,11 @@ def reaction_picker2(self, calling_domain: str, path: str,
instance_software: {}) -> None:
"""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]
if '?' in reaction_url:
reaction_url = reaction_url.split('?')[0]
timeline_bookmark = ''
timeline_bookmark: str = ''
if '?bm=' in path:
timeline_bookmark = path.split('?bm=')[1]
if '?' in timeline_bookmark:

View File

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

View File

@ -1739,7 +1739,7 @@ def show_mod_timeline(self, authorized: bool,
True,
0, positive_voting,
voting_time_mins)
moderation_action_str = ''
moderation_action_str: str = ''
if key_shortcuts.get(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
"""
users_path = path.replace('/sethashtagcategory', '')
hashtag = ''
hashtag: str = ''
if '/tags/' not in users_path:
# no hashtag is specified within the path
http_404(self, 14)

View File

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

View File

@ -128,9 +128,9 @@ def moderator_actions(self, path: str, calling_domain: str, cookie: str,
search_handle = \
search_nickname + '@' + search_domain
else:
search_handle = ''
search_handle: str = ''
else:
search_handle = ''
search_handle: str = ''
if '@' not in search_handle or \
'/@/' in 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_domain
else:
search_handle = ''
search_handle: str = ''
else:
search_handle = ''
search_handle: str = ''
if '@' not in search_handle:
# is this a local nickname on this instance?
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):
search_handle = local_handle
else:
search_handle = ''
search_handle: str = ''
if search_handle is None:
search_handle = ''
search_handle: str = ''
if '@' in search_handle:
msg = \
html_account_info(translate,

View File

@ -286,7 +286,7 @@ def citations_update(self, calling_domain: str, cookie: str,
citations.append(fields[field_name])
if citations:
citations_str = ''
citations_str: str = ''
for citation_date in citations:
citations_str += citation_date + '\n'
# 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')
handle = options_nickname + '@' + options_domain_full
if not person_notes:
person_notes = ''
person_notes: str = ''
set_person_notes(base_dir,
chooser_nickname,
domain,
@ -952,7 +952,7 @@ def _person_options_dm(self, options_confirm_params: str,
default_post_language2 = system_language
if default_post_language.get(nickname):
default_post_language2 = default_post_language[nickname]
default_buy_site = ''
default_buy_site: str = ''
searchable_by_default = 'yourself'
msg = \
html_new_post({}, False, translate,
@ -1206,7 +1206,7 @@ def _person_options_report(self, options_confirm_params: str,
default_post_language2 = system_language
if default_post_language.get(nickname):
default_post_language2 = default_post_language[nickname]
default_buy_site = ''
default_buy_site: str = ''
searchable_by_default = 'yourself'
msg = \
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:
""" HTTP POST save robots.txt file
"""
new_robots_txt = ''
new_robots_txt: str = ''
if fields.get('robotsTxt'):
new_robots_txt = fields['robotsTxt']
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())
if str(self.server.crawlers_allowed) != str(crawlers_allowed):
self.server.crawlers_allowed = crawlers_allowed
crawlers_allowed_str = ''
crawlers_allowed_str: str = ''
for uagent in crawlers_allowed:
if 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())
if str(self.server.user_agents_blocked) != str(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:
if 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:
""" HTTP POST set selected content warning lists
"""
new_lists_enabled = ''
new_lists_enabled: str = ''
for name, _ in self.server.cw_lists.items():
list_var_name = get_cw_list_variable(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
"""
# shared item federation domains
si_domain_updated = False
fed_domains_variable = "sharedItemsFederatedDomains"
fed_domains_str = get_config_param(base_dir, fed_domains_variable)
si_domain_updated: bool = False
fed_domains_variable: str = "sharedItemsFederatedDomains"
fed_domains_str: str = get_config_param(base_dir, fed_domains_variable)
if not fed_domains_str:
fed_domains_str = ''
shared_items_form_str = ''
fed_domains_str: str = ''
shared_items_form_str: str = ''
if fields.get('shareDomainList'):
shared_it_list = fed_domains_str.split(',')
for shared_federated_domain in shared_it_list:
@ -1564,8 +1564,8 @@ def _profile_post_alsoknownas(actor_json: {}, fields: {},
if actor_json.get('alsoKnownAs'):
also_known_as = actor_json['alsoKnownAs']
if fields.get('alsoKnownAs'):
also_known_as_str = ''
also_known_as_ctr = 0
also_known_as_str: str = ''
also_known_as_ctr: int = 0
for alt_actor in also_known_as:
if also_known_as_ctr > 0:
also_known_as_str += ', '
@ -1639,7 +1639,7 @@ def _profile_post_moved(actor_json: {}, fields: {},
"""
fieldnames = ('movedTo', 'copiedTo')
for fieldname in fieldnames:
moved_to = ''
moved_to: str = ''
if actor_json.get(fieldname):
if isinstance(actor_json[fieldname], str):
moved_to = remove_html(actor_json[fieldname])
@ -1869,7 +1869,7 @@ def _profile_post_birthday(fields: {}, actor_json: {},
actor_changed: bool) -> bool:
""" HTTP POST birthday on edit profile screen
"""
birth_date = ''
birth_date: str = ''
if actor_json.get('vcard:bday'):
birth_date = actor_json['vcard:bday']
if fields.get('birthDate'):
@ -2883,7 +2883,7 @@ def profile_edit(self, calling_domain: str, cookie: str,
post_image_filename)
post_bytes_str = post_bytes.decode('utf-8')
redirect_path = ''
redirect_path: str = ''
check_name_and_bio = False
on_final_welcome_screen = False
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:
"""Receive a vote on a question via POST
"""
first_post_id = ''
first_post_id: str = ''
if '?firstpost=' in path:
first_post_id = path.split('?firstpost=')[1]
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 = ';firstpost=' + first_post_id.replace('#', '--')
last_post_id = ''
last_post_id: str = ''
if '?lastpost=' in path:
last_post_id = path.split('?lastpost=')[1]
path = path.split('?lastpost=')[0]
@ -225,12 +225,12 @@ def _send_reply_to_question(self, base_dir: str,
event_date = None
event_time = None
event_end_time = None
event_category = ''
event_category: str = ''
location = None
conversation_id = None
convthread_id = None
buy_url = ''
chat_url = ''
buy_url: str = ''
chat_url: str = ''
city = get_spoofed_city(city_name, base_dir, nickname, domain)
languages_understood = \
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:
media_license_url = \
license_link_from_name(media_license_url)
media_creator = ''
media_creator: str = ''
if fields.get('mediaCreator'):
media_creator = fields['mediaCreator']
video_transcript = ''
video_transcript: str = ''
if fields.get('videoTranscript'):
video_transcript = fields['videoTranscript']
if fields.get('searchableByDropdown'):
@ -168,7 +168,7 @@ def _receive_new_post_process_newpost(self, fields: {},
# Append the address to the location if needed
if fields.get('locationAddress'):
location_str += ' <address>' + fields['locationAddress'] + '</address>'
event_category = ''
event_category: str = ''
if fields.get('eventCategory'):
event_category = fields['eventCategory']
message_json = \
@ -337,10 +337,10 @@ def _receive_new_post_process_newblog(self, fields: {},
if '://' not in media_license_url:
media_license_url = \
license_link_from_name(media_license_url)
media_creator = ''
media_creator: str = ''
if fields.get('mediaCreator'):
media_creator = fields['mediaCreator']
video_transcript = ''
video_transcript: str = ''
if fields.get('videoTranscript'):
video_transcript = fields['videoTranscript']
if fields.get('searchableByDropdown'):
@ -350,7 +350,7 @@ def _receive_new_post_process_newblog(self, fields: {},
# Append the address to the location if needed
if fields.get('locationAddress'):
location_str += ' <address>' + fields['locationAddress'] + '</address>'
event_category = ''
event_category: str = ''
if fields.get('eventCategory'):
event_category = fields['eventCategory']
message_json = \
@ -463,10 +463,10 @@ def _receive_new_post_process_editblog(self, fields: {},
content_map[system_language] = \
fields['message']
img_description = ''
img_description: str = ''
if fields.get('imageDescription'):
img_description = fields['imageDescription']
video_transcript = ''
video_transcript: str = ''
if fields.get('videoTranscript'):
video_transcript = fields['videoTranscript']
@ -479,7 +479,7 @@ def _receive_new_post_process_editblog(self, fields: {},
if '://' not in license_url:
license_url = \
license_link_from_name(license_url)
creator = ''
creator: str = ''
if fields.get('mediaCreator'):
creator = fields['mediaCreator']
post_json_object['object'] = \
@ -590,17 +590,17 @@ def _receive_new_post_process_newunlisted(self, fields: {},
if '://' not in media_license_url:
media_license_url = \
license_link_from_name(media_license_url)
media_creator = ''
media_creator: str = ''
if fields.get('mediaCreator'):
media_creator = fields['mediaCreator']
video_transcript = ''
video_transcript: str = ''
if fields.get('videoTranscript'):
video_transcript = fields['videoTranscript']
location_str = fields['location']
# Append the address to the location if needed
if fields.get('locationAddress'):
location_str += ' <address>' + fields['locationAddress'] + '</address>'
event_category = ''
event_category: str = ''
if fields.get('eventCategory'):
event_category = fields['eventCategory']
message_json = \
@ -764,10 +764,10 @@ def _receive_new_post_process_newfollowers(self, fields: {},
if '://' not in media_license_url:
media_license_url = \
license_link_from_name(media_license_url)
media_creator = ''
media_creator: str = ''
if fields.get('mediaCreator'):
media_creator = fields['mediaCreator']
video_transcript = ''
video_transcript: str = ''
if fields.get('videoTranscript'):
video_transcript = fields['videoTranscript']
if fields.get('searchableByDropdown'):
@ -777,7 +777,7 @@ def _receive_new_post_process_newfollowers(self, fields: {},
# Append the address to the location if needed
if fields.get('locationAddress'):
location_str += ' <address>' + fields['locationAddress'] + '</address>'
event_category = ''
event_category: str = ''
if fields.get('eventCategory'):
event_category = fields['eventCategory']
message_json = \
@ -954,10 +954,10 @@ def _receive_new_post_process_newdm(self, fields: {},
if '://' not in media_license_url:
media_license_url = \
license_link_from_name(media_license_url)
media_creator = ''
media_creator: str = ''
if fields.get('mediaCreator'):
media_creator = fields['mediaCreator']
video_transcript = ''
video_transcript: str = ''
if fields.get('videoTranscript'):
video_transcript = fields['videoTranscript']
location_str = fields['location']
@ -965,7 +965,7 @@ def _receive_new_post_process_newdm(self, fields: {},
if fields.get('locationAddress'):
location_str += \
' <address>' + fields['locationAddress'] + '</address>'
event_category = ''
event_category: str = ''
if fields.get('eventCategory'):
event_category = fields['eventCategory']
message_json = \
@ -1130,11 +1130,11 @@ def _receive_new_post_process_newreminder(self, fields: {}, nickname: str,
get_understood_languages(base_dir, http_prefix,
nickname, domain_full,
person_cache)
media_license_url = ''
media_creator = ''
media_license_url: str = ''
media_creator: str = ''
if fields.get('mediaCreator'):
media_creator = fields['mediaCreator']
video_transcript = ''
video_transcript: str = ''
if fields.get('videoTranscript'):
video_transcript = fields['videoTranscript']
location_str = fields['location']
@ -1142,7 +1142,7 @@ def _receive_new_post_process_newreminder(self, fields: {}, nickname: str,
if fields.get('locationAddress'):
location_str += \
' <address>' + fields['locationAddress'] + '</address>'
event_category = ''
event_category: str = ''
if fields.get('eventCategory'):
event_category = fields['eventCategory']
message_json = \
@ -1268,10 +1268,10 @@ def _receive_new_post_process_newreport(self, fields: {},
if '://' not in media_license_url:
media_license_url = \
license_link_from_name(media_license_url)
media_creator = ''
media_creator: str = ''
if fields.get('mediaCreator'):
media_creator = fields['mediaCreator']
video_transcript = ''
video_transcript: str = ''
if fields.get('videoTranscript'):
video_transcript = fields['videoTranscript']
message_json = \
@ -1369,10 +1369,10 @@ def _receive_new_post_process_newquestion(self, fields: {},
if '://' not in media_license_url:
media_license_url = \
license_link_from_name(media_license_url)
media_creator = ''
media_creator: str = ''
if fields.get('mediaCreator'):
media_creator = fields['mediaCreator']
video_transcript = ''
video_transcript: str = ''
if fields.get('videoTranscript'):
video_transcript = fields['videoTranscript']
message_json = \
@ -1482,10 +1482,10 @@ def _receive_new_post_process_newreading(self, fields: {},
if '://' not in media_license_url:
media_license_url = \
license_link_from_name(media_license_url)
media_creator = ''
media_creator: str = ''
if fields.get('mediaCreator'):
media_creator = fields['mediaCreator']
video_transcript = ''
video_transcript: str = ''
if fields.get('videoTranscript'):
video_transcript = fields['videoTranscript']
conversation_id = None
@ -1505,7 +1505,7 @@ def _receive_new_post_process_newreading(self, fields: {},
if fields.get('locationAddress'):
location_str += \
' <address>' + fields['locationAddress'] + '</address>'
event_category = ''
event_category: str = ''
if fields.get('eventCategory'):
event_category = fields['eventCategory']
# 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 ' +
last_used_filename)
mentions_str = ''
mentions_str: str = ''
if fields.get('mentions'):
mentions_str = fields['mentions'].strip() + ' '
if not fields.get('commentsEnabled'):
@ -2042,11 +2042,11 @@ def _receive_new_post_process(self, post_type: str, path: str, headers: {},
else:
comments_enabled = True
buy_url = ''
buy_url: str = ''
if fields.get('buyUrl'):
buy_url = fields['buyUrl']
chat_url = ''
chat_url: str = ''
if fields.get('chatUrl'):
chat_url = fields['chatUrl']

View File

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

View File

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

View File

@ -1286,7 +1286,7 @@ def _command_options() -> None:
argb.language = 'en'
if not argb.domain:
argb.domain = get_config_param(base_dir, 'domain')
domain = ''
domain: str = ''
if argb.domain:
domain = argb.domain
signing_priv_key_pem = None
@ -1371,7 +1371,7 @@ def _command_options() -> None:
}
if not argb.domain:
argb.domain = get_config_param(base_dir, 'domain')
domain = ''
domain: str = ''
if argb.domain:
domain = argb.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)
if not argb.domain:
argb.domain = get_config_param(base_dir, 'domain')
domain = ''
domain: str = ''
if argb.domain:
domain = argb.domain
if not domain:
print('Please specify a domain with the --domain option')
sys.exit()
nickname = ''
nickname: str = ''
if argb.nickname:
nickname = argb.nickname
if not nickname:
@ -1479,7 +1479,7 @@ def _command_options() -> None:
}
if not argb.domain:
argb.domain = get_config_param(base_dir, 'domain')
domain = ''
domain: str = ''
if argb.domain:
domain = argb.domain
signing_priv_key_pem = get_instance_actor_key(base_dir, domain)
@ -1502,7 +1502,7 @@ def _command_options() -> None:
session = create_session(None)
if not argb.domain:
argb.domain = get_config_param(base_dir, 'domain')
domain = ''
domain: str = ''
if argb.domain:
domain = argb.domain
test_vcard = get_vcard(False, session, argb.vcard,
@ -1516,7 +1516,7 @@ def _command_options() -> None:
session = create_session(None)
if not argb.domain:
argb.domain = get_config_param(base_dir, 'domain')
domain = ''
domain: str = ''
if argb.domain:
domain = argb.domain
test_vcard = get_vcard(True, session, argb.xmlvcard,
@ -1534,7 +1534,7 @@ def _command_options() -> None:
}
if not argb.domain:
argb.domain = get_config_param(base_dir, 'domain')
domain = ''
domain: str = ''
if argb.domain:
domain = argb.domain
signing_priv_key_pem = get_instance_actor_key(base_dir, domain)
@ -1565,7 +1565,7 @@ def _command_options() -> None:
}
if not argb.domain:
argb.domain = get_config_param(base_dir, 'domain')
domain = ''
domain: str = ''
if argb.domain:
domain = argb.domain
if not domain:
@ -3959,7 +3959,7 @@ def _command_options() -> None:
test_event_date = None
test_event_time = None
test_event_end_time = None
test_event_category = ''
test_event_category: str = ''
test_location = None
test_is_article = False
conversation_id = None
@ -3967,10 +3967,10 @@ def _command_options() -> None:
low_bandwidth = False
languages_understood = [argb.language]
translate = {}
buy_url = ''
chat_url = ''
buy_url: str = ''
chat_url: str = ''
auto_cw_cache = {}
test_video_transcript = ''
test_video_transcript: str = ''
searchable_by: list[str] = []
curr_session = None
@ -4165,7 +4165,7 @@ def _command_options() -> None:
if no_of_books:
argb.no_of_books = int(no_of_books)
content_license_url = ''
content_license_url: str = ''
if argb.content_license_url:
content_license_url = argb.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:
crawlers_allowed.append(crawlers_allowed_str2.strip())
lists_enabled = ''
lists_enabled: str = ''
if argb.lists_enabled:
lists_enabled = argb.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 ' +
followers_file)
if followers_str is None:
followers_str = ''
followers_str: str = ''
if handle in followers_str:
already_following = True
@ -668,7 +668,7 @@ def store_follow_request(base_dir: str,
load_string(followers_filename,
'EX: store_follow_request ' + followers_filename)
if followers_str is None:
followers_str = ''
followers_str: str = ''
if approve_handle in followers_str:
already_following = True
@ -1557,7 +1557,7 @@ def remove_follower(base_dir: str,
handle = remove_nickname + '@' + remove_domain
handle = handle.lower()
new_followers_str = ''
new_followers_str: str = ''
found = False
for handle2 in followers_list:
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 ' +
followers_filename)
if foll_text is None:
foll_text = ''
foll_text: str = ''
if search_domain not in foll_text:
return []
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,
'EX: _receive_calendar_events ' + calendar_filename)
if following_handles is None:
following_handles = ''
following_handles: str = ''
else:
# create a new calendar file from the following file
print('Creating calendar file ' + calendar_filename)
@ -139,7 +139,7 @@ def _receive_calendar_events(base_dir: str, nickname: str, domain: str,
# already added
return
# remove from calendar file
new_following_handles = ''
new_following_handles: str = ''
following_handles_list = following_handles.split('\n')
handle_lower = handle.lower()
for followed in following_handles_list:

View File

@ -87,7 +87,7 @@ def get_image_formats() -> str:
"""
image_ext = get_image_extensions()
image_formats = ''
image_formats: str = ''
for ext in image_ext:
if image_formats:
image_formats += ', '
@ -101,7 +101,7 @@ def get_media_formats() -> str:
"""
media_ext = get_media_extensions()
media_formats = ''
media_formats: str = ''
for ext in media_ext:
if 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:
sections = content_text.split('://')
ctr = 0
prev_section = ''
prev_section: str = ''
for section in sections:
if ctr > 0:
link_str = section
@ -100,7 +100,7 @@ def blog_to_gemini(base_dir: str, nickname: str, domain: str,
# get attachments
post_attachments = get_post_attachments(message_json)
if post_attachments:
descriptions = ''
descriptions: str = ''
for attach in post_attachments:
if not isinstance(attach, dict):
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
"""
patch_lines = patch_str.split('\n')
description = ''
description: str = ''
started = False
for line in patch_lines:
if started:
@ -167,7 +167,7 @@ def _git_add_from_handle(patch_str: str, handle: str) -> str:
return patch_str
patch_lines = patch_str.split('\n')
patch_str = ''
patch_str: str = ''
for line in patch_lines:
patch_str += line + '\n'
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:
"""Returns a day's events in icalendar format
"""
ical_str = ''
ical_str: str = ''
print('icalendar: ' + str(day_events))
for event_post in day_events:
event_description = None
event_place = None
post_id = None
sender_name = ''
sender_name: str = ''
sender_actor = None
event_is_public = False
event_start = None
@ -979,7 +979,7 @@ def _dav_store_event(base_dir: str, nickname: str, domain: str,
if not end_time:
return False
post_id = ''
post_id: str = ''
post_context = get_individual_post_context()
# create the status number from DTSTAMP
status_number, published = get_status_number(published)
@ -1056,7 +1056,7 @@ def _dav_store_event(base_dir: str, nickname: str, domain: str,
}
if location:
# get the location link
location_url = ''
location_url: str = ''
if '://' in location:
location_words = location.split(' ')
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 = _dav_date_from_string(query_end_time_str)
text_match = ''
text_match: str = ''
if ':text-match' in xml_str_lower:
match_str = xml_str_lower.split(':text-match')[1]
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:
text_match = text_match.split('<')[0]
else:
text_match = ''
text_match: str = ''
ical_events = None
etag = None
events_href = ''
responses = ''
events_href: str = ''
responses: str = ''
search_date = datetime.now()
if query_start_time and query_end_time:
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:response>\n'
if not responses:
all_events = ''
all_events: str = ''
for year in range(query_start_year, query_end_year+1):
if query_start_year == query_end_year:
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
signed_header_keys = headers.keys()
signed_header_text = ''
signed_header_text: str = ''
for header_key in signed_header_keys:
signed_header_text += f'{header_key}: {headers[header_key]}\n'
# strip the trailing linefeed
@ -198,7 +198,7 @@ def sign_post_headers_new(date_str: str, private_key_pem: str,
None, backend=default_backend())
# build a digest for signing
signed_header_keys = headers.keys()
signed_header_text = ''
signed_header_text: str = ''
for header_key in signed_header_keys:
signed_header_text += f'{header_key}: {headers[header_key]}\n'
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')
# Sign the digest. Potentially other signing algorithms can be added here.
signature = ''
signature: str = ''
if algorithm == 'rsa-sha512':
header_digest = get_sha_512(signed_header_text.encode('ascii'))
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'))
else:
print('Unknown http digest algorithm: ' + digest_algorithm)
header_digest = ''
header_digest: str = ''
padding_str = padding.PKCS1v15()
try:

View File

@ -597,7 +597,7 @@ def save_post_to_inbox_queue(base_dir: str, http_prefix: str,
curr_time = date_utcnow()
post_id = None
published = ''
published: str = ''
if post_json_object.get('id'):
post_id = remove_id_ending(post_json_object['id'])
published = curr_time.strftime("%Y-%m-%dT%H:%M:%SZ")
@ -1200,7 +1200,7 @@ def _send_to_group_members(server, session, session_onion,
else:
if group_actor != post_json_object['to']:
return
cc_str = ''
cc_str: str = ''
nickname = handle.split('@')[0].replace('!', '')
# 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
attach_image_filename = None
media_type = None
image_description = ''
image_description: str = ''
video_transcript = None
city = 'London, England'
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_time = None
event_end_time = None
event_category = ''
event_category: str = ''
location = None
conversation_id = None
convthread_id = None
low_bandwidth = False
buy_url = ''
chat_url = ''
buy_url: str = ''
chat_url: str = ''
auto_cw_cache = {}
post_json_object = \
create_direct_message_post(base_dir, nickname, domain, port,
@ -4077,7 +4077,7 @@ def run_inbox_queue(server,
inbox_start_time = time.time()
lists_enabled = get_config_param(base_dir, "listsEnabled")
dm_license_url = ''
dm_license_url: str = ''
fitness_performance(inbox_start_time, server.fitness,
'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'],
person_cache)
if prev_avatar_url is None:
prev_avatar_url = ''
prev_avatar_url: str = ''
_notify_moved(base_dir, domain_full,
prev_nickname + '@' + prev_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)
if not lang_list:
return ''
languages_str = ''
languages_str: str = ''
for lang in lang_list:
if languages_str:
languages_str += ' / ' + lang
@ -65,7 +65,7 @@ def set_actor_languages(actor_json: {}, languages_str: str) -> None:
lang_list = languages_str.lower().split(separator)
else:
lang_list = [languages_str.lower()]
lang_list2 = ''
lang_list2: str = ''
for lang in lang_list:
lang = lang.strip()
if lang_list2:
@ -169,7 +169,7 @@ def libretranslate_languages(url: str, api_key: str) -> []:
req = request.Request(url, data=url_params.encode())
response_str = ''
response_str: str = ''
with request.urlopen(req) as response:
response_str = response.read().decode()

View File

@ -193,7 +193,7 @@ def manual_approve_follow_request(session, session_onion, session_i2p,
return
# is the handle in the requests file?
approve_follows_str = ''
approve_follows_str: str = ''
try:
with open(approve_follows_filename, 'r', encoding='utf-8') as fp_foll:
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:
"""returns location address as a string
"""
location_str = ''
location_str: str = ''
address_section_name = (
'streetAddress',
'addressLocality',
@ -129,7 +129,7 @@ def _get_category_from_tags(tags: [], translate: {}) -> str:
if translate.get(category_str):
return translate[category_str]
if isinstance(evnt['category'], list):
category_str = ''
category_str: str = ''
for category_item in evnt['category']:
if not isinstance(category_item, str):
continue
@ -359,7 +359,7 @@ def get_location_from_post(post_json_object: {}) -> str:
def get_category_from_post(post_json_object: {}, translate: {}) -> str:
"""Returns the location category for the given post
"""
catstr = ''
catstr: str = ''
# location represented via a tag
post_obj = post_json_object
@ -376,7 +376,7 @@ def get_category_from_post(post_json_object: {}, translate: {}) -> str:
if translate.get(text):
catstr = translate[text]
elif isinstance(text, list):
catstr = ''
catstr: str = ''
for cat_text in text:
if not isinstance(cat_text, str):
continue
@ -1005,7 +1005,7 @@ def get_map_links_from_post_content(content: str, session) -> []:
continue
if ',' not in link_str:
continue
coords_str = ''
coords_str: str = ''
for char in link_str:
if not char.isnumeric() and char not in (',', '-', '.'):
break
@ -1058,7 +1058,7 @@ def add_tag_map_links(tag_maps_dir: str, tag_name: str,
# sort the list of map links
existing_map_links.sort(reverse=True)
map_links_str = ''
map_links_str: str = ''
ctr = 0
for link in existing_map_links:
if not link:
@ -1264,7 +1264,7 @@ def html_hashtag_maps(base_dir: str, tag_name: str,
time_period = _get_tagmaps_time_periods()
html_str = ''
html_str: str = ''
map_str = None
ua_str_lower = ua_str.lower()
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)
if not lines:
return
newlines = ''
newlines: str = ''
for file_line in lines:
if post_id in file_line:
# 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 = markdown_to_html(remove_html(welcome_text))
else:
welcome_text = ''
welcome_form = ''
welcome_text: str = ''
welcome_form: str = ''
css_filename = base_dir + '/epicyon-welcome.css'
if os.path.isfile(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 = markdown_to_html(remove_html(final_text))
else:
final_text = ''
final_text: str = ''
final_form = ''
final_form: str = ''
css_filename = base_dir + '/epicyon-welcome.css'
if os.path.isfile(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 = markdown_to_html(remove_html(profile_text))
else:
profile_text = ''
profile_text: str = ''
profile_form = ''
profile_form: str = ''
css_filename = base_dir + '/epicyon-welcome.css'
if os.path.isfile(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',
display_nickname)
bio_str = ''
bio_str: str = ''
if actor_json.get('summary'):
replacements = {
'<p>': '',

View File

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