mirror of https://gitlab.com/bashrc2/epicyon
Variable types
parent
e0b866c631
commit
9d1b20e1e1
|
|
@ -629,7 +629,7 @@ def _get_short_domain(domain: str) -> str:
|
|||
e.g. subdomain123.mydomain.com becomes mydomain.com
|
||||
"""
|
||||
sections: list[str] = domain.split('.')
|
||||
no_of_sections = len(sections)
|
||||
no_of_sections: int = len(sections)
|
||||
if no_of_sections > 2:
|
||||
return sections[no_of_sections-2] + '.' + sections[-1]
|
||||
return None
|
||||
|
|
|
|||
4
blog.py
4
blog.py
|
|
@ -207,7 +207,7 @@ def html_blog_post_gemini_links(content: str) -> str:
|
|||
if '=> ' not in content:
|
||||
return content
|
||||
ctr: int = 0
|
||||
sections = content.split('=> ')
|
||||
sections: list[str] = content.split('=> ')
|
||||
new_content: str = ''
|
||||
for section in sections:
|
||||
if ctr == 0:
|
||||
|
|
@ -278,7 +278,7 @@ def html_blog_post_markdown(content: str) -> str:
|
|||
for markdown_text, html_header in replacements.items():
|
||||
if markdown_text not in new_content:
|
||||
continue
|
||||
sections = new_content.split(markdown_text)
|
||||
sections: list[str] = new_content.split(markdown_text)
|
||||
ctr: int = 0
|
||||
new_content2: str = ''
|
||||
for section in sections:
|
||||
|
|
|
|||
18
content.py
18
content.py
|
|
@ -113,7 +113,7 @@ def remove_html_tag(html_str: str, tag: str) -> str:
|
|||
if match_str not in html_str:
|
||||
tag_found = False
|
||||
break
|
||||
sections = html_str.split(match_str, 1)
|
||||
sections: list[str] = html_str.split(match_str, 1)
|
||||
if '"' not in sections[1]:
|
||||
tag_found = False
|
||||
break
|
||||
|
|
@ -205,7 +205,7 @@ def html_replace_inline_quotes(content: str) -> str:
|
|||
"""
|
||||
if '<p class="quote-inline">' not in content:
|
||||
return content
|
||||
sections = content.split('<p class="quote-inline">')
|
||||
sections: list[str] = content.split('<p class="quote-inline">')
|
||||
ctr: int = 0
|
||||
new_content = ''
|
||||
for section in sections:
|
||||
|
|
@ -237,9 +237,9 @@ def html_replace_quote_marks(content: str) -> str:
|
|||
if content.count('"') > 4:
|
||||
return content
|
||||
|
||||
new_content = content
|
||||
new_content: str = content
|
||||
if '"' in content:
|
||||
sections = content.split('"')
|
||||
sections: list[str] = content.split('"')
|
||||
if len(sections) > 1:
|
||||
new_content: str = ''
|
||||
open_quote: bool = True
|
||||
|
|
@ -264,7 +264,7 @@ def html_replace_quote_marks(content: str) -> str:
|
|||
new_content: str = ''
|
||||
ctr: int = 0
|
||||
sections: list = content.split('"')
|
||||
no_of_sections = len(sections)
|
||||
no_of_sections: int = len(sections)
|
||||
for sec in sections:
|
||||
new_content += sec
|
||||
if ctr < no_of_sections - 1:
|
||||
|
|
@ -2043,8 +2043,8 @@ def contains_invalid_local_links(domain_full: str,
|
|||
continue
|
||||
# extract the urls and check whether they are for the local domain
|
||||
ctr: int = 0
|
||||
sections = content.split(match_str)
|
||||
final_section_index = len(sections) - 1
|
||||
sections: list[str] = content.split(match_str)
|
||||
final_section_index: int = len(sections) - 1
|
||||
for section_str in sections:
|
||||
if ctr == final_section_index:
|
||||
continue
|
||||
|
|
@ -2260,7 +2260,7 @@ def remove_script(content: str, log_filename: str,
|
|||
ending: str = '/script' + sep[1]
|
||||
if prefix not in content:
|
||||
continue
|
||||
sections = content.split(prefix)
|
||||
sections: list[str] = content.split(prefix)
|
||||
ctr: int = 0
|
||||
for text in sections:
|
||||
if ctr == 0:
|
||||
|
|
@ -2477,7 +2477,7 @@ def add_auto_cw(base_dir: str, nickname: str, domain: str,
|
|||
for cw_rule in auto_cw_list:
|
||||
if '->' not in cw_rule:
|
||||
continue
|
||||
sections = cw_rule.split('->')
|
||||
sections: list[str] = cw_rule.split('->')
|
||||
rulematch = sections[0].strip()
|
||||
if rulematch not in content:
|
||||
continue
|
||||
|
|
|
|||
|
|
@ -273,8 +273,8 @@ def show_individual_post(self, ssml_getreq: bool, authorized: bool,
|
|||
liked_by = liked_by.split('?')[0]
|
||||
path = path.split('?likedBy=')[0]
|
||||
|
||||
react_by = None
|
||||
react_emoji = None
|
||||
react_by: str = None
|
||||
react_emoji: str = None
|
||||
if '?reactBy=' in path:
|
||||
react_by = path.split('?reactBy=')[1].strip()
|
||||
if ';' in react_by:
|
||||
|
|
@ -285,14 +285,14 @@ def show_individual_post(self, ssml_getreq: bool, authorized: bool,
|
|||
react_emoji = react_emoji.split(';')[0]
|
||||
path = path.split('?reactBy=')[0]
|
||||
|
||||
named_status = path.split('/users/')[1]
|
||||
named_status: str = path.split('/users/')[1]
|
||||
if '/' not in named_status:
|
||||
return False
|
||||
post_sections = named_status.split('/')
|
||||
post_sections: list[str] = named_status.split('/')
|
||||
if len(post_sections) < 3:
|
||||
return False
|
||||
nickname = post_sections[0]
|
||||
status_number = post_sections[2]
|
||||
nickname: str = post_sections[0]
|
||||
status_number: str = post_sections[2]
|
||||
if len(status_number) <= 10 or (not status_number.isdigit()):
|
||||
return False
|
||||
|
||||
|
|
@ -638,11 +638,11 @@ def show_individual_at_post(self, ssml_getreq: bool, authorized: bool,
|
|||
nickname = named_status
|
||||
return False
|
||||
|
||||
post_sections = named_status.split('/')
|
||||
post_sections: list[str] = named_status.split('/')
|
||||
if len(post_sections) != 2:
|
||||
return False
|
||||
nickname = post_sections[0]
|
||||
status_number = post_sections[1]
|
||||
nickname: str = post_sections[0]
|
||||
status_number: str = post_sections[1]
|
||||
if len(status_number) <= 10 or not status_number.isdigit():
|
||||
return False
|
||||
|
||||
|
|
@ -974,28 +974,28 @@ def show_replies_to_post(self, authorized: bool,
|
|||
if not ('/statuses/' in path and '/users/' in path):
|
||||
return False
|
||||
|
||||
named_status = path.split('/users/')[1]
|
||||
named_status: str = path.split('/users/')[1]
|
||||
if '/' not in named_status:
|
||||
return False
|
||||
|
||||
post_sections = named_status.split('/')
|
||||
post_sections: list[str] = named_status.split('/')
|
||||
if len(post_sections) < 4:
|
||||
return False
|
||||
|
||||
if not post_sections[3].startswith('replies'):
|
||||
return False
|
||||
nickname = post_sections[0]
|
||||
status_number = post_sections[2]
|
||||
nickname: str = post_sections[0]
|
||||
status_number: str = post_sections[2]
|
||||
if not (len(status_number) > 10 and status_number.isdigit()):
|
||||
return False
|
||||
|
||||
boxname = 'outbox'
|
||||
boxname: str = 'outbox'
|
||||
# get the replies file
|
||||
post_dir = \
|
||||
post_dir: str = \
|
||||
acct_dir(base_dir, nickname, domain) + '/' + boxname
|
||||
orig_post_url = http_prefix + ':##' + domain_full + '#users#' + \
|
||||
orig_post_url: str = http_prefix + ':##' + domain_full + '#users#' + \
|
||||
nickname + '#statuses#' + status_number
|
||||
post_replies_filename = \
|
||||
post_replies_filename: str = \
|
||||
post_dir + '/' + orig_post_url + '.replies'
|
||||
if not is_a_file(post_replies_filename):
|
||||
# There are no replies,
|
||||
|
|
|
|||
|
|
@ -257,17 +257,17 @@ def show_roles(self, calling_domain: str, referer_domain: str,
|
|||
hide_recent_posts: {}) -> bool:
|
||||
"""Show roles within profile screen
|
||||
"""
|
||||
named_status = path.split('/users/')[1]
|
||||
named_status: str = path.split('/users/')[1]
|
||||
if '/' not in named_status:
|
||||
return False
|
||||
|
||||
post_sections = named_status.split('/')
|
||||
nickname = post_sections[0]
|
||||
actor_filename = acct_dir(base_dir, nickname, domain) + '.json'
|
||||
post_sections: list[str] = named_status.split('/')
|
||||
nickname: str = post_sections[0]
|
||||
actor_filename: str = acct_dir(base_dir, nickname, domain) + '.json'
|
||||
if not is_a_file(actor_filename):
|
||||
return False
|
||||
|
||||
actor_json = load_json(actor_filename)
|
||||
actor_json: dict = load_json(actor_filename)
|
||||
if not actor_json:
|
||||
return False
|
||||
|
||||
|
|
@ -418,11 +418,11 @@ def show_skills(self, calling_domain: str, referer_domain: str,
|
|||
hide_recent_posts: {}) -> bool:
|
||||
"""Show skills on the profile screen
|
||||
"""
|
||||
named_status = path.split('/users/')[1]
|
||||
named_status: str = path.split('/users/')[1]
|
||||
if '/' in named_status:
|
||||
post_sections = named_status.split('/')
|
||||
nickname = post_sections[0]
|
||||
actor_filename = acct_dir(base_dir, nickname, domain) + '.json'
|
||||
post_sections: list[str] = named_status.split('/')
|
||||
nickname: str = post_sections[0]
|
||||
actor_filename: str = acct_dir(base_dir, nickname, domain) + '.json'
|
||||
if is_a_file(actor_filename):
|
||||
actor_json = load_json(actor_filename)
|
||||
if actor_json:
|
||||
|
|
|
|||
2
flags.py
2
flags.py
|
|
@ -580,7 +580,7 @@ def is_valid_date(date_str: str) -> bool:
|
|||
return False
|
||||
if '-' not in date_str:
|
||||
return False
|
||||
date_sections = date_str.split('-')
|
||||
date_sections: list[str] = date_str.split('-')
|
||||
if len(date_sections) != 3:
|
||||
return False
|
||||
date_sect_ctr: int = 0
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ def blog_to_gemini(base_dir: str, nickname: str, domain: str,
|
|||
# get web links
|
||||
links: list[str] = []
|
||||
if '://' in content_text:
|
||||
sections = content_text.split('://')
|
||||
sections: list[str] = content_text.split('://')
|
||||
ctr: int = 0
|
||||
prev_section: str = ''
|
||||
for section in sections:
|
||||
|
|
|
|||
|
|
@ -877,7 +877,7 @@ def _dav_decode_token(token: str) -> (int, int, str):
|
|||
"""
|
||||
if '_' not in token or '--' not in token:
|
||||
return None, None, None
|
||||
token_sections = token.split('_')
|
||||
token_sections: list[str] = token.split('_')
|
||||
if len(token_sections) != 3:
|
||||
return None, None, None
|
||||
if not token_sections[0].isdigit():
|
||||
|
|
|
|||
25
maps.py
25
maps.py
|
|
@ -164,7 +164,7 @@ def _get_event_time_span_from_tags(tags: []) -> (str, str, str, str):
|
|||
start_time_str = start_time_str.split('+')[0]
|
||||
if '-' in start_time_str:
|
||||
start_time_str = start_time_str.split('-')[0]
|
||||
start_time_sections = start_time_str.split(':')
|
||||
start_time_sections: list[str] = start_time_str.split(':')
|
||||
if len(start_time_sections) < 2:
|
||||
return None, None, None, None
|
||||
start_time_str = \
|
||||
|
|
@ -181,7 +181,8 @@ def _get_event_time_span_from_tags(tags: []) -> (str, str, str, str):
|
|||
if '-' in end_time_str:
|
||||
end_time_str = end_time_str.split('-')[0]
|
||||
if ':' in end_time_str:
|
||||
end_time_sections = end_time_str.split(':')
|
||||
end_time_sections: list[str] = \
|
||||
end_time_str.split(':')
|
||||
if len(end_time_sections) >= 2:
|
||||
end_time_str = \
|
||||
end_time_sections[0] + ':' + \
|
||||
|
|
@ -420,7 +421,7 @@ def get_event_time_span_from_post(post_json_object: {}) -> str:
|
|||
start_time_str = start_time_str.split('+')[0]
|
||||
if '-' in start_time_str:
|
||||
start_time_str = start_time_str.split('-')[0]
|
||||
start_time_sections = start_time_str.split(':')
|
||||
start_time_sections: list[str] = start_time_str.split(':')
|
||||
if len(start_time_sections) < 2:
|
||||
return None, None, None, None
|
||||
start_time_str = \
|
||||
|
|
@ -437,7 +438,7 @@ def get_event_time_span_from_post(post_json_object: {}) -> str:
|
|||
if '-' in end_time_str:
|
||||
end_time_str = end_time_str.split('-')[0]
|
||||
if ':' in end_time_str:
|
||||
end_time_sections = end_time_str.split(':')
|
||||
end_time_sections: list[str] = end_time_str.split(':')
|
||||
if len(end_time_sections) >= 2:
|
||||
end_time_str = \
|
||||
end_time_sections[0] + ':' + \
|
||||
|
|
@ -583,7 +584,7 @@ def _geocoords_from_osmand_link(url: str) -> (int, float, float):
|
|||
if '#' in url:
|
||||
coords_str = url.split('#')[1]
|
||||
if '/' in coords_str:
|
||||
sections = coords_str.split('/')
|
||||
sections: list[str] = coords_str.split('/')
|
||||
if len(sections) == 3:
|
||||
zoom_str = sections[0]
|
||||
latitude_str = sections[1]
|
||||
|
|
@ -602,13 +603,13 @@ def _geocoords_from_geo_link(url: str) -> (int, float, float):
|
|||
"""Returns geocoordinates from an geo link
|
||||
https://en.wikipedia.org/wiki/Geo_URI_scheme
|
||||
"""
|
||||
latitude = None
|
||||
longitude = None
|
||||
latitude: float = None
|
||||
longitude: float = None
|
||||
zoom: int = 10
|
||||
|
||||
coords_str = url.split('geo:')[1]
|
||||
coords_str: str = url.split('geo:')[1]
|
||||
if ',' in coords_str:
|
||||
coords_sections = coords_str.split(',')
|
||||
coords_sections: list[str] = coords_str.split(',')
|
||||
if len(coords_sections) >= 2:
|
||||
latitude_str = coords_sections[0]
|
||||
longitude_str = coords_sections[1]
|
||||
|
|
@ -965,7 +966,7 @@ def get_map_links_from_post_content(content: str, session) -> []:
|
|||
"""Returns a list of map links
|
||||
"""
|
||||
osm_domain = 'openstreetmap.org'
|
||||
sections = content.split('://')
|
||||
sections: list[str] = content.split('://')
|
||||
map_links: list[str] = []
|
||||
ctr: int = 0
|
||||
for link_str in sections:
|
||||
|
|
@ -1000,7 +1001,7 @@ def get_map_links_from_post_content(content: str, session) -> []:
|
|||
|
||||
# https://en.wikipedia.org/wiki/Geo_URI_scheme
|
||||
ctr: int = 0
|
||||
sections = content.split('geo:')
|
||||
sections: list[str] = content.split('geo:')
|
||||
for link_str in sections:
|
||||
if ctr == 0:
|
||||
ctr += 1
|
||||
|
|
@ -1014,7 +1015,7 @@ def get_map_links_from_post_content(content: str, session) -> []:
|
|||
coords_str += char
|
||||
if ',' not in coords_str:
|
||||
continue
|
||||
coord_sections = coords_str.split(',')
|
||||
coord_sections: list[str] = coords_str.split(',')
|
||||
if len(coord_sections) < 2:
|
||||
continue
|
||||
if not is_float(coord_sections[0]) or \
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ def _markdown_emphasis_html(markdown: str) -> str:
|
|||
'` ': '</em> '
|
||||
}
|
||||
|
||||
sections = _markdown_get_sections(markdown)
|
||||
sections: list[str] = _markdown_get_sections(markdown)
|
||||
markdown = ''
|
||||
for section_text in sections:
|
||||
if '<code>' in section_text:
|
||||
|
|
@ -185,7 +185,7 @@ def _markdown_replace_links(markdown: str) -> str:
|
|||
"""Replaces markdown links with html
|
||||
Optionally replace image links
|
||||
"""
|
||||
sections = _markdown_get_sections(markdown)
|
||||
sections: list[str] = _markdown_get_sections(markdown)
|
||||
result: str = ''
|
||||
for section_text in sections:
|
||||
if '<code>' in section_text or \
|
||||
|
|
@ -254,7 +254,7 @@ def _markdown_replace_misskey(markdown: str) -> str:
|
|||
}
|
||||
if '$[' not in markdown or ']' not in markdown:
|
||||
return markdown
|
||||
sections = _markdown_get_sections(markdown)
|
||||
sections: list[str] = _markdown_get_sections(markdown)
|
||||
result: str = ''
|
||||
for section_text in sections:
|
||||
if '<code>' in section_text or \
|
||||
|
|
|
|||
|
|
@ -277,9 +277,9 @@ def hashtag_rule_tree(operators: [],
|
|||
continue
|
||||
tree = [oper]
|
||||
if opmatch in conditions_str:
|
||||
sections = conditions_str.split(opmatch)
|
||||
sections: list[str] = conditions_str.split(opmatch)
|
||||
else:
|
||||
sections = conditions_str.split(oper + ' ', 1)
|
||||
sections: list[str] = conditions_str.split(oper + ' ', 1)
|
||||
for sub_condition_str in sections:
|
||||
result = hashtag_rule_tree(operators[ctr + 1:],
|
||||
sub_condition_str,
|
||||
|
|
|
|||
2
posts.py
2
posts.py
|
|
@ -2426,7 +2426,7 @@ def _append_citations_to_blog_post(base_dir: str,
|
|||
for line in citations:
|
||||
if citations_separator not in line:
|
||||
continue
|
||||
sections = line.strip().split(citations_separator)
|
||||
sections: list[str] = line.strip().split(citations_separator)
|
||||
if len(sections) != 3:
|
||||
continue
|
||||
# date_str = sections[0]
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ def get_book_link_from_content(content: str) -> str:
|
|||
if '://' not in content or \
|
||||
'"' not in content:
|
||||
return None
|
||||
sections = content.split('://')
|
||||
sections: list[str] = content.split('://')
|
||||
if '"' not in sections[0] or '"' not in sections[1]:
|
||||
return None
|
||||
previous_str = sections[0].split('"')[-1]
|
||||
|
|
|
|||
|
|
@ -510,7 +510,7 @@ def verify_html(session, url: str, debug: bool,
|
|||
return False
|
||||
|
||||
# ensure that there are not too many rel="me" links
|
||||
sections = verification_site_html.split(' rel="me" ')
|
||||
sections: list[str] = verification_site_html.split(' rel="me" ')
|
||||
me_links_count = len(sections) - 1
|
||||
if me_links_count > 5:
|
||||
return False
|
||||
|
|
|
|||
4
tests.py
4
tests.py
|
|
@ -4885,7 +4885,7 @@ def _test_translation_labels() -> None:
|
|||
continue
|
||||
if 'translate[' not in source_str:
|
||||
continue
|
||||
sections = source_str.split('translate[')
|
||||
sections: list[str] = source_str.split('translate[')
|
||||
ctr: int = 0
|
||||
for text in sections:
|
||||
if ctr == 0:
|
||||
|
|
@ -5799,7 +5799,7 @@ def _test_thread_functions():
|
|||
modules[mod_name]['lines'] = lines
|
||||
|
||||
for mod_name in threads_called_in_modules:
|
||||
thread_sections = \
|
||||
thread_sections: list[str] = \
|
||||
modules[mod_name]['source'].split('thread_with_trace(')
|
||||
ctr: int = 0
|
||||
for thread_str in thread_sections:
|
||||
|
|
|
|||
|
|
@ -393,7 +393,7 @@ def html_citations(base_dir: str, nickname: str, domain: str,
|
|||
for line in citations:
|
||||
if citations_separator not in line:
|
||||
continue
|
||||
sections = line.strip().split(citations_separator)
|
||||
sections: list[str] = line.strip().split(citations_separator)
|
||||
if len(sections) != 3:
|
||||
continue
|
||||
date_str = sections[0]
|
||||
|
|
|
|||
|
|
@ -945,7 +945,8 @@ def html_new_post(edit_post_params: {},
|
|||
for line in citations:
|
||||
if citations_separator not in line:
|
||||
continue
|
||||
sections = line.strip().split(citations_separator)
|
||||
sections: list[str] = \
|
||||
line.strip().split(citations_separator)
|
||||
if len(sections) != 3:
|
||||
continue
|
||||
title = sections[1]
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ def html_hash_tag_swarm(base_dir: str, actor: str, translate: {}) -> str:
|
|||
break
|
||||
if ' ' not in line:
|
||||
break
|
||||
sections = line.split(' ')
|
||||
sections: list[str] = line.split(' ')
|
||||
if len(sections) != 3:
|
||||
break
|
||||
post_days_since_epoch_str = sections[0]
|
||||
|
|
|
|||
|
|
@ -463,7 +463,7 @@ def _prepare_media_post_from_html_cache(post_html: str,
|
|||
text mode browsers, so that Lynx doesn't just say something like
|
||||
'this tag is not supported in your browser'
|
||||
"""
|
||||
sections = post_html.split('<' + media_type)
|
||||
sections: list[str] = post_html.split('<' + media_type)
|
||||
new_post_html: str = ''
|
||||
for section_str in sections:
|
||||
ending_tag = '</' + media_type + '>'
|
||||
|
|
@ -2286,27 +2286,27 @@ def _mentions_to_person_options(html_str: str, nickname: str, domain: str,
|
|||
if '"u-url mention"' not in html_str:
|
||||
return html_str
|
||||
|
||||
sections = html_str.split('<')
|
||||
sections: list[str] = html_str.split('<')
|
||||
for markup_str in sections:
|
||||
if '>' not in markup_str:
|
||||
continue
|
||||
markup_str = markup_str.split('>')[0]
|
||||
markup_str: str = markup_str.split('>')[0]
|
||||
if 'href="' not in markup_str or \
|
||||
'"u-url mention"' not in markup_str:
|
||||
continue
|
||||
link = markup_str.split('href="')[1]
|
||||
link: str = markup_str.split('href="')[1]
|
||||
if '"' not in link:
|
||||
continue
|
||||
post_actor = link.split('"')[0]
|
||||
post_actor: str = link.split('"')[0]
|
||||
# look up the avatar image for the mention
|
||||
avatar_url = \
|
||||
avatar_url: str = \
|
||||
get_avatar_image_url(session, base_dir, http_prefix, domain,
|
||||
post_actor, person_cache,
|
||||
None, allow_downloads,
|
||||
signing_priv_key_pem,
|
||||
mitm_servers)
|
||||
|
||||
replace_link = \
|
||||
replace_link: str = \
|
||||
"/users/" + nickname + "?options=" + post_actor + \
|
||||
";2;" + avatar_url
|
||||
html_str = html_str.replace('href="' + post_actor + '"',
|
||||
|
|
|
|||
Loading…
Reference in New Issue