mirror of https://gitlab.com/bashrc2/epicyon
Variable types
parent
39d9122081
commit
ff9c304702
6
city.py
6
city.py
|
|
@ -116,11 +116,11 @@ def _get_city_pulse(curr_time_of_day, decoy_seed: int) -> (float, float):
|
|||
Angle is in radians
|
||||
"""
|
||||
randgen = random.Random(decoy_seed)
|
||||
variance = 3
|
||||
variance: int = 3
|
||||
data_decoy_state = PERSON_SLEEP
|
||||
weekday = curr_time_of_day.weekday()
|
||||
min_hour = 7 + randint(0, variance)
|
||||
max_hour = 17 + randint(0, variance)
|
||||
min_hour: int = 7 + randint(0, variance)
|
||||
max_hour: int = 17 + randint(0, variance)
|
||||
if curr_time_of_day.hour > min_hour:
|
||||
if curr_time_of_day.hour <= max_hour:
|
||||
if weekday < 5:
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ def _remove_quotes_within_quotes(content: str) -> str:
|
|||
return content
|
||||
if '</blockquote>' not in content:
|
||||
return content
|
||||
ctr = 1
|
||||
ctr: int = 1
|
||||
found: bool = True
|
||||
while found:
|
||||
prefix = content.split('<blockquote>', ctr)[0] + '<blockquote>'
|
||||
|
|
@ -439,7 +439,7 @@ def _update_common_emoji(base_dir: str, emoji_content: str) -> None:
|
|||
if ' ' + emoji_content in line:
|
||||
if not emoji_found:
|
||||
emoji_found = True
|
||||
counter = 1
|
||||
counter: int = 1
|
||||
count_str = line.split(' ')[0]
|
||||
if count_str.isdigit():
|
||||
counter = int(count_str) + 1
|
||||
|
|
|
|||
|
|
@ -961,7 +961,7 @@ def daemon_http_get(self) -> None:
|
|||
nickname = self.path.split('/users/')[1]
|
||||
if '/' in nickname:
|
||||
nickname = nickname.split('/')[0]
|
||||
page_number = 1
|
||||
page_number: int = 1
|
||||
if '?page=' in self.path:
|
||||
page_number_str = self.path.split('?page=')[1]
|
||||
if ';' in page_number_str:
|
||||
|
|
@ -1002,7 +1002,7 @@ def daemon_http_get(self) -> None:
|
|||
if self.server.debug:
|
||||
print('Offers collection for account: ' + nickname)
|
||||
base_dir = self.server.base_dir
|
||||
offers_items_per_page = 12
|
||||
offers_items_per_page: int = 12
|
||||
max_shares_per_account = offers_items_per_page
|
||||
shared_items_federated_domains = \
|
||||
self.server.shared_items_federated_domains
|
||||
|
|
@ -1041,7 +1041,7 @@ def daemon_http_get(self) -> None:
|
|||
nickname = self.path.split('/users/')[1]
|
||||
if '/' in nickname:
|
||||
nickname = nickname.split('/')[0]
|
||||
page_number = 1
|
||||
page_number: int = 1
|
||||
if '?page=' in self.path:
|
||||
page_number_str = self.path.split('?page=')[1]
|
||||
if ';' in page_number_str:
|
||||
|
|
@ -1072,7 +1072,7 @@ def daemon_http_get(self) -> None:
|
|||
if self.server.debug:
|
||||
print('Blocked collection for account: ' + nickname)
|
||||
base_dir = self.server.base_dir
|
||||
blocked_items_per_page = 12
|
||||
blocked_items_per_page: int = 12
|
||||
blocked_json = \
|
||||
blocked_timeline_json(actor, page_number,
|
||||
blocked_items_per_page, base_dir,
|
||||
|
|
@ -1104,7 +1104,7 @@ def daemon_http_get(self) -> None:
|
|||
nickname = self.path.split('/users/')[1]
|
||||
if '/' in nickname:
|
||||
nickname = nickname.split('/')[0]
|
||||
page_number = 1
|
||||
page_number: int = 1
|
||||
if '?page=' in self.path:
|
||||
page_number_str = self.path.split('?page=')[1]
|
||||
if ';' in page_number_str:
|
||||
|
|
@ -1166,7 +1166,7 @@ def daemon_http_get(self) -> None:
|
|||
nickname = self.path.split('/users/')[1]
|
||||
if '/' in nickname:
|
||||
nickname = nickname.split('/')[0]
|
||||
page_number = 1
|
||||
page_number: int = 1
|
||||
if '?page=' in self.path:
|
||||
page_number_str = self.path.split('?page=')[1]
|
||||
if ';' in page_number_str:
|
||||
|
|
@ -1210,7 +1210,7 @@ def daemon_http_get(self) -> None:
|
|||
if self.server.debug:
|
||||
print('Wanted collection for account: ' + nickname)
|
||||
base_dir = self.server.base_dir
|
||||
wanted_items_per_page = 12
|
||||
wanted_items_per_page: int = 12
|
||||
max_shares_per_account = wanted_items_per_page
|
||||
shared_items_federated_domains = \
|
||||
self.server.shared_items_federated_domains
|
||||
|
|
@ -3131,7 +3131,7 @@ def daemon_http_get(self) -> None:
|
|||
hashtag_url = hashtag_url.split(';')[0]
|
||||
hashtag_url = hashtag_url.replace('--', '/')
|
||||
|
||||
page_number = 1
|
||||
page_number: int = 1
|
||||
if ';page=' in self.path:
|
||||
page_number_str = self.path.split(';page=')[1]
|
||||
if ';' in page_number_str:
|
||||
|
|
@ -4285,7 +4285,7 @@ def daemon_http_get(self) -> None:
|
|||
# reply from the web interface icon
|
||||
in_reply_to_url = None
|
||||
reply_to_list: list[str] = []
|
||||
reply_page_number = 1
|
||||
reply_page_number: int = 1
|
||||
reply_category: str = ''
|
||||
share_description = None
|
||||
conversation_id = None
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ def show_blog_page(self, authorized: bool,
|
|||
fitness: {}) -> bool:
|
||||
"""Shows a blog page
|
||||
"""
|
||||
page_number = 1
|
||||
page_number: int = 1
|
||||
nickname = path.split('/blog/')[1]
|
||||
if '/' in nickname:
|
||||
nickname = nickname.split('/')[0]
|
||||
|
|
|
|||
|
|
@ -253,7 +253,7 @@ def delete_button(self, calling_domain: str, path: str,
|
|||
print('ERROR: no cookie given when deleting ' + path)
|
||||
http_400(self)
|
||||
return
|
||||
page_number = 1
|
||||
page_number: int = 1
|
||||
if '?page=' in path:
|
||||
page_number_str = path.split('?page=')[1]
|
||||
if '?' in page_number_str:
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ def announce_button(self, calling_domain: str, path: str,
|
|||
instance_software: {}) -> None:
|
||||
"""The announce/repeat button was pressed on a post
|
||||
"""
|
||||
page_number = 1
|
||||
page_number: int = 1
|
||||
repeat_url = path.split('?repeat=')[1]
|
||||
if '?' in repeat_url:
|
||||
repeat_url = repeat_url.split('?')[0]
|
||||
|
|
@ -316,7 +316,7 @@ def announce_button_undo(self, calling_domain: str, path: str,
|
|||
session_yggdrasil) -> None:
|
||||
"""Undo announce/repeat button was pressed
|
||||
"""
|
||||
page_number = 1
|
||||
page_number: int = 1
|
||||
|
||||
# the post which was referenced by the announce post
|
||||
repeat_url = path.split('?unrepeat=')[1]
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ def bookmark_button(self, calling_domain: str, path: str,
|
|||
instance_software: {}) -> None:
|
||||
"""Bookmark button was pressed
|
||||
"""
|
||||
page_number = 1
|
||||
page_number: int = 1
|
||||
bookmark_url = path.split('?bookmark=')[1]
|
||||
if '?' in bookmark_url:
|
||||
bookmark_url = bookmark_url.split('?')[0]
|
||||
|
|
@ -301,7 +301,7 @@ def bookmark_button_undo(self, calling_domain: str, path: str,
|
|||
instance_software: {}) -> None:
|
||||
"""Button pressed to undo a bookmark
|
||||
"""
|
||||
page_number = 1
|
||||
page_number: int = 1
|
||||
bookmark_url = path.split('?unbookmark=')[1]
|
||||
if '?' in bookmark_url:
|
||||
bookmark_url = bookmark_url.split('?')[0]
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ def like_button(self, calling_domain: str, path: str,
|
|||
instance_software: {}) -> None:
|
||||
"""Press the like button
|
||||
"""
|
||||
page_number = 1
|
||||
page_number: int = 1
|
||||
like_url = path.split('?like=')[1]
|
||||
if '?' in like_url:
|
||||
like_url = like_url.split('?')[0]
|
||||
|
|
@ -355,7 +355,7 @@ def like_button_undo(self, calling_domain: str, path: str,
|
|||
instance_software: {}) -> None:
|
||||
"""A button is pressed to undo
|
||||
"""
|
||||
page_number = 1
|
||||
page_number: int = 1
|
||||
like_url = path.split('?unlike=')[1]
|
||||
if '?' in like_url:
|
||||
like_url = like_url.split('?')[0]
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ def mute_button(self, calling_domain: str, path: str,
|
|||
timeline_str = path.split('?tl=')[1]
|
||||
if '?' in timeline_str:
|
||||
timeline_str = timeline_str.split('?')[0]
|
||||
page_number = 1
|
||||
page_number: int = 1
|
||||
if '?page=' in path:
|
||||
page_number_str = path.split('?page=')[1]
|
||||
if ';' in page_number_str:
|
||||
|
|
@ -275,7 +275,7 @@ def mute_button_undo(self, calling_domain: str, path: str,
|
|||
timeline_str = path.split('?tl=')[1]
|
||||
if '?' in timeline_str:
|
||||
timeline_str = timeline_str.split('?')[0]
|
||||
page_number = 1
|
||||
page_number: int = 1
|
||||
if '?page=' in path:
|
||||
page_number_str = path.split('?page=')[1]
|
||||
if ';' in page_number_str:
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ def reaction_button(self, calling_domain: str, path: str,
|
|||
Note that this is not the emoji reaction selection icon at the
|
||||
bottom of the post
|
||||
"""
|
||||
page_number = 1
|
||||
page_number: int = 1
|
||||
reaction_url = path.split('?react=')[1]
|
||||
if '?' in reaction_url:
|
||||
reaction_url = reaction_url.split('?')[0]
|
||||
|
|
@ -382,7 +382,7 @@ def reaction_button_undo(self, calling_domain: str, path: str,
|
|||
instance_software: {}) -> None:
|
||||
"""A button is pressed to undo emoji reaction
|
||||
"""
|
||||
page_number = 1
|
||||
page_number: int = 1
|
||||
reaction_url = path.split('?unreact=')[1]
|
||||
if '?' in reaction_url:
|
||||
reaction_url = reaction_url.split('?')[0]
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ def show_shares_feed(self, authorized: bool,
|
|||
shares_per_page)
|
||||
if shares:
|
||||
if request_http(self.headers, debug):
|
||||
page_number = 1
|
||||
page_number: int = 1
|
||||
if '?page=' not in path:
|
||||
search_path = path
|
||||
# get a page of shares, not the summary
|
||||
|
|
@ -273,7 +273,7 @@ def show_following_feed(self, authorized: bool,
|
|||
'following')
|
||||
if following:
|
||||
if request_http(self.headers, debug):
|
||||
page_number = 1
|
||||
page_number: int = 1
|
||||
if '?page=' not in path:
|
||||
search_path = path
|
||||
# get a page of following, not the summary
|
||||
|
|
@ -478,7 +478,7 @@ def show_moved_feed(self, authorized: bool,
|
|||
http_prefix, authorized, follows_per_page)
|
||||
if following:
|
||||
if request_http(self.headers, debug):
|
||||
page_number = 1
|
||||
page_number: int = 1
|
||||
if '?page=' not in path:
|
||||
search_path = path
|
||||
# get a page of following, not the summary
|
||||
|
|
@ -673,7 +673,7 @@ def show_inactive_feed(self, authorized: bool,
|
|||
follows_per_page, sites_unavailable)
|
||||
if following:
|
||||
if request_http(self.headers, debug):
|
||||
page_number = 1
|
||||
page_number: int = 1
|
||||
if '?page=' not in path:
|
||||
search_path = path
|
||||
# get a page of following, not the summary
|
||||
|
|
@ -867,7 +867,7 @@ def show_followers_feed(self, authorized: bool,
|
|||
authorized, follows_per_page, 'followers')
|
||||
if followers:
|
||||
if request_http(self.headers, debug):
|
||||
page_number = 1
|
||||
page_number: int = 1
|
||||
if '?page=' not in path:
|
||||
search_path = path
|
||||
# get a page of followers, not the summary
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ def hashtag_search_json2(self, calling_domain: str,
|
|||
fitness: {}, debug: bool) -> None:
|
||||
"""Return a json collection for a hashtag
|
||||
"""
|
||||
page_number = 1
|
||||
page_number: int = 1
|
||||
if '?page=' in path:
|
||||
page_number_str = path.split('?page=')[1]
|
||||
if page_number_str.isdigit():
|
||||
|
|
@ -185,7 +185,7 @@ def hashtag_search2(self, calling_domain: str,
|
|||
instance_software: {}) -> None:
|
||||
"""Return the result of a hashtag search
|
||||
"""
|
||||
page_number = 1
|
||||
page_number: int = 1
|
||||
if '?page=' in path:
|
||||
page_number_str = path.split('?page=')[1]
|
||||
if '#' in page_number_str:
|
||||
|
|
|
|||
|
|
@ -86,8 +86,8 @@ def newswire_vote(self, calling_domain: str, path: str,
|
|||
if is_moderator(base_dir, nickname):
|
||||
newswire_item = newswire[date_str]
|
||||
print('Voting on newswire item: ' + str(newswire_item))
|
||||
votes_index = 2
|
||||
filename_index = 3
|
||||
votes_index: int = 2
|
||||
filename_index: int = 3
|
||||
if 'vote:' + nickname not in newswire_item[votes_index]:
|
||||
newswire_item[votes_index].append('vote:' + nickname)
|
||||
filename = newswire_item[filename_index]
|
||||
|
|
@ -144,8 +144,8 @@ def newswire_unvote(self, calling_domain: str, path: str,
|
|||
nickname = nickname.split('/')[0]
|
||||
if newswire.get(date_str):
|
||||
if is_moderator(base_dir, nickname):
|
||||
votes_index = 2
|
||||
filename_index = 3
|
||||
votes_index: int = 2
|
||||
filename_index: int = 3
|
||||
newswire_item = newswire[date_str]
|
||||
if 'vote:' + nickname in newswire_item[votes_index]:
|
||||
newswire_item[votes_index].remove('vote:' + nickname)
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ def show_media_timeline(self, authorized: bool,
|
|||
if request_http(self.headers, debug):
|
||||
nickname = path.replace('/users/', '')
|
||||
nickname = nickname.replace('/tlmedia', '')
|
||||
page_number = 1
|
||||
page_number: int = 1
|
||||
if '?page=' in nickname:
|
||||
page_number = nickname.split('?page=')[1]
|
||||
if ';' in page_number:
|
||||
|
|
@ -329,7 +329,7 @@ def show_blogs_timeline(self, authorized: bool,
|
|||
if request_http(self.headers, debug):
|
||||
nickname = path.replace('/users/', '')
|
||||
nickname = nickname.replace('/tlblogs', '')
|
||||
page_number = 1
|
||||
page_number: int = 1
|
||||
if '?page=' in nickname:
|
||||
page_number = nickname.split('?page=')[1]
|
||||
if ';' in page_number:
|
||||
|
|
@ -548,7 +548,7 @@ def show_news_timeline(self, authorized: bool,
|
|||
if request_http(self.headers, debug):
|
||||
nickname = path.replace('/users/', '')
|
||||
nickname = nickname.replace('/tlnews', '')
|
||||
page_number = 1
|
||||
page_number: int = 1
|
||||
if '?page=' in nickname:
|
||||
page_number = nickname.split('?page=')[1]
|
||||
if ';' in page_number:
|
||||
|
|
@ -769,7 +769,7 @@ def show_features_timeline(self, authorized: bool,
|
|||
if request_http(self.headers, debug):
|
||||
nickname = path.replace('/users/', '')
|
||||
nickname = nickname.replace('/tlfeatures', '')
|
||||
page_number = 1
|
||||
page_number: int = 1
|
||||
if '?page=' in nickname:
|
||||
page_number = nickname.split('?page=')[1]
|
||||
if ';' in page_number:
|
||||
|
|
@ -968,7 +968,7 @@ def show_shares_timeline(self, authorized: bool,
|
|||
if request_http(self.headers, debug):
|
||||
nickname = path.replace('/users/', '')
|
||||
nickname = nickname.replace('/tlshares', '')
|
||||
page_number = 1
|
||||
page_number: int = 1
|
||||
if '?page=' in nickname:
|
||||
page_number = nickname.split('?page=')[1]
|
||||
if ';' in page_number:
|
||||
|
|
@ -1120,7 +1120,7 @@ def show_wanted_timeline(self, authorized: bool,
|
|||
if request_http(self.headers, debug):
|
||||
nickname = path.replace('/users/', '')
|
||||
nickname = nickname.replace('/tlwanted', '')
|
||||
page_number = 1
|
||||
page_number: int = 1
|
||||
if '?page=' in nickname:
|
||||
page_number = nickname.split('?page=')[1]
|
||||
if ';' in page_number:
|
||||
|
|
@ -1289,7 +1289,7 @@ def show_bookmarks_timeline(self, authorized: bool,
|
|||
nickname = path.replace('/users/', '')
|
||||
nickname = nickname.replace('/tlbookmarks', '')
|
||||
nickname = nickname.replace('/bookmarks', '')
|
||||
page_number = 1
|
||||
page_number: int = 1
|
||||
if '?page=' in nickname:
|
||||
page_number = nickname.split('?page=')[1]
|
||||
if ';' in page_number:
|
||||
|
|
@ -1713,7 +1713,7 @@ def show_mod_timeline(self, authorized: bool,
|
|||
if request_http(self.headers, debug):
|
||||
nickname = path.replace('/users/', '')
|
||||
nickname = nickname.replace('/moderation', '')
|
||||
page_number = 1
|
||||
page_number: int = 1
|
||||
if '?page=' in nickname:
|
||||
page_number = nickname.split('?page=')[1]
|
||||
if ';' in page_number:
|
||||
|
|
@ -1922,7 +1922,7 @@ def show_dms(self, authorized: bool,
|
|||
if request_http(self.headers, debug):
|
||||
nickname = path.replace('/users/', '')
|
||||
nickname = nickname.replace('/dm', '')
|
||||
page_number = 1
|
||||
page_number: int = 1
|
||||
if '?page=' in nickname:
|
||||
page_number = nickname.split('?page=')[1]
|
||||
if ';' in page_number:
|
||||
|
|
@ -2139,7 +2139,7 @@ def show_replies(self, authorized: bool,
|
|||
if request_http(self.headers, debug):
|
||||
nickname = path.replace('/users/', '')
|
||||
nickname = nickname.replace('/tlreplies', '')
|
||||
page_number = 1
|
||||
page_number: int = 1
|
||||
if '?page=' in nickname:
|
||||
page_number = nickname.split('?page=')[1]
|
||||
if ';' in page_number:
|
||||
|
|
@ -2360,7 +2360,7 @@ def show_inbox(self, authorized: bool,
|
|||
if request_http(self.headers, debug):
|
||||
nickname = path.replace('/users/', '')
|
||||
nickname = nickname.replace('/inbox', '')
|
||||
page_number = 1
|
||||
page_number: int = 1
|
||||
if '?page=' in nickname:
|
||||
page_number = nickname.split('?page=')[1]
|
||||
if ';' in page_number:
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ from data import save_string
|
|||
def _person_options_page_number(options_confirm_params: str) -> int:
|
||||
"""Get the page number
|
||||
"""
|
||||
page_number = 1
|
||||
page_number: int = 1
|
||||
if 'pageNumber=' in options_confirm_params:
|
||||
page_number_str = options_confirm_params.split('pageNumber=')[1]
|
||||
if '&' in page_number_str:
|
||||
|
|
@ -1315,7 +1315,7 @@ def person_options2(self, path: str,
|
|||
instance_software: {}) -> None:
|
||||
"""Receive POST from person options screen
|
||||
"""
|
||||
page_number = 1
|
||||
page_number: int = 1
|
||||
users_path = path.split('/personoptions')[0]
|
||||
origin_path_str = http_prefix + '://' + domain_full + users_path
|
||||
|
||||
|
|
|
|||
|
|
@ -2284,7 +2284,7 @@ def _profile_post_registrations_remaining(base_dir: str, fields: {}) -> None:
|
|||
remaining = get_config_param(base_dir, reg_str)
|
||||
if fields.get('regRemaining'):
|
||||
if fields['regRemaining'] != remaining:
|
||||
remaining = int(fields['regRemaining'])
|
||||
remaining: int = int(fields['regRemaining'])
|
||||
if remaining < 0:
|
||||
remaining = 0
|
||||
elif remaining > 10:
|
||||
|
|
@ -2608,7 +2608,7 @@ def _profile_post_skill_level(actor_json: {},
|
|||
actor_changed: bool) -> bool:
|
||||
""" HTTP POST set skill levels
|
||||
"""
|
||||
skill_ctr = 1
|
||||
skill_ctr: int = 1
|
||||
actor_skills_ctr = no_of_actor_skills(actor_json)
|
||||
while skill_ctr < 10:
|
||||
skill_name = fields.get('skillName' + str(skill_ctr))
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ def receive_vote(self, calling_domain: str, cookie: str,
|
|||
last_post_id = last_post_id.replace('/', '--')
|
||||
last_post_id = ';lastpost=' + last_post_id.replace('#', '--')
|
||||
|
||||
page_number = 1
|
||||
page_number: int = 1
|
||||
if '?page=' in path:
|
||||
page_number_str = path.split('?page=')[1]
|
||||
if '#' in page_number_str:
|
||||
|
|
|
|||
|
|
@ -1660,8 +1660,8 @@ def _receive_new_post_process_newshare(self, fields: {},
|
|||
if duration_str:
|
||||
if ' ' not in duration_str:
|
||||
duration_str = duration_str + ' days'
|
||||
city = get_spoofed_city(city, base_dir, nickname, domain)
|
||||
item_qty = 1
|
||||
city: str = get_spoofed_city(city, base_dir, nickname, domain)
|
||||
item_qty: int = 1
|
||||
if fields['itemQty']:
|
||||
if is_float(fields['itemQty']):
|
||||
item_qty = float(fields['itemQty'])
|
||||
|
|
@ -2008,7 +2008,7 @@ def _receive_new_post_process(self, post_type: str, path: str, headers: {},
|
|||
if latitude is not None and \
|
||||
longitude is not None:
|
||||
osm_domain = 'osm.org'
|
||||
zoom = 17
|
||||
zoom: int = 17
|
||||
fields['location'] = \
|
||||
geocoords_to_osm_link(osm_domain, zoom,
|
||||
latitude, longitude)
|
||||
|
|
@ -2465,7 +2465,7 @@ def receive_new_post(self, post_type, path: str,
|
|||
"""A new post has been created
|
||||
This creates a thread to send the new post
|
||||
"""
|
||||
page_number = 1
|
||||
page_number: int = 1
|
||||
original_path = path
|
||||
|
||||
if '/users/' not in path:
|
||||
|
|
|
|||
|
|
@ -319,7 +319,7 @@ def receive_remove_post(self, calling_domain: str, cookie: str,
|
|||
curr_session, proxy_type: str) -> None:
|
||||
"""Endpoint for removing posts after confirmation
|
||||
"""
|
||||
page_number = 1
|
||||
page_number: int = 1
|
||||
users_path = path.split('/rmpost')[0]
|
||||
origin_path_str = \
|
||||
http_prefix + '://' + \
|
||||
|
|
|
|||
|
|
@ -817,7 +817,7 @@ def receive_search_query(self, calling_domain: str, cookie: str,
|
|||
"""Receive a search query
|
||||
"""
|
||||
# get the page number
|
||||
page_number = 1
|
||||
page_number: int = 1
|
||||
if '/searchhandle?page=' in path:
|
||||
page_number_str = path.split('/searchhandle?page=')[1]
|
||||
if '#' in page_number_str:
|
||||
|
|
|
|||
|
|
@ -658,11 +658,11 @@ def show_person_options(self, calling_domain: str, 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:
|
||||
page_number = 1
|
||||
page_number: int = 1
|
||||
options_list = options_str.split(';')
|
||||
options_actor = options_list[0]
|
||||
options_actor_url = options_actor
|
||||
options_page_number = 1
|
||||
options_page_number: int = 1
|
||||
if len(options_list) > 1:
|
||||
options_page_number = options_list[1]
|
||||
options_profile_url: str = ''
|
||||
|
|
|
|||
|
|
@ -1176,9 +1176,9 @@ def _desktop_show_box(indent: str,
|
|||
page_number: int) -> bool:
|
||||
"""Shows online timeline
|
||||
"""
|
||||
number_width = 2
|
||||
name_width = 16
|
||||
content_width = 50
|
||||
number_width: int = 2
|
||||
name_width: int = 16
|
||||
content_width: int = 50
|
||||
|
||||
# title
|
||||
_desktop_clear_screen()
|
||||
|
|
@ -1210,7 +1210,7 @@ def _desktop_show_box(indent: str,
|
|||
print('')
|
||||
return False
|
||||
|
||||
ctr = 1
|
||||
ctr: int = 1
|
||||
for post_json_object in box_json['orderedItems']:
|
||||
if not post_json_object.get('type'):
|
||||
continue
|
||||
|
|
@ -1649,7 +1649,7 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
|
|||
system_language, espeak)
|
||||
|
||||
curr_timeline = 'inbox'
|
||||
page_number = 1
|
||||
page_number: int = 1
|
||||
|
||||
post_json_object = {}
|
||||
original_screen_reader = screenreader
|
||||
|
|
@ -1808,7 +1808,7 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
|
|||
command_str = _desktop_wait_for_cmd(2, debug)
|
||||
break
|
||||
if command_str.startswith('show dm'):
|
||||
page_number = 1
|
||||
page_number: int = 1
|
||||
prev_timeline_first_id: str = ''
|
||||
curr_timeline = 'dm'
|
||||
box_json = c2s_box_json(session, nickname, password,
|
||||
|
|
@ -1823,7 +1823,7 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
|
|||
screenreader, system_language, espeak,
|
||||
page_number)
|
||||
elif command_str.startswith('show rep'):
|
||||
page_number = 1
|
||||
page_number: int = 1
|
||||
prev_timeline_first_id: str = ''
|
||||
curr_timeline = 'tlreplies'
|
||||
box_json = c2s_box_json(session, nickname, password,
|
||||
|
|
@ -1838,7 +1838,7 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
|
|||
screenreader, system_language, espeak,
|
||||
page_number)
|
||||
elif command_str.startswith('show b'):
|
||||
page_number = 1
|
||||
page_number: int = 1
|
||||
prev_timeline_first_id: str = ''
|
||||
curr_timeline = 'tlbookmarks'
|
||||
box_json = c2s_box_json(session, nickname, password,
|
||||
|
|
@ -1854,7 +1854,7 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
|
|||
page_number)
|
||||
elif string_starts_with(command_str,
|
||||
('show sen', 'show out')):
|
||||
page_number = 1
|
||||
page_number: int = 1
|
||||
prev_timeline_first_id: str = ''
|
||||
curr_timeline = 'outbox'
|
||||
box_json = c2s_box_json(session, nickname, password,
|
||||
|
|
@ -1870,7 +1870,7 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
|
|||
page_number)
|
||||
elif (command_str == 'show' or command_str.startswith('show in') or
|
||||
command_str == 'clear'):
|
||||
page_number = 1
|
||||
page_number: int = 1
|
||||
prev_timeline_first_id: str = ''
|
||||
curr_timeline = 'inbox'
|
||||
refresh_timeline = True
|
||||
|
|
@ -2549,7 +2549,7 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
|
|||
print('')
|
||||
elif (command_str == 'follow requests' or
|
||||
command_str.startswith('follow requests ')):
|
||||
curr_page = 1
|
||||
curr_page: int = 1
|
||||
if ' ' in command_str:
|
||||
page_num = command_str.split(' ')[-1].strip()
|
||||
if len(page_num) > 5:
|
||||
|
|
@ -2571,7 +2571,7 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
|
|||
print('')
|
||||
elif (command_str == 'following' or
|
||||
command_str.startswith('following ')):
|
||||
curr_page = 1
|
||||
curr_page: int = 1
|
||||
if ' ' in command_str:
|
||||
page_num = command_str.split(' ')[-1].strip()
|
||||
if len(page_num) > 5:
|
||||
|
|
@ -2594,7 +2594,7 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
|
|||
print('')
|
||||
elif (command_str == 'followers' or
|
||||
command_str.startswith('followers ')):
|
||||
curr_page = 1
|
||||
curr_page: int = 1
|
||||
if ' ' in command_str:
|
||||
page_num = command_str.split(' ')[-1].strip()
|
||||
if len(page_num) > 5:
|
||||
|
|
|
|||
10
epicyon.py
10
epicyon.py
|
|
@ -960,7 +960,7 @@ def _command_options() -> None:
|
|||
nickname = get_nickname_from_actor(url)
|
||||
domain, _ = get_domain_from_actor(url)
|
||||
url = http_prefix + '://' + domain + '/users/' + nickname
|
||||
timeout = 15
|
||||
timeout: int = 15
|
||||
sites_unavailable: list[str] = []
|
||||
active = site_is_active(url, timeout,
|
||||
sites_unavailable)
|
||||
|
|
@ -1672,7 +1672,7 @@ def _command_options() -> None:
|
|||
preferred_podcast_formats.append(pod_format)
|
||||
|
||||
if argb.rss:
|
||||
timeout_sec = 20
|
||||
timeout_sec: int = 20
|
||||
session = create_session(None)
|
||||
if not argb.language:
|
||||
argb.language = 'en'
|
||||
|
|
@ -1733,7 +1733,7 @@ def _command_options() -> None:
|
|||
if not argb.maxRegistrations:
|
||||
max_registrations = get_config_param(base_dir, 'maxRegistrations')
|
||||
if not max_registrations:
|
||||
max_registrations = 10
|
||||
max_registrations: int = 10
|
||||
set_config_param(base_dir, 'maxRegistrations',
|
||||
str(max_registrations))
|
||||
else:
|
||||
|
|
@ -1796,7 +1796,7 @@ def _command_options() -> None:
|
|||
yggdrasil_domain = None
|
||||
|
||||
# get port number from configuration
|
||||
config_port = get_config_param(base_dir, 'port')
|
||||
config_port: int = get_config_param(base_dir, 'port')
|
||||
if config_port:
|
||||
port = config_port
|
||||
else:
|
||||
|
|
@ -1806,7 +1806,7 @@ def _command_options() -> None:
|
|||
else:
|
||||
port = 443
|
||||
|
||||
config_proxy_port = get_config_param(base_dir, 'proxyPort')
|
||||
config_proxy_port: int = get_config_param(base_dir, 'proxyPort')
|
||||
if config_proxy_port:
|
||||
proxy_port = config_proxy_port
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -456,7 +456,7 @@ def get_following_feed(base_dir: str, domain: str, port: int, path: str,
|
|||
header_only = True
|
||||
page_number = None
|
||||
if '?page=' in path:
|
||||
page_number = path.split('?page=')[1]
|
||||
page_number: int = path.split('?page=')[1]
|
||||
if len(page_number) > 5:
|
||||
page_number = "1"
|
||||
if page_number == 'true' or not authorized:
|
||||
|
|
|
|||
16
happening.py
16
happening.py
|
|
@ -1300,17 +1300,17 @@ def dav_report_response(base_dir: str, nickname: str, domain: str,
|
|||
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
|
||||
end_month_number = query_end_month
|
||||
start_month_number: int = query_start_month
|
||||
end_month_number: int = query_end_month
|
||||
elif year == query_end_year:
|
||||
start_month_number = 1
|
||||
end_month_number = query_end_month
|
||||
start_month_number: int = 1
|
||||
end_month_number: int = query_end_month
|
||||
elif year == query_start_year:
|
||||
start_month_number = query_start_month
|
||||
end_month_number = 12
|
||||
start_month_number: int = query_start_month
|
||||
end_month_number: int = 12
|
||||
else:
|
||||
start_month_number = 1
|
||||
end_month_number = 12
|
||||
start_month_number: int = 1
|
||||
end_month_number: int = 12
|
||||
for month in range(start_month_number, end_month_number+1):
|
||||
ical_events = \
|
||||
get_month_events_icalendar(base_dir,
|
||||
|
|
|
|||
|
|
@ -499,7 +499,7 @@ def receive_edit_to_post(recent_posts_cache: {}, message_json: {},
|
|||
# remove from memory cache
|
||||
remove_post_from_cache(message_json, recent_posts_cache)
|
||||
# regenerate html for the post
|
||||
page_number = 1
|
||||
page_number: int = 1
|
||||
show_published_date_only: bool = False
|
||||
show_individual_post_icons: bool = True
|
||||
manually_approve_followers = \
|
||||
|
|
@ -1080,7 +1080,7 @@ def receive_like(recent_posts_cache: {},
|
|||
print('Liked post json: ' + str(liked_post_json))
|
||||
print('Liked post nickname: ' + handle_name + ' ' + domain)
|
||||
print('Liked post cache: ' + str(cached_post_filename))
|
||||
page_number = 1
|
||||
page_number: int = 1
|
||||
show_published_date_only: bool = False
|
||||
show_individual_post_icons: bool = True
|
||||
manually_approve_followers = \
|
||||
|
|
@ -1330,7 +1330,7 @@ def receive_reaction(recent_posts_cache: {},
|
|||
print('Reaction post json: ' + str(reaction_post_json))
|
||||
print('Reaction post nickname: ' + handle_name + ' ' + domain)
|
||||
print('Reaction post cache: ' + str(cached_post_filename))
|
||||
page_number = 1
|
||||
page_number: int = 1
|
||||
show_published_date_only: bool = False
|
||||
show_individual_post_icons: bool = True
|
||||
manually_approve_followers = \
|
||||
|
|
@ -1529,7 +1529,7 @@ def receive_zot_reaction(recent_posts_cache: {},
|
|||
print('Reaction post json: ' + str(reaction_post_json))
|
||||
print('Reaction post nickname: ' + handle_name + ' ' + domain)
|
||||
print('Reaction post cache: ' + str(cached_post_filename))
|
||||
page_number = 1
|
||||
page_number: int = 1
|
||||
show_published_date_only: bool = False
|
||||
show_individual_post_icons: bool = True
|
||||
manually_approve_followers = \
|
||||
|
|
@ -1671,7 +1671,7 @@ def receive_bookmark(recent_posts_cache: {},
|
|||
print('Bookmarked post json: ' + str(bookmarked_post_json))
|
||||
print('Bookmarked post nickname: ' + nickname + ' ' + domain)
|
||||
print('Bookmarked post cache: ' + str(cached_post_filename))
|
||||
page_number = 1
|
||||
page_number: int = 1
|
||||
show_published_date_only: bool = False
|
||||
show_individual_post_icons: bool = True
|
||||
manually_approve_followers = \
|
||||
|
|
@ -1983,7 +1983,7 @@ def receive_announce(recent_posts_cache: {},
|
|||
domain_full = get_full_domain(domain, port)
|
||||
|
||||
# Generate html. This also downloads the announced post.
|
||||
page_number: bool = 1
|
||||
page_number: int = 1
|
||||
show_published_date_only: bool = False
|
||||
show_individual_post_icons: bool = True
|
||||
manually_approve_followers = \
|
||||
|
|
|
|||
14
maps.py
14
maps.py
|
|
@ -332,8 +332,8 @@ def get_location_from_post(post_json_object: {}) -> str:
|
|||
|
||||
if locn_exists:
|
||||
# location geocoordinate
|
||||
osm_domain = 'osm.org'
|
||||
zoom = 17
|
||||
osm_domain: str = 'osm.org'
|
||||
zoom: int = 17
|
||||
locn = geocoords_to_osm_link(osm_domain, zoom,
|
||||
locn2['latitude'],
|
||||
locn2['longitude'])
|
||||
|
|
@ -567,7 +567,7 @@ def _geocoords_from_osmand_link(url: str) -> (int, float, float):
|
|||
"""
|
||||
latitude = None
|
||||
longitude = None
|
||||
zoom = 10
|
||||
zoom: int = 10
|
||||
|
||||
if 'pin=' in url:
|
||||
pin_coords_str = url.split('pin=')[1]
|
||||
|
|
@ -602,7 +602,7 @@ def _geocoords_from_geo_link(url: str) -> (int, float, float):
|
|||
"""
|
||||
latitude = None
|
||||
longitude = None
|
||||
zoom = 10
|
||||
zoom: int = 10
|
||||
|
||||
coords_str = url.split('geo:')[1]
|
||||
if ',' in coords_str:
|
||||
|
|
@ -648,7 +648,7 @@ def _geocoords_from_gmaps_link(url: str) -> (int, float, float):
|
|||
coords = coords_str.split(',')
|
||||
if len(coords) not in (2, 3):
|
||||
return None, None, None
|
||||
zoom = 100
|
||||
zoom: int = 100
|
||||
if zoom_exists:
|
||||
zoom = coords[2]
|
||||
if not zoom.isdigit():
|
||||
|
|
@ -702,7 +702,7 @@ def _geocoords_from_bmaps_link(url: str) -> (int, float, float):
|
|||
coords[1] = coords[1].split('"')[0]
|
||||
if not is_float(longitude):
|
||||
return None, None, None
|
||||
zoom = 17
|
||||
zoom: int = 17
|
||||
if 'lvl=' in orig_coords_str:
|
||||
zoom = orig_coords_str.split('lvl=')[1]
|
||||
if '&' in zoom:
|
||||
|
|
@ -750,7 +750,7 @@ def _geocoords_from_waze_link(url: str) -> (int, float, float):
|
|||
coords[1] = coords[1].split('"')[0]
|
||||
if not is_float(longitude):
|
||||
return None, None, None
|
||||
zoom = 17
|
||||
zoom: int = 17
|
||||
if 'zoom=' in orig_coords_str:
|
||||
zoom = orig_coords_str.split('zoom=')[1]
|
||||
if '&' in zoom:
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ def _meta_data_instance_v1(show_accounts: bool,
|
|||
if rules_lines is None:
|
||||
return {}
|
||||
|
||||
rule_ctr = 1
|
||||
rule_ctr: int = 1
|
||||
for line in rules_lines:
|
||||
line = line.strip()
|
||||
if not line:
|
||||
|
|
@ -78,11 +78,11 @@ def _meta_data_instance_v1(show_accounts: bool,
|
|||
admin_actor['preferredUsername']
|
||||
|
||||
if show_accounts:
|
||||
active_accounts = no_of_accounts(base_dir)
|
||||
local_posts = get_status_count(base_dir)
|
||||
active_accounts: int = no_of_accounts(base_dir)
|
||||
local_posts: int = get_status_count(base_dir)
|
||||
else:
|
||||
active_accounts = 1
|
||||
local_posts = 1
|
||||
active_accounts: int = 1
|
||||
local_posts: int = 1
|
||||
|
||||
created_at = ''
|
||||
if admin_actor.get('published'):
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ def _meta_data_instance_v2(show_accounts: bool,
|
|||
if rules_lines is None:
|
||||
return {}
|
||||
|
||||
rule_ctr = 1
|
||||
rule_ctr: int = 1
|
||||
for line in rules_lines:
|
||||
line = line.strip()
|
||||
if not line:
|
||||
|
|
@ -85,9 +85,9 @@ def _meta_data_instance_v2(show_accounts: bool,
|
|||
admin_actor['preferredUsername']
|
||||
|
||||
if show_accounts:
|
||||
active_accounts = no_of_accounts(base_dir)
|
||||
active_accounts: int = no_of_accounts(base_dir)
|
||||
else:
|
||||
active_accounts = 1
|
||||
active_accounts: int = 1
|
||||
|
||||
created_at = ''
|
||||
if admin_actor.get('published'):
|
||||
|
|
|
|||
18
metadata.py
18
metadata.py
|
|
@ -33,15 +33,17 @@ def meta_data_node_info(base_dir: str,
|
|||
sensitive
|
||||
"""
|
||||
if show_accounts:
|
||||
active_accounts = no_of_accounts(base_dir)
|
||||
active_accounts_monthly = no_of_active_accounts_monthly(base_dir, 1)
|
||||
active_accounts_half_year = no_of_active_accounts_monthly(base_dir, 6)
|
||||
local_posts = get_status_count(base_dir)
|
||||
active_accounts: int = no_of_accounts(base_dir)
|
||||
active_accounts_monthly: int = \
|
||||
no_of_active_accounts_monthly(base_dir, 1)
|
||||
active_accounts_half_year: int = \
|
||||
no_of_active_accounts_monthly(base_dir, 6)
|
||||
local_posts: int = get_status_count(base_dir)
|
||||
else:
|
||||
active_accounts = 1
|
||||
active_accounts_monthly = 1
|
||||
active_accounts_half_year = 1
|
||||
local_posts = 1
|
||||
active_accounts: int = 1
|
||||
active_accounts_monthly: int = 1
|
||||
active_accounts_half_year: int = 1
|
||||
local_posts: int = 1
|
||||
|
||||
nodeinfo = {
|
||||
"version": "2.2",
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ def _download_newswire_feed_favicon(session, base_dir: str,
|
|||
fav_url = get_newswire_favicon_url(link)
|
||||
if '://' not in link:
|
||||
return False
|
||||
timeout_sec = 10
|
||||
timeout_sec: int = 10
|
||||
image_data, mime_type = \
|
||||
download_image_any_mime_type(session, fav_url, timeout_sec, debug)
|
||||
if not image_data or not mime_type:
|
||||
|
|
|
|||
|
|
@ -1168,7 +1168,7 @@ def person_box_json(recent_posts_cache: {},
|
|||
# handle page numbers
|
||||
page_number = None
|
||||
if '?page=' in path:
|
||||
page_number = path.split('?page=')[1]
|
||||
page_number: int = path.split('?page=')[1]
|
||||
if ';' in page_number:
|
||||
page_number = page_number.split(';')[0]
|
||||
if len(page_number) > 5:
|
||||
|
|
|
|||
8
posts.py
8
posts.py
|
|
@ -5873,9 +5873,9 @@ def get_public_posts_of_person(base_dir: str, nickname: str, domain: str,
|
|||
if not person_id:
|
||||
return
|
||||
|
||||
max_mentions = 10
|
||||
max_emoji = 10
|
||||
max_attachments = 5
|
||||
max_mentions: int = 10
|
||||
max_emoji: int = 10
|
||||
max_attachments: int = 5
|
||||
_get_posts(session, person_url, 30, max_mentions, max_emoji,
|
||||
max_attachments, federation_list, raw, simple, debug,
|
||||
project_version, http_prefix, origin_domain, system_language,
|
||||
|
|
@ -7020,7 +7020,7 @@ def get_max_profile_posts(base_dir: str, nickname: str, domain: str,
|
|||
"""
|
||||
max_posts_filename = \
|
||||
acct_dir(base_dir, nickname, domain) + '/max_profile_posts.txt'
|
||||
max_profile_posts = 4
|
||||
max_profile_posts: int = 4
|
||||
if not os.path.isfile(max_posts_filename):
|
||||
return max_profile_posts
|
||||
max_posts_str = \
|
||||
|
|
|
|||
|
|
@ -497,7 +497,7 @@ def _update_common_reactions(base_dir: str, emoji_content: str) -> None:
|
|||
if ' ' + emoji_content in line:
|
||||
if not reaction_found:
|
||||
reaction_found = True
|
||||
counter = 1
|
||||
counter: int = 1
|
||||
count_str = line.split(' ')[0]
|
||||
if count_str.isdigit():
|
||||
counter = int(count_str) + 1
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ def get_moved_feed(base_dir: str, domain: str, port: int, path: str,
|
|||
page_ctr: int = 0
|
||||
curr_page += 1
|
||||
following['totalItems'] = total_ctr
|
||||
last_page = 1
|
||||
last_page: int = 1
|
||||
if follows_per_page > 0:
|
||||
last_page = int(total_ctr / follows_per_page)
|
||||
last_page = max(last_page, 1)
|
||||
|
|
|
|||
|
|
@ -240,8 +240,8 @@ def _get_json_signed(session, url: str, domain_full: str, session_headers: {},
|
|||
if '://' not in url:
|
||||
print('Invalid url: ' + url)
|
||||
return None
|
||||
http_prefix = url.split('://')[0]
|
||||
to_domain_full = url.split('://')[1]
|
||||
http_prefix: str = url.split('://')[0]
|
||||
to_domain_full: str = url.split('://')[1]
|
||||
if '/' in to_domain_full:
|
||||
to_domain_full = to_domain_full.split('/')[0]
|
||||
|
||||
|
|
|
|||
|
|
@ -1906,12 +1906,12 @@ def run_federated_shares_daemon(base_dir: str, httpd, http_prefix: str,
|
|||
mitm_servers: []) -> None:
|
||||
"""Runs the daemon used to update federated shared items
|
||||
"""
|
||||
seconds_per_hour = 60 * 60
|
||||
file_check_interval_sec = 120
|
||||
seconds_per_hour: int = 60 * 60
|
||||
file_check_interval_sec: int = 120
|
||||
time.sleep(60)
|
||||
# the token for this instance will be changed every 7-14 days
|
||||
min_days = 7
|
||||
max_days = 14
|
||||
min_days: int = 7
|
||||
max_days: int = 14
|
||||
_generate_next_shares_token_update(base_dir, min_days, max_days)
|
||||
sites_unavailable: list[str] = []
|
||||
while True:
|
||||
|
|
|
|||
|
|
@ -44,8 +44,8 @@ def get_speaker_pitch(display_name: str, screenreader: str,
|
|||
"""Returns the speech synthesis pitch for the given name
|
||||
"""
|
||||
random.seed(display_name)
|
||||
range_min = 1
|
||||
range_max = 100
|
||||
range_min: int = 1
|
||||
range_max: int = 100
|
||||
if 'She' in gender:
|
||||
range_min = 50
|
||||
elif 'Him' in gender:
|
||||
|
|
|
|||
73
tests.py
73
tests.py
|
|
@ -488,7 +488,7 @@ def _test_http_sig_new(algorithm: str, digest_algorithm: str):
|
|||
body_digest = \
|
||||
message_content_digest(message_body_json_str, digest_algorithm)
|
||||
assert body_digest in digest_str
|
||||
content_length = 18
|
||||
content_length: int = 18
|
||||
content_type = 'application/activity+json'
|
||||
public_key_pem = \
|
||||
'-----BEGIN RSA PUBLIC KEY-----\n' + \
|
||||
|
|
@ -773,17 +773,17 @@ def create_server_alice(path: str, domain: str, port: int,
|
|||
os.mkdir(path)
|
||||
os.chdir(path)
|
||||
shared_items_federated_domains: list[str] = []
|
||||
system_language = 'en'
|
||||
languages_understood = [system_language]
|
||||
nickname = 'alice'
|
||||
http_prefix = 'http'
|
||||
system_language: str = 'en'
|
||||
languages_understood: list[str] = [system_language]
|
||||
nickname: str = 'alice'
|
||||
http_prefix: str = 'http'
|
||||
proxy_type = None
|
||||
password = 'alicepass'
|
||||
max_replies = 64
|
||||
domain_max_posts_per_day = 1000
|
||||
account_max_posts_per_day = 1000
|
||||
allow_deletion = True
|
||||
low_bandwidth = True
|
||||
password: str = 'alicepass'
|
||||
max_replies: int = 64
|
||||
domain_max_posts_per_day: int = 1000
|
||||
account_max_posts_per_day: int = 1000
|
||||
allow_deletion: bool = True
|
||||
low_bandwidth: bool = True
|
||||
private_key_pem, public_key_pem, person, wf_endpoint = \
|
||||
create_person(path, nickname, domain, port, http_prefix, True,
|
||||
False, password)
|
||||
|
|
@ -807,7 +807,7 @@ def create_server_alice(path: str, domain: str, port: int,
|
|||
test_attach_image_filename = None
|
||||
test_media_type = None
|
||||
test_image_description = None
|
||||
test_city = 'London, England'
|
||||
test_city: str = 'London, England'
|
||||
test_in_reply_to = None
|
||||
test_in_reply_to_atom_uri = None
|
||||
test_subject = None
|
||||
|
|
@ -815,19 +815,21 @@ def create_server_alice(path: str, domain: str, port: int,
|
|||
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: bool = False
|
||||
conversation_id = None
|
||||
convthread_id = None
|
||||
translate = {}
|
||||
content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0'
|
||||
media_license_url = 'https://creativecommons.org/licenses/by-nc/4.0'
|
||||
media_creator = 'Mr Blobby'
|
||||
buy_url = ''
|
||||
chat_url = ''
|
||||
auto_cw_cache = {}
|
||||
test_video_transcript = ''
|
||||
translate: dict = {}
|
||||
content_license_url: str = \
|
||||
'https://creativecommons.org/licenses/by-nc/4.0'
|
||||
media_license_url: str = \
|
||||
'https://creativecommons.org/licenses/by-nc/4.0'
|
||||
media_creator: str = 'Mr Blobby'
|
||||
buy_url: str = ''
|
||||
chat_url: str = ''
|
||||
auto_cw_cache: dict = {}
|
||||
test_video_transcript: str = ''
|
||||
searchable_by: list[str] = []
|
||||
session = None
|
||||
create_public_post(path, nickname, domain, port, http_prefix,
|
||||
|
|
@ -4389,8 +4391,8 @@ def _test_theme():
|
|||
|
||||
def _test_recent_posts_cache():
|
||||
print('test_recent_posts_cache')
|
||||
recent_posts_cache = {}
|
||||
max_recent_posts = 3
|
||||
recent_posts_cache: dict = {}
|
||||
max_recent_posts: int = 3
|
||||
html_str = '<html></html>'
|
||||
for i in range(5):
|
||||
post_json_object = {
|
||||
|
|
@ -4928,8 +4930,8 @@ def _test_constant_time_string():
|
|||
assert not constant_time_string_check('testing', '1234')
|
||||
assert not constant_time_string_check('testing', '1234567')
|
||||
|
||||
time_threshold_microseconds = 10
|
||||
itterations = 256
|
||||
time_threshold_microseconds: int = 10
|
||||
itterations: int = 256
|
||||
|
||||
start = time.time()
|
||||
test_str = 'nnjfbefefbsnjsdnvbcueftqfeuqfbqefnjeniwufgy'
|
||||
|
|
@ -7630,7 +7632,7 @@ def _test_can_replyto(base_dir: str) -> None:
|
|||
|
||||
# test a post within the reply interval
|
||||
post_url = post_json_object['object']['id']
|
||||
reply_interval_hours = 2
|
||||
reply_interval_hours: int = 2
|
||||
curr_date_str = "2021-09-08T21:32:10Z"
|
||||
assert can_reply_to(base_dir, nickname, domain,
|
||||
post_url, reply_interval_hours,
|
||||
|
|
@ -9210,15 +9212,18 @@ def _test_book_link(base_dir: str):
|
|||
expected_readers += 1
|
||||
print('reader_list 3: ' + str(books_cache['reader_list']))
|
||||
|
||||
title = 'Pirate Enlightenment, or the Real Libertalia'
|
||||
image_url = 'https://bookwyrm.instance/images/previews/covers/5283.jpg'
|
||||
book_url = 'https://bookwyrm.instance/book/78252'
|
||||
content = 'rated <a href="' + book_url + \
|
||||
title: str = \
|
||||
'Pirate Enlightenment, or the Real Libertalia'
|
||||
image_url: str = \
|
||||
'https://bookwyrm.instance/images/previews/covers/5283.jpg'
|
||||
book_url: str = \
|
||||
'https://bookwyrm.instance/book/78252'
|
||||
content: str = 'rated <a href="' + book_url + \
|
||||
'"><i>' + title + '</i></a>'
|
||||
actor = 'https://bookwyrm.instance/user/ghi'
|
||||
rating = 3.5
|
||||
id_str = actor + '/generatednote/73467834576'
|
||||
published = '2024-01-03T12:30:00.2+00:00'
|
||||
actor: str = 'https://bookwyrm.instance/user/ghi'
|
||||
rating: float = 3.5
|
||||
id_str: str = actor + '/generatednote/73467834576'
|
||||
published: str = '2024-01-03T12:30:00.2+00:00'
|
||||
post_json_object = {
|
||||
'@context': 'https://www.w3.org/ns/activitystreams',
|
||||
'attachment': [{'@context': 'https://www.w3.org/ns/activitystreams',
|
||||
|
|
|
|||
2
utils.py
2
utils.py
|
|
@ -904,7 +904,7 @@ def save_json(json_object: {}, filename: str) -> bool:
|
|||
print('EX: save_json object is not json ' + str(json_object))
|
||||
return False
|
||||
|
||||
tries = 1
|
||||
tries: int = 1
|
||||
while tries <= 5:
|
||||
try:
|
||||
with open(filename, 'w+', encoding='utf-8') as fp_json:
|
||||
|
|
|
|||
|
|
@ -404,7 +404,8 @@ def html_calendar(person_cache: {}, translate: {},
|
|||
month_number = default_month
|
||||
day_number = None
|
||||
year: int = default_year
|
||||
actor = http_prefix + '://' + domain_full + path.replace('/calendar', '')
|
||||
actor: str = \
|
||||
http_prefix + '://' + domain_full + path.replace('/calendar', '')
|
||||
only_show_reminders: bool = False
|
||||
if '?' in actor:
|
||||
first = True
|
||||
|
|
@ -494,14 +495,14 @@ def html_calendar(person_cache: {}, translate: {},
|
|||
get_calendar_events(base_dir, nickname, domain, year, month_number,
|
||||
text_match, only_show_reminders)
|
||||
|
||||
prev_year = year
|
||||
prev_month_number = month_number - 1
|
||||
prev_year: int = year
|
||||
prev_month_number: int = month_number - 1
|
||||
if prev_month_number < 1:
|
||||
prev_month_number = 12
|
||||
prev_year = year - 1
|
||||
|
||||
next_year = year
|
||||
next_month_number = month_number + 1
|
||||
next_year: int = year
|
||||
next_month_number: int = month_number + 1
|
||||
if next_month_number > 12:
|
||||
next_month_number = 1
|
||||
next_year = year + 1
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ def _get_left_column_shares(base_dir: str,
|
|||
shared_items_federated_domains: []) -> []:
|
||||
"""get any shares and turn them into the left column links format
|
||||
"""
|
||||
page_number = 1
|
||||
page_number: int = 1
|
||||
actor = local_actor_url(http_prefix, nickname, domain_full)
|
||||
# NOTE: this could potentially be slow if the number of federated
|
||||
# shared items is large
|
||||
|
|
@ -87,7 +87,7 @@ def _get_left_column_wanted(base_dir: str,
|
|||
shared_items_federated_domains: []) -> []:
|
||||
"""get any wanted items and turn them into the left column links format
|
||||
"""
|
||||
page_number = 1
|
||||
page_number: int = 1
|
||||
actor = local_actor_url(http_prefix, nickname, domain_full)
|
||||
# NOTE: this could potentially be slow if the number of federated
|
||||
# wanted items is large
|
||||
|
|
|
|||
|
|
@ -394,10 +394,10 @@ def html_new_post(edit_post_params: {},
|
|||
'<input type="time" name="eventEndTime"' + \
|
||||
end_time_default + '></label>\n</p>\n'
|
||||
|
||||
show_public_on_dropdown = True
|
||||
message_box_height = 400
|
||||
image_description_height = 150
|
||||
transcript_height = 1000
|
||||
show_public_on_dropdown: bool = True
|
||||
message_box_height: int = 400
|
||||
image_description_height: int = 150
|
||||
transcript_height: int = 1000
|
||||
|
||||
# filename of the banner shown at the top
|
||||
banner_file, _ = \
|
||||
|
|
|
|||
|
|
@ -225,7 +225,7 @@ def html_account_info(translate: {},
|
|||
|
||||
info_form += '<div class="accountInfoDomains">\n'
|
||||
users_path = '/users/' + nickname + '/accountinfo'
|
||||
ctr = 1
|
||||
ctr: int = 1
|
||||
for post_domain, blocked_post_urls in domain_dict.items():
|
||||
info_form += '<a href="' + \
|
||||
http_prefix + '://' + post_domain + '" ' + \
|
||||
|
|
|
|||
|
|
@ -274,7 +274,7 @@ def _html_podcast_soundbites(link_url: str, extension: str,
|
|||
podcast_str = '<div class="performers">\n'
|
||||
podcast_str += ' <center>\n'
|
||||
podcast_str += '<ul>\n'
|
||||
ctr = 1
|
||||
ctr: int = 1
|
||||
for performer in podcast_properties['soundbites']:
|
||||
if not performer.get('startTime'):
|
||||
continue
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ def insert_question(base_dir: str, translate: {},
|
|||
content += '<div class="questionresult">\n'
|
||||
|
||||
# get the maximum number of votes
|
||||
max_votes = 1
|
||||
max_votes: int = 1
|
||||
for question_option in post_json_object['object']['oneOf']:
|
||||
if not question_option.get('name'):
|
||||
continue
|
||||
|
|
|
|||
|
|
@ -1392,7 +1392,7 @@ def hashtag_search_rss(nickname: str, domain: str, port: int,
|
|||
|
||||
domain_full = get_full_domain(domain, port)
|
||||
|
||||
max_feed_length = 10
|
||||
max_feed_length: int = 10
|
||||
hashtag_feed = rss2tag_header(hashtag, http_prefix, domain_full)
|
||||
for index, item in enumerate(lines):
|
||||
post_id = item.strip('\n').strip('\r')
|
||||
|
|
|
|||
|
|
@ -412,10 +412,10 @@ def page_number_buttons(users_path: str, box_name: str,
|
|||
page_number: int, header: str) -> str:
|
||||
"""Shows selactable page numbers at the bottom of the screen
|
||||
"""
|
||||
pages_width = 2
|
||||
min_page_number = page_number - pages_width
|
||||
min_page_number = max(min_page_number, 1)
|
||||
max_page_number = min_page_number + 1 + (pages_width * 2)
|
||||
pages_width: int = 2
|
||||
min_page_number: int = page_number - pages_width
|
||||
min_page_number: int = max(min_page_number, 1)
|
||||
max_page_number: int = min_page_number + 1 + (pages_width * 2)
|
||||
num_str: str = ''
|
||||
for page in range(min_page_number, max_page_number):
|
||||
if num_str:
|
||||
|
|
|
|||
Loading…
Reference in New Issue