mirror of https://gitlab.com/bashrc2/epicyon
Tidying
parent
72df995204
commit
f0b9757bde
2
blog.py
2
blog.py
|
@ -272,7 +272,7 @@ def _html_blog_post_content(debug: bool, session, authorized: bool,
|
||||||
|
|
||||||
person_url = local_actor_url(http_prefix, nickname, domain_full)
|
person_url = local_actor_url(http_prefix, nickname, domain_full)
|
||||||
actor_json = \
|
actor_json = \
|
||||||
get_person_from_cache(base_dir, person_url, person_cache, False)
|
get_person_from_cache(base_dir, person_url, person_cache)
|
||||||
languages_understood = []
|
languages_understood = []
|
||||||
if actor_json:
|
if actor_json:
|
||||||
languages_understood = get_actor_languages_list(actor_json)
|
languages_understood = get_actor_languages_list(actor_json)
|
||||||
|
|
|
@ -34,7 +34,6 @@ from session import post_json
|
||||||
|
|
||||||
def undo_bookmarks_collection_entry(recent_posts_cache: {},
|
def undo_bookmarks_collection_entry(recent_posts_cache: {},
|
||||||
base_dir: str, post_filename: str,
|
base_dir: str, post_filename: str,
|
||||||
object_url: str,
|
|
||||||
actor: str, domain: str,
|
actor: str, domain: str,
|
||||||
debug: bool) -> None:
|
debug: bool) -> None:
|
||||||
"""Undoes a bookmark for a particular actor
|
"""Undoes a bookmark for a particular actor
|
||||||
|
@ -366,7 +365,7 @@ def undo_bookmark_post(recent_posts_cache: {},
|
||||||
return None
|
return None
|
||||||
|
|
||||||
undo_bookmarks_collection_entry(recent_posts_cache,
|
undo_bookmarks_collection_entry(recent_posts_cache,
|
||||||
base_dir, post_filename, object_url,
|
base_dir, post_filename,
|
||||||
new_undo_bookmark_json['actor'],
|
new_undo_bookmark_json['actor'],
|
||||||
domain, debug)
|
domain, debug)
|
||||||
else:
|
else:
|
||||||
|
|
6
cache.py
6
cache.py
|
@ -77,8 +77,8 @@ def store_person_in_cache(base_dir: str, person_url: str,
|
||||||
save_json(person_json, cache_filename)
|
save_json(person_json, cache_filename)
|
||||||
|
|
||||||
|
|
||||||
def get_person_from_cache(base_dir: str, person_url: str, person_cache: {},
|
def get_person_from_cache(base_dir: str, person_url: str,
|
||||||
allow_write_to_file: bool) -> {}:
|
person_cache: {}) -> {}:
|
||||||
"""Get an actor from the cache
|
"""Get an actor from the cache
|
||||||
"""
|
"""
|
||||||
# if the actor is not in memory then try to load it from file
|
# if the actor is not in memory then try to load it from file
|
||||||
|
@ -157,7 +157,7 @@ def get_person_pub_key(base_dir: str, session, person_url: str,
|
||||||
person_url.replace(possible_users_path + 'inbox', '/inbox')
|
person_url.replace(possible_users_path + 'inbox', '/inbox')
|
||||||
break
|
break
|
||||||
person_json = \
|
person_json = \
|
||||||
get_person_from_cache(base_dir, person_url, person_cache, True)
|
get_person_from_cache(base_dir, person_url, person_cache)
|
||||||
if not person_json:
|
if not person_json:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: Obtaining public key for ' + person_url)
|
print('DEBUG: Obtaining public key for ' + person_url)
|
||||||
|
|
|
@ -7935,8 +7935,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
actor_json = \
|
actor_json = \
|
||||||
get_person_from_cache(base_dir,
|
get_person_from_cache(base_dir,
|
||||||
options_actor,
|
options_actor,
|
||||||
self.server.person_cache,
|
self.server.person_cache)
|
||||||
True)
|
|
||||||
if actor_json:
|
if actor_json:
|
||||||
if actor_json.get('movedTo'):
|
if actor_json.get('movedTo'):
|
||||||
moved_to = actor_json['movedTo']
|
moved_to = actor_json['movedTo']
|
||||||
|
|
1
inbox.py
1
inbox.py
|
@ -2058,7 +2058,6 @@ def _receive_undo_bookmark(recent_posts_cache: {},
|
||||||
|
|
||||||
undo_bookmarks_collection_entry(recent_posts_cache, base_dir,
|
undo_bookmarks_collection_entry(recent_posts_cache, base_dir,
|
||||||
post_filename,
|
post_filename,
|
||||||
message_json['object']['url'],
|
|
||||||
message_json['actor'], domain, debug)
|
message_json['actor'], domain, debug)
|
||||||
# regenerate the html
|
# regenerate the html
|
||||||
bookmarked_post_json = load_json(post_filename, 0, 1)
|
bookmarked_post_json = load_json(post_filename, 0, 1)
|
||||||
|
|
|
@ -39,7 +39,7 @@ def get_understood_languages(base_dir: str, http_prefix: str,
|
||||||
"""
|
"""
|
||||||
person_url = local_actor_url(http_prefix, nickname, domain_full)
|
person_url = local_actor_url(http_prefix, nickname, domain_full)
|
||||||
actor_json = \
|
actor_json = \
|
||||||
get_person_from_cache(base_dir, person_url, person_cache, False)
|
get_person_from_cache(base_dir, person_url, person_cache)
|
||||||
if not actor_json:
|
if not actor_json:
|
||||||
print('WARN: unable to load actor to obtain languages ' + person_url)
|
print('WARN: unable to load actor to obtain languages ' + person_url)
|
||||||
return []
|
return []
|
||||||
|
@ -117,7 +117,7 @@ def understood_post_language(base_dir: str, nickname: str, domain: str,
|
||||||
return True
|
return True
|
||||||
person_url = local_actor_url(http_prefix, nickname, domain_full)
|
person_url = local_actor_url(http_prefix, nickname, domain_full)
|
||||||
actor_json = \
|
actor_json = \
|
||||||
get_person_from_cache(base_dir, person_url, person_cache, False)
|
get_person_from_cache(base_dir, person_url, person_cache)
|
||||||
if not actor_json:
|
if not actor_json:
|
||||||
print('WARN: unable to load actor to check languages ' + person_url)
|
print('WARN: unable to load actor to check languages ' + person_url)
|
||||||
return False
|
return False
|
||||||
|
|
|
@ -1686,8 +1686,7 @@ def get_person_avatar_url(base_dir: str, person_url: str, person_cache: {},
|
||||||
"""Returns the avatar url for the person
|
"""Returns the avatar url for the person
|
||||||
"""
|
"""
|
||||||
person_json = \
|
person_json = \
|
||||||
get_person_from_cache(base_dir, person_url, person_cache,
|
get_person_from_cache(base_dir, person_url, person_cache)
|
||||||
allow_downloads)
|
|
||||||
if not person_json:
|
if not person_json:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
2
posts.py
2
posts.py
|
@ -313,7 +313,7 @@ def _get_person_box_actor(session, base_dir: str, actor: str,
|
||||||
"""Returns the actor json for the given actor url
|
"""Returns the actor json for the given actor url
|
||||||
"""
|
"""
|
||||||
person_json = \
|
person_json = \
|
||||||
get_person_from_cache(base_dir, actor, person_cache, True)
|
get_person_from_cache(base_dir, actor, person_cache)
|
||||||
if person_json:
|
if person_json:
|
||||||
return person_json
|
return person_json
|
||||||
|
|
||||||
|
|
2
tests.py
2
tests.py
|
@ -679,7 +679,7 @@ def _test_cache():
|
||||||
}
|
}
|
||||||
person_cache = {}
|
person_cache = {}
|
||||||
store_person_in_cache(None, person_url, person_json, person_cache, True)
|
store_person_in_cache(None, person_url, person_json, person_cache, True)
|
||||||
result = get_person_from_cache(None, person_url, person_cache, True)
|
result = get_person_from_cache(None, person_url, person_cache)
|
||||||
assert result['id'] == 123456
|
assert result['id'] == 123456
|
||||||
assert result['test'] == 'This is a test'
|
assert result['test'] == 'This is a test'
|
||||||
|
|
||||||
|
|
|
@ -1116,8 +1116,7 @@ def _get_post_title_announce_html(base_dir: str,
|
||||||
container_class_icons, container_class)
|
container_class_icons, container_class)
|
||||||
|
|
||||||
announce_domain, _ = get_domain_from_actor(attributed_to)
|
announce_domain, _ = get_domain_from_actor(attributed_to)
|
||||||
get_person_from_cache(base_dir, attributed_to,
|
get_person_from_cache(base_dir, attributed_to, person_cache)
|
||||||
person_cache, allow_downloads)
|
|
||||||
announce_display_name = \
|
announce_display_name = \
|
||||||
get_display_name(base_dir, attributed_to, person_cache)
|
get_display_name(base_dir, attributed_to, person_cache)
|
||||||
if announce_display_name:
|
if announce_display_name:
|
||||||
|
@ -1325,7 +1324,7 @@ def _get_post_title_reply_html(base_dir: str,
|
||||||
return (title_str, reply_avatar_image_in_post,
|
return (title_str, reply_avatar_image_in_post,
|
||||||
container_class_icons, container_class)
|
container_class_icons, container_class)
|
||||||
|
|
||||||
get_person_from_cache(base_dir, reply_actor, person_cache, allow_downloads)
|
get_person_from_cache(base_dir, reply_actor, person_cache)
|
||||||
reply_display_name = \
|
reply_display_name = \
|
||||||
get_display_name(base_dir, reply_actor, person_cache)
|
get_display_name(base_dir, reply_actor, person_cache)
|
||||||
if reply_display_name:
|
if reply_display_name:
|
||||||
|
@ -2121,7 +2120,7 @@ def individual_post_as_html(signing_priv_key_pem: str,
|
||||||
domain_full = get_full_domain(domain, port)
|
domain_full = get_full_domain(domain, port)
|
||||||
person_url = local_actor_url(http_prefix, nickname, domain_full)
|
person_url = local_actor_url(http_prefix, nickname, domain_full)
|
||||||
actor_json = \
|
actor_json = \
|
||||||
get_person_from_cache(base_dir, person_url, person_cache, False)
|
get_person_from_cache(base_dir, person_url, person_cache)
|
||||||
languages_understood = []
|
languages_understood = []
|
||||||
if actor_json:
|
if actor_json:
|
||||||
languages_understood = get_actor_languages_list(actor_json)
|
languages_understood = get_actor_languages_list(actor_json)
|
||||||
|
|
Loading…
Reference in New Issue