mirror of https://gitlab.com/bashrc2/epicyon
Case insensitive avatar image search
parent
82312175a8
commit
a9206ee855
11
utils.py
11
utils.py
|
@ -769,3 +769,14 @@ def searchBoxPosts(baseDir: str, nickname: str, domain: str,
|
||||||
if len(res) >= maxResults:
|
if len(res) >= maxResults:
|
||||||
return res
|
return res
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|
||||||
|
def getFileCaseInsensitive(filename: str) -> str:
|
||||||
|
"""Returns a case specific filename given a case insensitive version of it
|
||||||
|
"""
|
||||||
|
directory, filename = os.path.split(filename)
|
||||||
|
directory, filename = (directory or '.'), filename.lower()
|
||||||
|
for f in os.listdir(directory):
|
||||||
|
newFilename = os.path.join(directory, f)
|
||||||
|
if os.path.isfile(newFilename) and f.lower() == filename:
|
||||||
|
return newFilename
|
||||||
|
|
|
@ -24,6 +24,7 @@ from ssb import getSSBAddress
|
||||||
from tox import getToxAddress
|
from tox import getToxAddress
|
||||||
from matrix import getMatrixAddress
|
from matrix import getMatrixAddress
|
||||||
from donate import getDonationUrl
|
from donate import getDonationUrl
|
||||||
|
from utils import getFileCaseInsensitive
|
||||||
from utils import searchBoxPosts
|
from utils import searchBoxPosts
|
||||||
from utils import isBlogPost
|
from utils import isBlogPost
|
||||||
from utils import updateRecentPostsCache
|
from utils import updateRecentPostsCache
|
||||||
|
@ -254,7 +255,8 @@ def getPersonAvatarUrl(baseDir: str, personUrl: str, personCache: {}) -> str:
|
||||||
return None
|
return None
|
||||||
# get from locally stored image
|
# get from locally stored image
|
||||||
actorStr = personJson['id'].replace('/', '-')
|
actorStr = personJson['id'].replace('/', '-')
|
||||||
avatarImagePath = baseDir + '/cache/avatars/' + actorStr
|
avatarImagePath = \
|
||||||
|
getFileCaseInsensitive(baseDir + '/cache/avatars/' + actorStr
|
||||||
if os.path.isfile(avatarImagePath + '.png'):
|
if os.path.isfile(avatarImagePath + '.png'):
|
||||||
return '/avatars/' + actorStr + '.png'
|
return '/avatars/' + actorStr + '.png'
|
||||||
elif os.path.isfile(avatarImagePath + '.jpg'):
|
elif os.path.isfile(avatarImagePath + '.jpg'):
|
||||||
|
|
Loading…
Reference in New Issue