diff --git a/utils.py b/utils.py index a62205c35..3954852ab 100644 --- a/utils.py +++ b/utils.py @@ -237,7 +237,7 @@ def remove_markup_tag(html: str, tag: str) -> str: return html section = html.split('<' + tag) - result = '' + result: str = '' for text in section: if not result: if html.startswith('<' + tag) and '>' in text: @@ -249,7 +249,7 @@ def remove_markup_tag(html: str, tag: str) -> str: html = result section = html.split('' in text: @@ -292,8 +292,8 @@ def get_content_from_post(post_json_object: {}, system_language: str, if not this_post_json.get(content_type) and \ not has_contentmap_dict: return '' - content = '' - replacements = { + content: str = '' + replacements: dict = { '&': '&', '': '', '': '' @@ -378,7 +378,7 @@ def get_media_descriptions_from_post(post_json_object: {}) -> str: post_attachments = get_post_attachments(post_json_object) if not post_attachments: return '' - descriptions = '' + descriptions: str = '' for attach in post_attachments: if not isinstance(attach, dict): print('WARN: attachment is not a dict ' + str(attach)) @@ -426,7 +426,7 @@ def get_summary_from_post(post_json_object: {}, system_language: str, if summary_str: summary_str = summary_str.strip() if not _valid_summary(summary_str): - summary_str = '' + summary_str: str = '' return summary_str @@ -626,7 +626,7 @@ def remove_html(content: str) -> str: '
': '\n' } content = replace_strings(content, replacements) - result = '' + result: str = '' for char in content: if char == '<': removing = True @@ -639,7 +639,7 @@ def remove_html(content: str) -> str: # insert spaces after full stops str_len = len(plain_text) - result = '' + result: str = '' for i in range(str_len): result += plain_text[i] if plain_text[i] == '.' and i < str_len - 1: @@ -668,8 +668,8 @@ def remove_style_within_html(content: str) -> str: if ' style="' not in content: return content sections = content.split(' style="') - result = '' - ctr = 0 + result: str = '' + ctr: int = 0 for section_text in sections: if ctr > 0: result += section_text.split('"', 1)[1] @@ -701,7 +701,7 @@ def get_memorials(base_dir: str) -> str: memorial_str = load_string(memorial_file, 'EX: unable to read ' + memorial_file) if memorial_str is None: - memorial_str = '' + memorial_str: str = '' return memorial_str @@ -710,7 +710,7 @@ def set_memorials(base_dir: str, domain: str, memorial_str) -> None: """ # check that the accounts exist memorial_list = memorial_str.split('\n') - new_memorial_str = '' + new_memorial_str: str = '' for memorial_item in memorial_list: memorial_nick = memorial_item.strip() check_dir = acct_dir(base_dir, memorial_nick, domain) @@ -1600,7 +1600,7 @@ def follow_person(base_dir: str, nickname: str, domain: str, if os.path.isfile(unfollowed_filename): if text_in_file(handle_to_follow, unfollowed_filename): # remove them from the unfollowed file - new_lines = '' + new_lines: str = '' lines: list[str] = \ load_list(unfollowed_filename, 'EX: follow_person unable to read ' + @@ -1804,7 +1804,7 @@ def _remove_attachment(base_dir: str, http_prefix: str, load_string(account_media_log_filename, 'EX: _remove unable to read media log for ' + nickname) if media_log_text is None: - media_log_text = '' + media_log_text: str = '' if search_filename + '\n' in media_log_text: media_log_text = media_log_text.replace(search_filename + '\n', '') save_string(media_log_text, account_media_log_filename, @@ -2106,7 +2106,7 @@ def _delete_conversation_post(base_dir: str, nickname: str, domain: str, 'EX: _delete_conversation_post unable to read ' + conversation_filename) if conversation_str is None: - conversation_str = '' + conversation_str: str = '' if post_id + '\n' not in conversation_str: return False conversation_str = conversation_str.replace(post_id + '\n', '') @@ -2182,7 +2182,7 @@ def _is_remote_dm(domain_full: str, post_json_object: {}) -> bool: def get_gemini_blog_title(message_json: dict, system_language: str) -> str: """Returns the title for a gemini blog post """ - title_text = '' + title_text: str = '' title_str = get_summary_from_post(message_json, system_language, []) if title_str: title_text = remove_html(title_str) @@ -2540,7 +2540,7 @@ def get_nickname_validation_pattern() -> str: """Returns a html text input validation pattern for nickname """ reserved_names = _get_reserved_words() - pattern = '' + pattern: str = '' for word in reserved_names: if pattern: pattern += '(?!.*\\b' + word + '\\b)' @@ -2706,7 +2706,7 @@ def camel_case_split(text: str) -> str: '(?<=[A-Z])(?=[A-Z][a-z])|$)', text) if not matches: return text - result_str = '' + result_str: str = '' for word in matches: result_str += word.group(0) + ' ' return result_str.strip() @@ -2723,9 +2723,9 @@ def _convert_to_camel_case(text: str) -> str: """ if '_' not in text: return text - words = text.split('_') - result = '' - ctr = 0 + words: list = text.split('_') + result: str = '' + ctr: int = 0 for wrd in words: if ctr > 0: result += wrd.title() @@ -2842,7 +2842,7 @@ def user_agent_domain(user_agent: str, debug: bool) -> str: """ if 'https://' not in user_agent and 'http://' not in user_agent: return None - agent_domain = '' + agent_domain: str = '' if 'https://' in user_agent: agent_domain = user_agent.split('https://')[1].strip() else: @@ -2950,7 +2950,7 @@ def get_port_from_domain(domain: str) -> int: if ':' in domain: if domain.startswith('did:'): return None - port_str = '' + port_str: str = '' if ']:' not in domain: if '[' not in domain: port_str = domain.split(':')[1] @@ -4148,8 +4148,8 @@ def get_image_file(base_dir: str, name: str, directory: str, """returns the filenames for an image with the given name """ banner_extensions = get_image_extensions() - banner_file = '' - banner_filename = '' + banner_file: str = '' + banner_filename: str = '' im_name = name for ext in banner_extensions: banner_file_test = im_name + '.' + ext diff --git a/webapp_about.py b/webapp_about.py index f7c19bf65..269aa5ae1 100644 --- a/webapp_about.py +++ b/webapp_about.py @@ -41,7 +41,7 @@ def html_about(base_dir: str, http_prefix: str, if about_text: about_text = markdown_to_html(about_text) - about_form = '' + about_form: str = '' css_filename = base_dir + '/epicyon-profile.css' if os.path.isfile(base_dir + '/epicyon.css'): css_filename = base_dir + '/epicyon.css' diff --git a/webapp_accesskeys.py b/webapp_accesskeys.py index 5acdebc11..c60265d38 100644 --- a/webapp_accesskeys.py +++ b/webapp_accesskeys.py @@ -59,7 +59,7 @@ def html_access_keys(base_dir: str, timeline_key = access_keys['menuTimeline'] submit_key = access_keys['submitButton'] - access_keys_form = '' + access_keys_form: str = '' css_filename = base_dir + '/epicyon-profile.css' if os.path.isfile(base_dir + '/epicyon.css'): css_filename = base_dir + '/epicyon.css' diff --git a/webapp_calendar.py b/webapp_calendar.py index 25e96c55e..5a8bfe400 100644 --- a/webapp_calendar.py +++ b/webapp_calendar.py @@ -189,14 +189,14 @@ def _html_calendar_day(person_cache: {}, translate: {}, event_time = None event_time_markup = None event_end_time = None - start_time_str = '' - end_time_str = '' + start_time_str: str = '' + end_time_str: str = '' event_description = None event_language = system_language event_place = None event_address = None post_id = None - sender_name = '' + sender_name: str = '' sender_actor = None event_is_public = False # get the time place and description @@ -271,7 +271,7 @@ def _html_calendar_day(person_cache: {}, translate: {}, event_description = \ translate['Reminder'] + ': ' + event_description - delete_button_str = '' + delete_button_str: str = '' if post_id: delete_button_str = \ ' str: """Returns html content for the left column """ - html_str = '' + html_str: str = '' separator_str = html_post_separator(base_dir, 'left') domain = remove_domain_port(domain_full) - edit_image_class = '' + edit_image_class: str = '' if show_header_image: left_image_file, left_column_image_filename = \ get_left_image_file(base_dir, nickname, domain, theme) @@ -386,7 +386,7 @@ def html_links_mobile(base_dir: str, known_epicyon_instances: []) -> str: """Show the left column links within mobile view """ - html_str = '' + html_str: str = '' # the css filename css_filename = base_dir + '/epicyon-profile.css' @@ -514,13 +514,13 @@ def html_edit_links(translate: {}, base_dir: str, path: str, ' \n' links_filename = data_dir(base_dir) + '/links.txt' - links_str = '' + links_str: str = '' if os.path.isfile(links_filename): links_str = load_string(links_filename, 'EX: html_edit_links unable to read ' + links_filename) if links_str is None: - links_str = '' + links_str: str = '' edit_links_form += \ '
' @@ -542,14 +542,14 @@ def html_edit_links(translate: {}, base_dir: str, path: str, if admin_nickname: if nickname == admin_nickname: about_filename = data_dir(base_dir) + '/about.md' - about_str = '' + about_str: str = '' if os.path.isfile(about_filename): about_str = \ load_string(about_filename, 'EX: html_edit_links unable to read 2 ' + about_filename) if about_str is None: - about_str = '' + about_str: str = '' edit_links_form += \ '
' @@ -565,13 +565,13 @@ def html_edit_links(translate: {}, base_dir: str, path: str, '
' tos_filename = data_dir(base_dir) + '/tos.md' - tos_str = '' + tos_str: str = '' if os.path.isfile(tos_filename): tos_str = load_string(tos_filename, 'EX: html_edit_links unable to read 3 ' + tos_filename) if tos_str is None: - tos_str = '' + tos_str: str = '' edit_links_form += \ '
' @@ -587,14 +587,14 @@ def html_edit_links(translate: {}, base_dir: str, path: str, '
' specification_filename = data_dir(base_dir) + '/activitypub.md' - specification_str = '' + specification_str: str = '' if os.path.isfile(specification_filename): specification_str = \ load_string(specification_filename, 'EX: html_edit_links unable to read 4 ' + specification_filename) if specification_str is None: - specification_str = '' + specification_str: str = '' edit_links_form += \ '
' diff --git a/webapp_column_right.py b/webapp_column_right.py index a638c4002..93552d6c4 100644 --- a/webapp_column_right.py +++ b/webapp_column_right.py @@ -68,7 +68,7 @@ def get_right_column_content(base_dir: str, nickname: str, domain_full: str, access_keys: {}) -> str: """Returns html content for the right column """ - html_str = '' + html_str: str = '' domain = remove_domain_port(domain_full) @@ -98,7 +98,7 @@ def get_right_column_content(base_dir: str, nickname: str, domain_full: str, html_str += '
' + publish_button_str + '
' # show a column header image, eg. title of the theme or newswire banner - edit_image_class = '' + edit_image_class: str = '' if show_header_image: right_image_file, right_column_image_filename = \ get_right_image_file(base_dir, nickname, domain, theme) @@ -236,12 +236,12 @@ def _html_newswire(base_dir: str, newswire: {}, nickname: str, moderator: bool, """Converts a newswire dict into html """ separator_str = html_post_separator(base_dir, 'right') - html_str = '' - replacements1 = { + html_str: str = '' + replacements1: dict = { 'T': ' ', 'Z': '' } - replacements2 = { + replacements2: dict = { ' ': '__', ':': 'aa' } @@ -265,7 +265,7 @@ def _html_newswire(base_dir: str, newswire: {}, nickname: str, moderator: bool, date_str_link = replace_strings(date_str, replacements1) url = item[1] favicon_url = get_newswire_favicon_url(url) - favicon_link = '' + favicon_link: str = '' if favicon_url: cached_favicon_filename = \ get_fav_filename_from_url(base_dir, favicon_url) @@ -302,7 +302,7 @@ def _html_newswire(base_dir: str, newswire: {}, nickname: str, moderator: bool, html_str += separator_str if moderated_item and 'vote:' + nickname in item[2]: - total_votes_str = '' + total_votes_str: str = '' total_votes = 0 if moderator: total_votes = votes_on_newswire_item(item[2]) @@ -330,7 +330,7 @@ def _html_newswire(base_dir: str, newswire: {}, nickname: str, moderator: bool, html_str += ' ' html_str += date_shown + '

\n' else: - total_votes_str = '' + total_votes_str: str = '' total_votes = 0 if moderator: if moderated_item: @@ -376,7 +376,7 @@ def html_citations(base_dir: str, nickname: str, domain: str, theme: str) -> str: """Show the citations screen when creating a blog """ - html_str = '' + html_str: str = '' # create a list of dates for citations # these can then be used to re-select checkboxes later @@ -430,12 +430,12 @@ def html_citations(base_dir: str, nickname: str, domain: str, html_str += translate['Choose newswire items ' + 'referenced in your article'] + '
' if blog_title is None: - blog_title = '' + blog_title: str = '' html_str += \ ' \n' if blog_content is None: - blog_content = '' + blog_content: str = '' html_str += \ ' \n' @@ -460,7 +460,7 @@ def html_citations(base_dir: str, nickname: str, domain: str, if ']' in item[0]: item[0] = item[0].split(']')[0] # should this checkbox be selected? - selected_str = '' + selected_str: str = '' if date_str in citations_selected: selected_str = ' checked' @@ -502,7 +502,7 @@ def html_newswire_mobile(base_dir: str, nickname: str, ua_str: str) -> str: """Shows the mobile version of the newswire right column """ - html_str = '' + html_str: str = '' # the css filename css_filename = base_dir + '/epicyon-profile.css' @@ -637,14 +637,14 @@ def html_edit_newswire(translate: {}, base_dir: str, path: str, '
\n' newswire_filename = data_dir(base_dir) + '/newswire.txt' - newswire_str = '' + newswire_str: str = '' if os.path.isfile(newswire_filename): newswire_str = \ load_string(newswire_filename, 'EX: html_edit_newswire unable to read ' + newswire_filename) if newswire_str is None: - newswire_str = '' + newswire_str: str = '' edit_newswire_form += \ '
' @@ -661,7 +661,7 @@ def html_edit_newswire(translate: {}, base_dir: str, path: str, 'style="height:80vh" spellcheck="false">' + \ newswire_str + '' - filter_str = '' + filter_str: str = '' filter_filename = \ data_dir(base_dir) + '/news@' + domain + '/filters.txt' if os.path.isfile(filter_filename): @@ -670,7 +670,7 @@ def html_edit_newswire(translate: {}, base_dir: str, path: str, 'EX: html_edit_newswire unable to read 2 ' + filter_filename) if filter_str is None: - filter_str = '' + filter_str: str = '' edit_newswire_form += \ '
\n' - citations_str = '' + citations_str: str = '' if endpoint == 'newblog': citations_filename = \ acct_dir(base_dir, nickname, domain) + '/.citations.txt' @@ -956,8 +956,8 @@ def html_new_post(edit_post_params: {}, citations_str += ' \n' citations_str += '
\n' - replies_section = '' - date_and_location = '' + replies_section: str = '' + date_and_location: str = '' if endpoint not in ('newshare', 'newwanted', 'newreport', 'newquestion', 'newreadingstatus'): @@ -1159,7 +1159,7 @@ def html_new_post(edit_post_params: {}, banner_path + '" alt="" />
\n' + \ '\n' - mentions_str = '' + mentions_str: str = '' for ment in mentions: mention_nickname = get_nickname_from_actor(ment) if not mention_nickname: @@ -1186,13 +1186,13 @@ def html_new_post(edit_post_params: {}, dropdown_reminder_suffix = '/newreminder' dropdown_report_suffix = '/newreport' if in_reply_to or mentions: - dropdown_new_post_suffix = '' - dropdown_new_blog_suffix = '' - dropdown_unlisted_suffix = '' - dropdown_followers_suffix = '' - dropdown_dm_suffix = '' - dropdown_reminder_suffix = '' - dropdown_report_suffix = '' + dropdown_new_post_suffix: str = '' + dropdown_new_blog_suffix: str = '' + dropdown_unlisted_suffix: str = '' + dropdown_followers_suffix: str = '' + dropdown_dm_suffix: str = '' + dropdown_reminder_suffix: str = '' + dropdown_report_suffix: str = '' if in_reply_to: dropdown_new_post_suffix += '?replyto=' + in_reply_to dropdown_new_blog_suffix += '?replyto=' + in_reply_to @@ -1224,7 +1224,7 @@ def html_new_post(edit_post_params: {}, dropdown_followers_suffix += '?convthreadId=' + convthread_id dropdown_dm_suffix += '?convthreadId=' + convthread_id - drop_down_content = '' + drop_down_content: str = '' if not report_url and not share_description: account_dir = acct_dir(base_dir, nickname, domain) drop_down_content = \ @@ -1352,7 +1352,7 @@ def html_new_post(edit_post_params: {}, html_following_data_list(base_dir, nickname, domain, domain_full, 'following', True) new_post_form += '' - selected_str = '' + selected_str: str = '' if endpoint != 'newreadingstatus': new_post_form += \ @@ -1366,7 +1366,7 @@ def html_new_post(edit_post_params: {}, message_box_height = 800 # get the default message text - default_message = '' + default_message: str = '' if edited_post_json: content_str = \ get_content_from_post(edited_post_json, system_language, diff --git a/webapp_frontscreen.py b/webapp_frontscreen.py index 84b412008..329858b1b 100644 --- a/webapp_frontscreen.py +++ b/webapp_frontscreen.py @@ -55,10 +55,10 @@ def _html_front_screen_posts(recent_posts_cache: {}, max_recent_posts: int, which is the blog timeline of the news actor """ separator_str = html_post_separator(base_dir, None) - profile_str = '' - max_items = 4 - ctr = 0 - curr_page = 1 + profile_str: str = '' + max_items: int = 4 + ctr: int = 0 + curr_page: int = 1 box_name = 'tlfeatures' authorized = True while ctr < max_items and curr_page < 4: @@ -210,7 +210,7 @@ def html_front_screen(signing_priv_key_pem: str, if os.path.isfile(base_dir + '/epicyon.css'): css_filename = base_dir + '/epicyon.css' - license_str = '' + license_str: str = '' banner_file, _ = \ get_banner_file(base_dir, nickname, domain, theme) profile_str += \ diff --git a/webapp_hashtagswarm.py b/webapp_hashtagswarm.py index 21bc29616..301e4931c 100644 --- a/webapp_hashtagswarm.py +++ b/webapp_hashtagswarm.py @@ -67,7 +67,7 @@ def get_hashtag_categories_feed(base_dir: str, rss_str += \ '\n' + \ ' ' + escape_text(category_str) + '\n' - list_str = '' + list_str: str = '' for hashtag in hashtag_list: if ':' in hashtag: continue @@ -104,7 +104,7 @@ def html_hash_tag_swarm(base_dir: str, actor: str, translate: {}) -> str: # Load the blocked hashtags into memory. # This avoids needing to repeatedly load the blocked file for each hashtag - blocked_str = '' + blocked_str: str = '' global_blocking_filename = data_dir(base_dir) + '/blocking.txt' if os.path.isfile(global_blocking_filename): blocked_str = \ @@ -112,7 +112,7 @@ def html_hash_tag_swarm(base_dir: str, actor: str, translate: {}) -> str: 'EX: html_hash_tag_swarm unable to read ' + global_blocking_filename) if blocked_str is None: - blocked_str = '' + blocked_str: str = '' for _, _, files in os.walk(base_dir + '/tags'): for fname in files: @@ -215,7 +215,7 @@ def html_hash_tag_swarm(base_dir: str, actor: str, translate: {}) -> str: tag_swarm.sort() # swarm of categories - category_swarm_str = '' + category_swarm_str: str = '' if category_swarm: if len(category_swarm) > 3: category_swarm.sort() @@ -232,7 +232,7 @@ def html_hash_tag_swarm(base_dir: str, actor: str, translate: {}) -> str: category_swarm_str += '
\n' # swarm of tags - tag_swarm_str = '' + tag_swarm_str: str = '' for tag_name in tag_swarm: tag_display_name = tag_name tag_map_filename = \ @@ -382,7 +382,7 @@ def _store_tag_name(base_dir: str, nickname: str, 'EX: store_hash_tags failed to read ' + tags_filename) if content is None: - content = '' + content: str = '' if post_url not in content: content = tag_line + content if save_string(content, tags_filename, diff --git a/webapp_headerbuttons.py b/webapp_headerbuttons.py index a09893162..6b118c074 100644 --- a/webapp_headerbuttons.py +++ b/webapp_headerbuttons.py @@ -197,7 +197,7 @@ def header_buttons_timeline(default_timeline: str, translate['Inbox'] + '' # show todays events buttons on the first inbox page - happening_str = '' + happening_str: str = '' if box_name == 'inbox' and page_number == 1: now = datetime.now() tomorrow = datetime.now() + timedelta(1) diff --git a/webapp_likers.py b/webapp_likers.py index 85bcafd2a..ed1337257 100644 --- a/webapp_likers.py +++ b/webapp_likers.py @@ -161,7 +161,7 @@ def html_likers_of_post(base_dir: str, nickname: str, mutuals_list = get_mutuals_of_person(base_dir, nickname, domain) is_text_mode = text_mode_browser(ua_str) - likers_list = '' + likers_list: str = '' for like_item in obj[dict_name]['items']: if not like_item.get('actor'): continue @@ -189,12 +189,12 @@ def html_likers_of_post(base_dir: str, nickname: str, liker_avatar_url = \ get_person_avatar_url(base_dir, liker_actor, person_cache) if not liker_avatar_url: - liker_avatar_url = '' + liker_avatar_url: str = '' else: liker_avatar_url = ';' + liker_avatar_url # get the mutual icon prefix - mutual_prefix = '' + mutual_prefix: str = '' if liker_username: liker_domain, _ = get_domain_from_actor(liker_actor) if liker_domain: diff --git a/webapp_login.py b/webapp_login.py index a3613e809..17edd9b14 100644 --- a/webapp_login.py +++ b/webapp_login.py @@ -147,14 +147,14 @@ def html_login(translate: {}, 'EX: html_login unable to read ' + dir_str + '/login.txt') if login_text is None: - login_text = '' + login_text: str = '' css_filename = base_dir + '/epicyon-login.css' if os.path.isfile(base_dir + '/login.css'): css_filename = base_dir + '/login.css' # show the register button - register_button_str = '' + register_button_str: str = '' if get_config_param(base_dir, 'registration') == 'open': remaining = 0 if get_config_param(base_dir, 'registrationsRemaining'): @@ -178,7 +178,7 @@ def html_login(translate: {}, '' - login_button_str = '' + login_button_str: str = '' if accounts > 0: login_button_str = \ '\n' - person_notes = '' + person_notes: str = '' if origin_path_str == '/users/' + nickname: person_notes = \ get_person_notes(base_dir, nickname, domain, handle) diff --git a/webapp_podcast.py b/webapp_podcast.py index 628f16d08..57d5463ef 100644 --- a/webapp_podcast.py +++ b/webapp_podcast.py @@ -55,7 +55,7 @@ def _html_podcast_chapters(link_url: str, chapters_url = podcast_properties[key]['uri'] else: return '' - html_str = '' + html_str: str = '' if podcast_properties[key].get('type'): url_type = podcast_properties[key]['type'] @@ -82,7 +82,7 @@ def _html_podcast_chapters(link_url: str, return '' if not isinstance(chapters_json['chapters'], list): return '' - chapters_html = '' + chapters_html: str = '' for chapter in chapters_json['chapters']: if not isinstance(chapter, dict): continue @@ -91,7 +91,7 @@ def _html_podcast_chapters(link_url: str, if not chapter.get('startTime'): continue chapter_title = chapter['title'] - chapter_url = '' + chapter_url: str = '' if chapter.get('url'): url_str = get_url_from_post(chapter['url']) chapter_url = remove_html(url_str) @@ -131,8 +131,8 @@ def _html_podcast_transcripts(podcast_properties: {}, translate: {}) -> str: return '' if not isinstance(podcast_properties[key], list): return '' - ctr = 1 - html_str = '' + ctr: int = 1 + html_str: str = '' for _ in podcast_properties[key]: transcript_url = None if podcast_properties[key].get('url'): @@ -176,7 +176,7 @@ def _html_podcast_social_interactions(podcast_properties: {}, episode_post_url = podcast_properties[key]['text'] else: return '' - actor_str = '' + actor_str: str = '' podcast_account_id = None if podcast_properties[key].get('accountId'): podcast_account_id = podcast_properties[key]['accountId'] @@ -233,11 +233,11 @@ def _html_podcast_performers(podcast_properties: {}) -> str: performer_title += ', ' + performer['group'] + '' performer_title = remove_html(performer_title) - performer_url = '' + performer_url: str = '' if performer.get('href'): performer_url = remove_html(performer['href']) - performer_img = '' + performer_img: str = '' if performer.get('img'): performer_img = performer['img'] @@ -336,7 +336,7 @@ def html_podcast_episode(translate: {}, preload_images) podcast_properties = newswire_item[8] - image_url = '' + image_url: str = '' image_src = 'src' if podcast_properties.get('images'): if podcast_properties['images'].get('srcset'): @@ -483,7 +483,7 @@ def html_podcast_episode(translate: {}, '" rel="donation">

\n' - fediverse_handle = '' + fediverse_handle: str = '' if len(newswire_item) > 9: fediverse_handle = newswire_item[9] podcast_nickname = get_nickname_from_actor(fediverse_handle) @@ -497,7 +497,7 @@ def html_podcast_episode(translate: {}, if len(newswire_item) > 10: extra_links = newswire_item[10] if extra_links: - links_text = '' + links_text: str = '' for link_str in extra_links: link_str = remove_html(link_str) if not resembles_url(link_str): @@ -518,7 +518,7 @@ def html_podcast_episode(translate: {}, podcast_str += links_text if podcast_properties['categories']: - tags_str = '' + tags_str: str = '' for tag in podcast_properties['categories']: tag = tag.replace('#', '') if not tag: diff --git a/webapp_post.py b/webapp_post.py index 1d263957e..07089ff0d 100644 --- a/webapp_post.py +++ b/webapp_post.py @@ -407,7 +407,7 @@ def prepare_html_post_nickname(nickname: str, post_html: str) -> str: user_found = True post_str = post_html - new_post_str = '' + new_post_str: str = '' while user_found: if users_str not in post_str: new_post_str += post_str @@ -439,7 +439,7 @@ def replace_link_variable(link: str, variable_name: str, value: str, return link curr_str = link - result = '' + result: str = '' while full_var in curr_str: prefix = curr_str.split(full_var, 1)[0] + full_var next_str = curr_str.split(full_var, 1)[1] @@ -449,7 +449,7 @@ def replace_link_variable(link: str, variable_name: str, value: str, curr_str = next_str else: result += prefix + value - curr_str = '' + curr_str: str = '' return result + curr_str @@ -461,7 +461,7 @@ def _prepare_media_post_from_html_cache(post_html: str, 'this tag is not supported in your browser' """ sections = post_html.split('<' + media_type) - new_post_html = '' + new_post_html: str = '' for section_str in sections: ending_tag = '' if ending_tag not in section_str: @@ -469,8 +469,8 @@ def _prepare_media_post_from_html_cache(post_html: str, continue markup = section_str.split(ending_tag)[0] ending = section_str.split(ending_tag)[1] - url = '' - description = '' + url: str = '' + description: str = '' # get the video/audio url if it exists if ' src="' in markup: url = markup.split(' src="')[1] @@ -534,7 +534,7 @@ def prepare_post_from_html_cache(nickname: str, post_html: str, box_name: str, # add first post in the timeline if first_post_id is None: - first_post_id = '' + first_post_id: str = '' first_post_id = first_post_id.replace('#', '/') if '?firstpost=' in with_page_number: @@ -657,7 +657,7 @@ def _get_avatar_image_html(show_avatar_options: bool, if avatar_url.endswith('.svg'): avatar_url = '/icons/avatar_default.png' - avatar_link = '' + avatar_link: str = '' if '/users/news/' not in avatar_url: avatar_link = \ ' str: """Returns html for the edit icon/button """ - edit_str = '' + edit_str: str = '' actor = get_actor_from_post(post_json_object) # This should either be a post which you created, # or it could be generated from the newswire (see @@ -834,12 +834,12 @@ def _get_edit_icon_html(base_dir: str, nickname: str, domain_full: str, if '/statuses/' not in post_id: return edit_str - reply_to = '' + reply_to: str = '' reply_id = get_reply_to(post_json_object['object']) if reply_id: reply_to = ';replyTo=' + reply_id - first_post_str = '' + first_post_str: str = '' if first_post_id: first_post_str = ';firstpost=' + first_post_id @@ -978,7 +978,7 @@ def _get_announce_icon_html(is_announced: bool, first_post_id: str) -> str: """Returns html for announce icon/button at the bottom of the post """ - announce_str = '' + announce_str: str = '' if not show_repeat_icon: return announce_str @@ -989,17 +989,17 @@ def _get_announce_icon_html(is_announced: bool, # don't allow announce/repeat of your own posts announce_icon = 'repeat_inactive.png' announce_link = 'repeat' - announce_emoji = '' + announce_emoji: str = '' if not is_public_repeat: announce_link = 'repeatprivate' repeat_this_post_str = 'Repeat this post' if translate.get(repeat_this_post_str): repeat_this_post_str = translate[repeat_this_post_str] announce_title = repeat_this_post_str - unannounce_link_str = '' + unannounce_link_str: str = '' announce_count = no_of_announces(post_json_object) - announce_count_str = '' + announce_count_str: str = '' if announce_count > 0: if announce_count <= max_announce_count: announce_count_str = ' (' + str(announce_count) + ')' @@ -1009,7 +1009,7 @@ def _get_announce_icon_html(is_announced: bool, post_actor, nickname, domain_full): if announce_count == 1: # announced by the reader only - announce_count_str = '' + announce_count_str: str = '' announce_icon = 'repeat.png' announce_emoji = '🔁 ' announce_link = 'unrepeat' @@ -1027,7 +1027,7 @@ def _get_announce_icon_html(is_announced: bool, remove_hash_from_post_id(post_json_object['object']['id']) announce_post_id = remove_id_ending(announce_post_id) - announce_str = '' + announce_str: str = '' if announce_count_str: announcers_post_id = announce_post_id.replace('/', '--') announcers_screen_link = \ @@ -1042,7 +1042,7 @@ def _get_announce_icon_html(is_announced: bool, announce_count_str.replace('(', '').replace(')', '').strip() announce_str += '\n' - first_post_str = '' + first_post_str: str = '' if first_post_id: first_post_str = '?firstpost=' + first_post_id.replace('#', '/') @@ -1079,18 +1079,18 @@ def _get_like_icon_html(nickname: str, domain_full: str, """ if not show_like_button or is_moderation_post: return '' - like_str = '' + like_str: str = '' like_icon = 'like_inactive.png' like_link = 'like' like_title = 'Like this post' if translate.get(like_title): like_title = translate[like_title] - like_emoji = '' + like_emoji: str = '' like_count = no_of_likes(post_json_object) _log_post_timing(enable_timing_log, post_start_time, '12.1') - like_count_str = '' + like_count_str: str = '' if like_count > 0: if like_count <= max_like_count: like_count_str = ' (' + str(like_count) + ')' @@ -1099,7 +1099,7 @@ def _get_like_icon_html(nickname: str, domain_full: str, if liked_by_person(post_json_object, nickname, domain_full): if like_count == 1: # liked by the reader only - like_count_str = '' + like_count_str: str = '' like_icon = 'like.png' like_link = 'unlike' like_title = 'Undo the like' @@ -1112,7 +1112,7 @@ def _get_like_icon_html(nickname: str, domain_full: str, like_post_id = remove_hash_from_post_id(post_json_object['id']) like_post_id = remove_id_ending(like_post_id) - like_str = '' + like_str: str = '' if like_count_str: likers_post_id = like_post_id.replace('/', '--') likers_screen_link = \ @@ -1129,7 +1129,7 @@ def _get_like_icon_html(nickname: str, domain_full: str, like_str += like_count_str.replace('(', '').replace(')', '').strip() like_str += '\n' - first_post_str = '' + first_post_str: str = '' if first_post_id: first_post_str = '?firstpost=' + first_post_id.replace('#', '/') @@ -1165,7 +1165,7 @@ def _get_bookmark_icon_html(base_dir: str, post_url: str) -> str: """Returns html for bookmark icon/button """ - bookmark_str = '' + bookmark_str: str = '' if is_moderation_post: return bookmark_str @@ -1175,7 +1175,7 @@ def _get_bookmark_icon_html(base_dir: str, bookmark_icon = 'bookmark_inactive.png' bookmark_link = 'bookmark' - bookmark_emoji = '' + bookmark_emoji: str = '' bookmark_title = 'Bookmark this post' if translate.get(bookmark_title): bookmark_title = translate[bookmark_title] @@ -1191,7 +1191,7 @@ def _get_bookmark_icon_html(base_dir: str, remove_hash_from_post_id(post_json_object['object']['id']) bookmark_post_id = remove_id_ending(bookmark_post_id) - first_post_str = '' + first_post_str: str = '' if first_post_id: first_post_str = '?firstpost=' + first_post_id.replace('#', '/') @@ -1224,7 +1224,7 @@ def _get_reaction_icon_html(nickname: str, post_json_object: {}, first_post_id: str) -> str: """Returns html for reaction icon/button """ - reaction_str = '' + reaction_str: str = '' if not show_reaction_button or is_moderation_post: return reaction_str @@ -1238,7 +1238,7 @@ def _get_reaction_icon_html(nickname: str, post_json_object: {}, remove_hash_from_post_id(post_json_object['object']['id']) reaction_post_id = remove_id_ending(reaction_post_id) - first_post_str = '' + first_post_str: str = '' if first_post_id: first_post_str = '?firstpost=' + first_post_id.replace('#', '/') @@ -1271,13 +1271,13 @@ def _get_mute_icon_html(is_muted: bool, first_post_id: str) -> str: """Returns html for mute icon/button """ - mute_str = '' + mute_str: str = '' if (allow_deletion or ('/' + domain_full + '/' in post_actor and message_id.startswith(post_actor))): return mute_str - first_post_str = '' + first_post_str: str = '' if first_post_id: first_post_str = '?firstpost=' + first_post_id.replace('#', '/') @@ -1326,7 +1326,7 @@ def _get_delete_icon_html(nickname: str, domain_full: str, first_post_id: str) -> str: """Returns html for delete icon/button """ - delete_str = '' + delete_str: str = '' if (allow_deletion or ('/' + domain_full + '/' in post_actor and message_id.startswith(post_actor))): @@ -1336,7 +1336,7 @@ def _get_delete_icon_html(nickname: str, domain_full: str, if translate.get(delete_this_post_str): delete_this_post_str = translate[delete_this_post_str] - first_post_str = '' + first_post_str: str = '' if first_post_id: first_post_str = \ '?firstpost=' + first_post_id.replace('#', '/') @@ -1360,7 +1360,7 @@ def _get_published_date_str(post_json_object: {}, timezone: str) -> str: """Return the html for the published date on a post """ - published_str = '' + published_str: str = '' if not post_json_object['object'].get('published'): return published_str @@ -1402,7 +1402,7 @@ def _get_blog_citations_html(box_name: str, """Returns blog citations as html """ # show blog citations - citations_str = '' + citations_str: str = '' if box_name not in ('tlblogs', 'tlfeatures'): return citations_str @@ -1517,8 +1517,8 @@ def _get_post_title_announce_html(base_dir: str, """Returns the announce title of a post containing names of participants x announces y """ - title_str = '' - reply_avatar_image_in_post = '' + title_str: str = '' + reply_avatar_image_in_post: str = '' obj_json = post_json_object['object'] # has no attribution @@ -1530,7 +1530,7 @@ def _get_post_title_announce_html(base_dir: str, attributed_to = get_attributed_to(obj_json['attributedTo']) if attributed_to is None: - attributed_to = '' + attributed_to: str = '' # boosting your own post if attributed_to.startswith(post_actor): @@ -1551,7 +1551,7 @@ def _get_post_title_announce_html(base_dir: str, announce_domain, _ = get_domain_from_actor(attributed_to) get_person_from_cache(base_dir, attributed_to, person_cache) - announce_handle = '' + announce_handle: str = '' if announce_nickname and announce_domain: announce_handle = announce_nickname + '@' + announce_domain announce_display_name = \ @@ -1577,7 +1577,7 @@ def _get_post_title_announce_html(base_dir: str, announce_display_name, False, translate) # add mutual icon to the display name - mutual_prefix = '' + mutual_prefix: str = '' if announce_handle in mutuals_list: mutual_prefix = '⇆ ' @@ -1606,7 +1606,7 @@ def _get_post_title_announce_html(base_dir: str, _log_post_timing(enable_timing_log, post_start_time, '13.4') if not announce_avatar_url: - announce_avatar_url = '' + announce_avatar_url: str = '' idx = 'Show options for this person' if '/users/news/' not in announce_avatar_url: @@ -1700,7 +1700,7 @@ def _reply_with_unknown_path_html(translate: {}, post_bookmark = '#' + bookmark_from_id(post_id) post_link = '/users/' + nickname + '?convthread=' + \ post_id.replace('--', '/') + post_bookmark - mitm_str = '' + mitm_str: str = '' if post_domain in mitm_servers: mitm_str = ' ' + mitm_warning_html(translate) title_str = \ @@ -1728,11 +1728,11 @@ def _get_reply_html(translate: {}, """Returns html title for a reply """ # add mutual icon to the display name - mutual_prefix = '' + mutual_prefix: str = '' if reply_handle in mutuals_list: mutual_prefix = '⇆ ' - reply_nickname = '' + reply_nickname: str = '' if '@' in reply_nickname: reply_nickname = reply_handle.split('@')[0] bot_prefix = get_display_name_prefix(actor_type, reply_nickname, @@ -1781,8 +1781,8 @@ def _get_post_title_reply_html(base_dir: str, """Returns the reply title of a post containing names of participants x replies to y """ - title_str = '' - reply_avatar_image_in_post = '' + title_str: str = '' + reply_avatar_image_in_post: str = '' obj_json = post_json_object['object'] # not a reply @@ -1877,7 +1877,7 @@ def _get_post_title_reply_html(base_dir: str, return (title_str, reply_avatar_image_in_post, container_class_icons, container_class) - reply_handle = '' + reply_handle: str = '' if reply_nickname and reply_domain: reply_handle = reply_nickname + '@' + reply_domain get_person_from_cache(base_dir, reply_actor, person_cache) @@ -2239,7 +2239,7 @@ def _get_buy_footer(buy_links: {}, translate: {}) -> str: return '' icon_filename = 'buy.png' description = translate['Buy'] - buy_str = '' + buy_str: str = '' for _, buy_url in buy_links.items(): buy_str = \ ' ' + \ @@ -3291,7 +3291,7 @@ def individual_post_as_html(signing_priv_key_pem: str, translate, session, session, session, session) if map_str: - event_category = '' + event_category: str = '' if category_str: category_text = 'Category' if translate.get('Category'): @@ -3304,7 +3304,7 @@ def individual_post_as_html(signing_priv_key_pem: str, time_text = translate['Time'] time_span_str = \ '
' + time_text + ': ' + time_span_str - map_addr_str = '' + map_addr_str: str = '' if '
' in location_str: # append the address after the map addrstr = location_str.split('
')[1] @@ -3391,7 +3391,7 @@ def individual_post_as_html(signing_priv_key_pem: str, map_str += '

' + time_text + ': ' + time_span_str + '

\n' if is_muted: - content_str = '' + content_str: str = '' else: if not is_patch: message_class = 'message' @@ -3503,10 +3503,10 @@ def html_individual_post(recent_posts_cache: {}, max_recent_posts: int, """Show an individual post as html """ original_post_json = post_json_object - post_str = '' - by_str = '' - by_text = '' - by_text_extra = '' + post_str: str = '' + by_str: str = '' + by_text: str = '' + by_text_extra: str = '' if liked_by: by_str = liked_by by_text = 'Liked by' @@ -3532,7 +3532,7 @@ def html_individual_post(recent_posts_cache: {}, max_recent_posts: int, # get the list of mutuals for the current account mutuals_list = get_mutuals_of_person(base_dir, nickname, domain) - mutual_prefix = '' + mutual_prefix: str = '' if by_str_handle in mutuals_list: if not text_mode_browser(ua_str): mutual_prefix = '⇆ ' @@ -3769,7 +3769,7 @@ def html_post_replies(recent_posts_cache: {}, max_recent_posts: int, block_nostr: {}) -> str: """Show the replies to an individual post as html """ - replies_str = '' + replies_str: str = '' if replies_json.get('orderedItems'): minimize_all_images = False if nickname in min_images_for_accounts: @@ -3812,7 +3812,7 @@ def html_post_replies(recent_posts_cache: {}, max_recent_posts: int, css_filename = base_dir + '/epicyon.css' instance_title = get_config_param(base_dir, 'instanceTitle') - metadata = '' + metadata: str = '' preload_images: list[str] = [] header_str = \ html_header_with_external_style(css_filename, instance_title, metadata, @@ -3888,7 +3888,7 @@ def html_emoji_reaction_picker(recent_posts_cache: {}, max_recent_posts: int, if not os.path.isfile(reactions_filename): reactions_filename = base_dir + '/emoji/default_reactions.json' reactions_json = load_json(reactions_filename) - emoji_picks_str = '' + emoji_picks_str: str = '' base_url = '/users/' + nickname post_id = remove_id_ending(post_json_object['id']) actor_url = get_actor_from_post(post_json_object) @@ -3917,7 +3917,7 @@ def html_emoji_reaction_picker(recent_posts_cache: {}, max_recent_posts: int, get_banner_file(base_dir, nickname, domain, theme_name) instance_title = get_config_param(base_dir, 'instanceTitle') - metadata = '' + metadata: str = '' preload_images: list[str] = [] header_str = \ html_header_with_external_style(css_filename, instance_title, metadata, diff --git a/webapp_profile.py b/webapp_profile.py index f6b719554..77958700b 100644 --- a/webapp_profile.py +++ b/webapp_profile.py @@ -167,11 +167,11 @@ def _get_profile_short_description(profile_description: str) -> str: profile_description_short = profile_description if '\n' in profile_description: if len(profile_description.split('\n')) > 6: - profile_description_short = '' + profile_description_short: str = '' else: if '
' in profile_description: if len(profile_description.split('
')) > 6: - profile_description_short = '' + profile_description_short: str = '' # keep the profile description short if len(profile_description_short) > 2048: profile_description_short = profile_description_short[:2048] @@ -299,7 +299,7 @@ def html_profile_after_search(authorized: bool, from_domain = i2p_domain http = True if yggdrasil_domain: - profile_domain = '' + profile_domain: str = '' if '@' in profile_handle: profile_domain = profile_handle.split('@')[1] else: @@ -333,7 +333,7 @@ def html_profile_after_search(authorized: bool, return None search_domain_full = get_full_domain(search_domain, search_port) - profile_str = '' + profile_str: str = '' css_filename = base_dir + '/epicyon-profile.css' if os.path.isfile(base_dir + '/epicyon.css'): css_filename = base_dir + '/epicyon.css' @@ -348,7 +348,7 @@ def html_profile_after_search(authorized: bool, attached_shared_items = \ actor_attached_shares_as_html(profile_json, max_shares_on_profile) - avatar_url = '' + avatar_url: str = '' if profile_json.get('icon'): url_str = get_person_icon(profile_json) if url_str: @@ -389,7 +389,7 @@ def html_profile_after_search(authorized: bool, blog_url = get_blog_address(profile_json) lxmf_address = get_lxmf_address(profile_json) - moved_to = '' + moved_to: str = '' if profile_json.get('movedTo') or profile_json.get('copiedTo'): if profile_json.get('movedTo'): if not isinstance(profile_json['movedTo'], str): @@ -400,7 +400,6 @@ def html_profile_after_search(authorized: bool, if moved_to: if '"' in moved_to: moved_to = moved_to.split('"')[1] - moved_to = moved_to display_name += ' ⌂' you_follow = \ @@ -416,7 +415,7 @@ def html_profile_after_search(authorized: bool, profile_status = get_actor_status(profile_json) if profile_status: if actor_status_expired(profile_json['sm:status']): - profile_status = '' + profile_status: str = '' if profile_status: profile_status = \ remove_link_trackers_from_content(profile_status) @@ -424,7 +423,7 @@ def html_profile_after_search(authorized: bool, add_emoji_to_display_name(session, base_dir, http_prefix, nickname, domain, profile_status, False, translate) - profile_description = '' + profile_description: str = '' if profile_json.get('summary'): if not dangerous_markup(profile_json['summary'], False, []): @@ -447,7 +446,7 @@ def html_profile_after_search(authorized: bool, return None outbox_url = profile_json['outbox'] - # profileBackgroundImage = '' + # profileBackgroundImage: str = '' # if profile_json.get('image'): # if profile_json['image'].get('url'): # url_str = get_url_from_post(profile_json['image']['url']) @@ -461,7 +460,7 @@ def html_profile_after_search(authorized: bool, profile_description_short = \ _get_profile_short_description(profile_description) # remove formatting from profile description used on title - avatar_description = '' + avatar_description: str = '' if profile_json.get('summary'): if isinstance(profile_json['summary'], str): avatar_description = \ @@ -471,7 +470,7 @@ def html_profile_after_search(authorized: bool, if '<' in avatar_description: avatar_description = remove_html(avatar_description) - image_url = '' + image_url: str = '' if profile_json.get('image'): if profile_json['image'].get('url'): url_str = get_url_from_post(profile_json['image']['url']) @@ -496,7 +495,7 @@ def html_profile_after_search(authorized: bool, repo_url = get_repo_url(profile_json) # is sending posts to this account blocked? - send_blocks_str = '' + send_blocks_str: str = '' if sending_is_blocked2(base_dir, nickname, domain, search_domain_full, person_url): send_block_filename = \ @@ -508,7 +507,7 @@ def html_profile_after_search(authorized: bool, send_block_filename, False): send_blocks_str = translate['FollowWarning'] - birth_date = '' + birth_date: str = '' if profile_json.get('vcard:bday'): birth_date = profile_json['vcard:bday'] @@ -777,7 +776,7 @@ def _get_profile_header(base_dir: str, http_prefix: str, nickname: str, ' \n' - occupation_str = '' + occupation_str: str = '' if occupation_name: occupation_str += \ ' ' + occupation_name + '
\n' @@ -795,7 +794,7 @@ def _get_profile_header(base_dir: str, http_prefix: str, nickname: str, # show if the actor is proxied if not actor_proxied: - actor_proxied = '' + actor_proxied: str = '' else: actor_proxied = remove_html(actor_proxied) if resembles_url(actor_proxied): @@ -810,7 +809,7 @@ def _get_profile_header(base_dir: str, http_prefix: str, nickname: str, actor_proxied = ' [' + actor_proxied + ']' # show blog icon if this account has a blog - acct_blog_str = '' + acct_blog_str: str = '' has_blog = account_has_blog(base_dir, nickname, domain) if has_blog: acct_blog_str = \ @@ -984,7 +983,7 @@ def _get_profile_header_after_search(base_dir: str, display_name = search_nickname if not actor_proxied: - actor_proxied = '' + actor_proxied: str = '' else: actor_proxied = remove_html(actor_proxied) if resembles_url(actor_proxied): @@ -1241,7 +1240,7 @@ def html_profile(signing_priv_key_pem: str, profile_status = get_actor_status(profile_json) if profile_status: if actor_status_expired(profile_json['sm:status']): - profile_status = '' + profile_status: str = '' if profile_status: profile_status = \ remove_link_trackers_from_content(profile_status) @@ -1291,16 +1290,16 @@ def html_profile(signing_priv_key_pem: str, # shares_button = 'buttonselected' # elif selected == 'wanted': # wanted_button = 'buttonselected' - login_button = '' + login_button: str = '' - follow_approvals_section = '' + follow_approvals_section: str = '' follow_approvals = False - edit_profile_str = '' - logout_str = '' + edit_profile_str: str = '' + logout_str: str = '' actor = profile_json['id'] users_path = '/users/' + actor.split('/users/')[1] - donate_section = '' + donate_section: str = '' donate_url = get_donation_url(profile_json) website_url = get_website(profile_json, translate) repo_url = get_repo_url(profile_json) @@ -1538,7 +1537,7 @@ def html_profile(signing_priv_key_pem: str, # if so then append a new instance indicator follower_domain, _ = \ get_domain_from_actor(follower_actor) - new_follower_domain = '' + new_follower_domain: str = '' if follower_domain not in curr_follower_domains: new_follower_domain = ' ✨' @@ -1580,7 +1579,7 @@ def html_profile(signing_priv_key_pem: str, profile_description_short = \ _get_profile_short_description(profile_description) # remove formatting from profile description used on title - avatar_description = '' + avatar_description: str = '' if profile_json.get('summary'): avatar_description = profile_json['summary'].replace('
', '\n') replacements = { @@ -1589,7 +1588,7 @@ def html_profile(signing_priv_key_pem: str, } avatar_description = replace_strings(avatar_description, replacements) - moved_to = '' + moved_to: str = '' if profile_json.get('movedTo') or profile_json.get('copiedTo'): if profile_json.get('movedTo'): if isinstance(profile_json['movedTo'], str): @@ -1601,7 +1600,7 @@ def html_profile(signing_priv_key_pem: str, if '"' in moved_to: moved_to = moved_to.split('"')[1] else: - moved_to = '' + moved_to: str = '' also_known_as = None if profile_json.get('alsoKnownAs'): @@ -1641,7 +1640,7 @@ def html_profile(signing_priv_key_pem: str, attached_shared_items = \ actor_attached_shares_as_html(profile_json, max_shares_on_profile) - birth_date = '' + birth_date: str = '' if profile_json.get('vcard:bday'): birth_date = profile_json['vcard:bday'] @@ -1977,7 +1976,7 @@ def _html_profile_posts(recent_posts_cache: {}, max_recent_posts: int, These should only be public posts """ separator_str = html_post_separator(base_dir, None) - profile_str = '' + profile_str: str = '' max_items = max_profile_posts ctr = 0 curr_page = 1 @@ -2064,7 +2063,7 @@ def _html_profile_following(translate: {}, base_dir: str, http_prefix: str, mitm_servers: []) -> str: """Shows following on the profile screen """ - profile_str = '' + profile_str: str = '' if authorized and page_number: if authorized and page_number > 1: @@ -2140,7 +2139,7 @@ def _html_profile_roles(translate: {}, nickname: str, domain: str, roles_list: []) -> str: """Shows roles on the profile screen """ - profile_str = '' + profile_str: str = '' profile_str += \ '
\n
\n' for role in roles_list: @@ -2160,7 +2159,7 @@ def _html_profile_roles(translate: {}, nickname: str, domain: str, def _html_profile_skills(skills_json: {}) -> str: """Shows skills on the profile screen """ - profile_str = '' + profile_str: str = '' for skill, level in skills_json.items(): profile_str += \ '
' + skill + \ @@ -2177,7 +2176,7 @@ def _html_profile_shares(actor: str, translate: {}, shares_file_type: str) -> str: """Shows shares on the profile screen """ - profile_str = '' + profile_str: str = '' for item in shares_json['orderedItems']: profile_str += html_individual_share(domain, item['shareId'], actor, item, translate, @@ -2274,7 +2273,7 @@ def _html_edit_profile_twitter(base_dir: str, translate: {}, 'removeTwitter', remove_twitter) twitter_replacement_domain = get_config_param(base_dir, "twitterdomain") if not twitter_replacement_domain: - twitter_replacement_domain = '' + twitter_replacement_domain: str = '' twitter_str += \ edit_text_field(translate['Twitter Replacement Domain'], 'twitterdomain', twitter_replacement_domain) @@ -2416,7 +2415,7 @@ def _html_edit_profile_instance(base_dir: str, translate: {}, '
\n' - city = '' + city: str = '' city_filename = acct_dir(base_dir, nickname, domain) + '/city.txt' if os.path.isfile(city_filename): city1 = \ @@ -2769,7 +2768,7 @@ def _html_edit_profile_filtering(base_dir: str, nickname: str, domain: str, for city_name in cities: if ':' not in city_name: continue - city_selected = '' + city_selected: str = '' city_name = city_name.split(':')[0] city_name = city_name.lower() if city: @@ -2845,7 +2844,7 @@ def _html_edit_profile_filtering(base_dir: str, nickname: str, domain: str, '' + \ translate['Known Web Crawlers'] + '
\n' - user_agents_blocked_str = '' + user_agents_blocked_str: str = '' for uagent in user_agents_blocked: if user_agents_blocked_str: user_agents_blocked_str += '\n' @@ -2859,7 +2858,7 @@ def _html_edit_profile_filtering(base_dir: str, nickname: str, domain: str, '' + \ translate['Known Search Bots'] + '
\n' - crawlers_allowed_str = '' + crawlers_allowed_str: str = '' for uagent in crawlers_allowed: if crawlers_allowed_str: crawlers_allowed_str += '\n' @@ -2869,7 +2868,7 @@ def _html_edit_profile_filtering(base_dir: str, nickname: str, domain: str, 'crawlersAllowedStr', crawlers_allowed_str, 200, '', False) - buy_domains_list_str = '' + buy_domains_list_str: str = '' for buy_icon_text, buy_url in buy_sites.items(): if buy_icon_text != buy_url: buy_domains_list_str += \ @@ -2883,7 +2882,7 @@ def _html_edit_profile_filtering(base_dir: str, nickname: str, domain: str, 'buySitesStr', buy_domains_list_str, 200, '', False) - block_federated_endpoints_list_str = '' + block_federated_endpoints_list_str: str = '' for block_api_url in block_federated_endpoints: block_federated_endpoints_list_str += block_api_url.strip() + '\n' block_federated_str = "Blocking API endpoints" @@ -2894,7 +2893,7 @@ def _html_edit_profile_filtering(base_dir: str, nickname: str, domain: str, 200, '', False) robots_txt_filename = data_dir(base_dir) + '/robots.txt' - robots_txt = '' + robots_txt: str = '' if os.path.isfile(robots_txt_filename): new_robots_txt = \ load_string(robots_txt_filename, @@ -2942,7 +2941,7 @@ def _html_edit_profile_filtering(base_dir: str, nickname: str, domain: str, edit_profile_form += \ edit_check_box(idx, 'blockNostr', blocknostr) - cw_lists_str = '' + cw_lists_str: str = '' for name, list_json in cw_lists.items(): variablename = get_cw_list_variable(name) list_is_enabled = False @@ -3118,7 +3117,7 @@ def _html_edit_notifications(base_dir: str, nickname: str, domain: str, """Notifications settings """ ntfy_url = "ntfy.sh" - ntfy_topic = '' + ntfy_topic: str = '' ntfy_url_file = \ acct_dir(base_dir, nickname, domain) + '/.ntfy_url' @@ -3137,7 +3136,7 @@ def _html_edit_notifications(base_dir: str, nickname: str, domain: str, 'EX: _html_edit_notifications unable to read ' + ntfy_topic_file) if ntfy_topic is None: - ntfy_topic = '' + ntfy_topic: str = '' edit_profile_form = begin_edit_section(translate['Notifications']) edit_profile_form += edit_text_field(translate['ntfy URL'], @@ -3351,7 +3350,7 @@ def _get_supported_languagesSorted(base_dir: str) -> str: if not lang_list: return '' lang_list.sort() - languages_str = '' + languages_str: str = '' for lang in lang_list: if languages_str: languages_str += ' / ' + lang @@ -3386,7 +3385,7 @@ def _html_edit_profile_main(base_dir: str, display_nickname: str, edit_text_area(translate['Your bio'], None, 'bio', bio_str, 200, '', True) - birth_date = '' + birth_date: str = '' birth_date_field = 'vcard:bday' if actor_json.get(birth_date_field): if '-' in actor_json[birth_date_field]: @@ -3410,7 +3409,7 @@ def _html_edit_profile_main(base_dir: str, display_nickname: str, ' \n' - occupation_name = '' + occupation_name: str = '' if actor_json.get('hasOccupation'): occupation_name = get_occupation_name(actor_json) @@ -3418,7 +3417,7 @@ def _html_edit_profile_main(base_dir: str, display_nickname: str, edit_text_field(translate['Occupation'], 'occupationName', occupation_name) - also_known_as_str = '' + also_known_as_str: str = '' if actor_json.get('alsoKnownAs'): also_known_as = actor_json['alsoKnownAs'] ctr = 0 @@ -3629,14 +3628,14 @@ def html_edit_profile(server, translate: {}, actor_json['summary'].replace('

', '').replace('

', '') if is_filtered(base_dir, nickname, domain, bio_str, system_language): - bio_str = '' + bio_str: str = '' bio_str = remove_html(bio_str) if actor_json.get('manuallyApprovesFollowers'): if actor_json['manuallyApprovesFollowers']: manually_approves_followers = 'checked' else: - manually_approves_followers = '' - reject_spam_actors = '' + manually_approves_followers: str = '' + reject_spam_actors: str = '' actor_spam_filter_filename = \ acct_dir(base_dir, nickname, domain) + '/.reject_spam_actors' if os.path.isfile(actor_spam_filter_filename): @@ -3644,10 +3643,10 @@ def html_edit_profile(server, translate: {}, if actor_json.get('type'): if actor_json['type'] == 'Service': is_bot = 'checked' - is_group = '' + is_group: str = '' elif actor_json['type'] == 'Group': is_group = 'checked' - is_bot = '' + is_bot: str = '' account_dir = acct_dir(base_dir, nickname, domain) if os.path.isfile(account_dir + '/.followDMs'): follow_dms = 'checked' @@ -3684,14 +3683,14 @@ def html_edit_profile(server, translate: {}, if os.path.isfile(base_dir + '/epicyon.css'): css_filename = base_dir + '/epicyon.css' - instance_str = '' - role_assign_str = '' - peertube_str = '' - libretranslate_str = '' - memorial_str = '' - system_monitor_str = '' - graphics_str = '' - shares_federation_str = '' + instance_str: str = '' + role_assign_str: str = '' + peertube_str: str = '' + libretranslate_str: str = '' + memorial_str: str = '' + system_monitor_str: str = '' + graphics_str: str = '' + shares_federation_str: str = '' admin_nickname = get_config_param(base_dir, 'admin') @@ -3996,7 +3995,7 @@ def _individual_follow_as_html(signing_priv_key_pem: str, elif dormant: title_str += ' 💤' - buttons_str = '' + buttons_str: str = '' if authorized: for btn in buttons: if btn == 'block': diff --git a/webapp_pwa.py b/webapp_pwa.py index 5fcad6859..74b08a34a 100644 --- a/webapp_pwa.py +++ b/webapp_pwa.py @@ -42,7 +42,7 @@ def get_pwa_theme_colors(css_filename: str) -> (str, str): 'EX: get_pwa_theme_colors unable to read ' + css_filename) if css_str is None: - css_str = '' + css_str: str = '' pwa_theme_color = \ _get_variable_from_css(css_str, 'pwa-theme-color') diff --git a/webapp_question.py b/webapp_question.py index ca67c8815..f512023a7 100644 --- a/webapp_question.py +++ b/webapp_question.py @@ -27,7 +27,7 @@ def insert_question(base_dir: str, translate: {}, message_id = remove_id_ending(post_json_object['id']) if '#' in message_id: message_id = message_id.split('#', 1)[0] - page_number_str = '' + page_number_str: str = '' if page_number: page_number_str = '?page=' + str(page_number)