Snake case

merge-requests/30/head
Bob Mottram 2021-12-27 17:35:58 +00:00
parent 02aa413ab3
commit 218ea067c0
3 changed files with 13 additions and 12 deletions

View File

@ -289,7 +289,7 @@ from utils import remove_id_ending
from utils import undoLikesCollectionEntry from utils import undoLikesCollectionEntry
from utils import deletePost from utils import deletePost
from utils import isBlogPost from utils import isBlogPost
from utils import removeAvatarFromCache from utils import remove_avatar_from_cache
from utils import locate_post from utils import locate_post
from utils import get_cached_post_filename from utils import get_cached_post_filename
from utils import remove_post_from_cache from utils import remove_post_from_cache
@ -6511,7 +6511,7 @@ class PubServer(BaseHTTPRequestHandler):
True) True)
# clear any cached images for this actor # clear any cached images for this actor
idStr = actor_json['id'].replace('/', '-') idStr = actor_json['id'].replace('/', '-')
removeAvatarFromCache(base_dir, idStr) remove_avatar_from_cache(base_dir, idStr)
# save the actor to the cache # save the actor to the cache
actorCacheFilename = \ actorCacheFilename = \
base_dir + '/cache/actors/' + \ base_dir + '/cache/actors/' + \

View File

@ -42,7 +42,7 @@ from utils import get_full_domain
from utils import remove_id_ending from utils import remove_id_ending
from utils import get_protocol_prefixes from utils import get_protocol_prefixes
from utils import isBlogPost from utils import isBlogPost
from utils import removeAvatarFromCache from utils import remove_avatar_from_cache
from utils import isPublicPost from utils import isPublicPost
from utils import get_cached_post_filename from utils import get_cached_post_filename
from utils import remove_post_from_cache from utils import remove_post_from_cache
@ -895,7 +895,7 @@ def _personReceiveUpdate(base_dir: str,
# remove avatar if it exists so that it will be refreshed later # remove avatar if it exists so that it will be refreshed later
# when a timeline is constructed # when a timeline is constructed
actorStr = personJson['id'].replace('/', '-') actorStr = personJson['id'].replace('/', '-')
removeAvatarFromCache(base_dir, actorStr) remove_avatar_from_cache(base_dir, actorStr)
return True return True

View File

@ -634,20 +634,21 @@ def get_link_prefixes() -> []:
'hyper://', 'gemini://', 'gopher://', 'briar:') 'hyper://', 'gemini://', 'gopher://', 'briar:')
def removeAvatarFromCache(base_dir: str, actorStr: str) -> None: def remove_avatar_from_cache(base_dir: str, actorStr: str) -> None:
"""Removes any existing avatar entries from the cache """Removes any existing avatar entries from the cache
This avoids duplicate entries with differing extensions This avoids duplicate entries with differing extensions
""" """
avatarFilenameExtensions = get_image_extensions() avatar_filename_extensions = get_image_extensions()
for extension in avatarFilenameExtensions: for extension in avatar_filename_extensions:
avatarFilename = \ avatar_filename = \
base_dir + '/cache/avatars/' + actorStr + '.' + extension base_dir + '/cache/avatars/' + actorStr + '.' + extension
if os.path.isfile(avatarFilename): if os.path.isfile(avatar_filename):
try: try:
os.remove(avatarFilename) os.remove(avatar_filename)
except OSError: except OSError:
print('EX: removeAvatarFromCache ' + print('EX: remove_avatar_from_cache ' +
'unable to delete cached avatar ' + str(avatarFilename)) 'unable to delete cached avatar ' +
str(avatar_filename))
def save_json(json_object: {}, filename: str) -> bool: def save_json(json_object: {}, filename: str) -> bool: