mirror of https://gitlab.com/bashrc2/epicyon
Snake case
parent
24118d0e7f
commit
dac2324ba9
|
@ -14,7 +14,7 @@ from shutil import copyfile
|
|||
from utils import dangerousSVG
|
||||
from utils import removeDomainPort
|
||||
from utils import isValidLanguage
|
||||
from utils import getImageExtensions
|
||||
from utils import get_image_extensions
|
||||
from utils import loadJson
|
||||
from utils import saveJson
|
||||
from utils import fileLastModified
|
||||
|
@ -1024,7 +1024,7 @@ def saveMediaInFormPOST(mediaBytes, debug: bool,
|
|||
if not mediaBytes:
|
||||
if filenameBase:
|
||||
# remove any existing files
|
||||
extensionTypes = getImageExtensions()
|
||||
extensionTypes = get_image_extensions()
|
||||
for ex in extensionTypes:
|
||||
possibleOtherFormat = filenameBase + '.' + ex
|
||||
if os.path.isfile(possibleOtherFormat):
|
||||
|
@ -1099,7 +1099,7 @@ def saveMediaInFormPOST(mediaBytes, debug: bool,
|
|||
|
||||
# remove any existing image files with a different format
|
||||
if detectedExtension != 'zip':
|
||||
extensionTypes = getImageExtensions()
|
||||
extensionTypes = get_image_extensions()
|
||||
for ex in extensionTypes:
|
||||
if ex == detectedExtension:
|
||||
continue
|
||||
|
|
|
@ -276,7 +276,7 @@ from utils import get_full_domain
|
|||
from utils import removeHtml
|
||||
from utils import is_editor
|
||||
from utils import is_artist
|
||||
from utils import getImageExtensions
|
||||
from utils import get_image_extensions
|
||||
from utils import mediaFileMimeType
|
||||
from utils import getCSS
|
||||
from utils import firstParagraphFromString
|
||||
|
@ -12647,7 +12647,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
base_dir: str, GETstartTime) -> bool:
|
||||
"""Show a background image
|
||||
"""
|
||||
imageExtensions = getImageExtensions()
|
||||
imageExtensions = get_image_extensions()
|
||||
for ext in imageExtensions:
|
||||
for bg in ('follow', 'options', 'login', 'welcome'):
|
||||
# follow screen background image
|
||||
|
@ -12696,7 +12696,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
"""If a background image is missing after searching for a handle
|
||||
then substitute this image
|
||||
"""
|
||||
imageExtensions = getImageExtensions()
|
||||
imageExtensions = get_image_extensions()
|
||||
for ext in imageExtensions:
|
||||
bgFilename = \
|
||||
base_dir + '/theme/' + theme_name + '/image.' + ext
|
||||
|
@ -12823,7 +12823,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
if not os.path.isfile(avatarFilename):
|
||||
originalExt = avatarFileExt
|
||||
originalAvatarFile = avatarFile
|
||||
altExt = getImageExtensions()
|
||||
altExt = get_image_extensions()
|
||||
altFound = False
|
||||
for alt in altExt:
|
||||
if alt == originalExt:
|
||||
|
|
4
media.py
4
media.py
|
@ -17,7 +17,7 @@ from hashlib import sha1
|
|||
from auth import createPassword
|
||||
from utils import get_base_content_from_post
|
||||
from utils import get_full_domain
|
||||
from utils import getImageExtensions
|
||||
from utils import get_image_extensions
|
||||
from utils import get_video_extensions
|
||||
from utils import get_audio_extensions
|
||||
from utils import getMediaExtensions
|
||||
|
@ -246,7 +246,7 @@ def getAttachmentMediaType(filename: str) -> str:
|
|||
image, video or audio
|
||||
"""
|
||||
mediaType = None
|
||||
imageTypes = getImageExtensions()
|
||||
imageTypes = get_image_extensions()
|
||||
for mType in imageTypes:
|
||||
if filename.endswith('.' + mType):
|
||||
return 'image'
|
||||
|
|
|
@ -53,7 +53,7 @@ from utils import get_config_param
|
|||
from utils import refresh_newswire
|
||||
from utils import getProtocolPrefixes
|
||||
from utils import has_users_path
|
||||
from utils import getImageExtensions
|
||||
from utils import get_image_extensions
|
||||
from utils import isImageFile
|
||||
from utils import acct_dir
|
||||
from utils import get_user_paths
|
||||
|
@ -1619,7 +1619,7 @@ def getPersonAvatarUrl(base_dir: str, personUrl: str, person_cache: {},
|
|||
actorStr = personJson['id'].replace('/', '-')
|
||||
avatarImagePath = base_dir + '/cache/avatars/' + actorStr
|
||||
|
||||
imageExtension = getImageExtensions()
|
||||
imageExtension = get_image_extensions()
|
||||
for ext in imageExtension:
|
||||
imFilename = avatarImagePath + '.' + ext
|
||||
imPath = '/avatars/' + actorStr + '.' + ext
|
||||
|
|
10
shares.py
10
shares.py
|
@ -30,7 +30,7 @@ from utils import get_full_domain
|
|||
from utils import validNickname
|
||||
from utils import loadJson
|
||||
from utils import saveJson
|
||||
from utils import getImageExtensions
|
||||
from utils import get_image_extensions
|
||||
from utils import removeDomainPort
|
||||
from utils import isAccountDir
|
||||
from utils import acct_dir
|
||||
|
@ -142,7 +142,7 @@ def removeSharedItem(base_dir: str, nickname: str, domain: str,
|
|||
# remove any image for the item
|
||||
itemIDfile = base_dir + '/sharefiles/' + nickname + '/' + itemID
|
||||
if sharesJson[itemID]['imageUrl']:
|
||||
formats = getImageExtensions()
|
||||
formats = get_image_extensions()
|
||||
for ext in formats:
|
||||
if sharesJson[itemID]['imageUrl'].endswith('.' + ext):
|
||||
if os.path.isfile(itemIDfile + '.' + ext):
|
||||
|
@ -339,7 +339,7 @@ def addShare(base_dir: str,
|
|||
if not imageFilename:
|
||||
sharesImageFilename = \
|
||||
acct_dir(base_dir, nickname, domain) + '/upload'
|
||||
formats = getImageExtensions()
|
||||
formats = get_image_extensions()
|
||||
for ext in formats:
|
||||
if os.path.isfile(sharesImageFilename + '.' + ext):
|
||||
imageFilename = sharesImageFilename + '.' + ext
|
||||
|
@ -355,7 +355,7 @@ def addShare(base_dir: str,
|
|||
if not os.path.isdir(base_dir + '/sharefiles/' + nickname):
|
||||
os.mkdir(base_dir + '/sharefiles/' + nickname)
|
||||
itemIDfile = base_dir + '/sharefiles/' + nickname + '/' + itemID
|
||||
formats = getImageExtensions()
|
||||
formats = get_image_extensions()
|
||||
for ext in formats:
|
||||
if not imageFilename.endswith('.' + ext):
|
||||
continue
|
||||
|
@ -435,7 +435,7 @@ def _expireSharesForAccount(base_dir: str, nickname: str, domain: str,
|
|||
del sharesJson[itemID]
|
||||
# remove any associated images
|
||||
itemIDfile = base_dir + '/sharefiles/' + nickname + '/' + itemID
|
||||
formats = getImageExtensions()
|
||||
formats = get_image_extensions()
|
||||
for ext in formats:
|
||||
if os.path.isfile(itemIDfile + '.' + ext):
|
||||
try:
|
||||
|
|
4
theme.py
4
theme.py
|
@ -11,7 +11,7 @@ import os
|
|||
from utils import isAccountDir
|
||||
from utils import loadJson
|
||||
from utils import saveJson
|
||||
from utils import getImageExtensions
|
||||
from utils import get_image_extensions
|
||||
from utils import copytree
|
||||
from utils import acct_dir
|
||||
from utils import dangerousSVG
|
||||
|
@ -679,7 +679,7 @@ def _setThemeImages(base_dir: str, name: str) -> None:
|
|||
backgroundNames = ('login', 'shares', 'delete', 'follow',
|
||||
'options', 'block', 'search', 'calendar',
|
||||
'welcome')
|
||||
extensions = getImageExtensions()
|
||||
extensions = get_image_extensions()
|
||||
|
||||
for subdir, dirs, files in os.walk(base_dir + '/accounts'):
|
||||
for acct in dirs:
|
||||
|
|
10
utils.py
10
utils.py
|
@ -354,7 +354,7 @@ def get_audio_extensions() -> []:
|
|||
return ('mp3', 'ogg', 'flac')
|
||||
|
||||
|
||||
def getImageExtensions() -> []:
|
||||
def get_image_extensions() -> []:
|
||||
"""Returns a list of the possible image file extensions
|
||||
"""
|
||||
return ('png', 'jpg', 'jpeg', 'gif', 'webp', 'avif', 'svg', 'ico')
|
||||
|
@ -399,7 +399,7 @@ def getImageExtensionFromMimeType(contentType: str) -> str:
|
|||
def getMediaExtensions() -> []:
|
||||
"""Returns a list of the possible media file extensions
|
||||
"""
|
||||
return getImageExtensions() + \
|
||||
return get_image_extensions() + \
|
||||
get_video_extensions() + get_audio_extensions()
|
||||
|
||||
|
||||
|
@ -407,7 +407,7 @@ def getImageFormats() -> str:
|
|||
"""Returns a string of permissable image formats
|
||||
used when selecting an image for a new post
|
||||
"""
|
||||
imageExt = getImageExtensions()
|
||||
imageExt = get_image_extensions()
|
||||
|
||||
imageFormats = ''
|
||||
for ext in imageExt:
|
||||
|
@ -420,7 +420,7 @@ def getImageFormats() -> str:
|
|||
def isImageFile(filename: str) -> bool:
|
||||
"""Is the given filename an image?
|
||||
"""
|
||||
for ext in getImageExtensions():
|
||||
for ext in get_image_extensions():
|
||||
if filename.endswith('.' + ext):
|
||||
return True
|
||||
return False
|
||||
|
@ -642,7 +642,7 @@ def removeAvatarFromCache(base_dir: str, actorStr: str) -> None:
|
|||
"""Removes any existing avatar entries from the cache
|
||||
This avoids duplicate entries with differing extensions
|
||||
"""
|
||||
avatarFilenameExtensions = getImageExtensions()
|
||||
avatarFilenameExtensions = get_image_extensions()
|
||||
for extension in avatarFilenameExtensions:
|
||||
avatarFilename = \
|
||||
base_dir + '/cache/avatars/' + actorStr + '.' + extension
|
||||
|
|
|
@ -22,7 +22,7 @@ from utils import getNicknameFromActor
|
|||
from utils import isfloat
|
||||
from utils import get_audio_extensions
|
||||
from utils import get_video_extensions
|
||||
from utils import getImageExtensions
|
||||
from utils import get_image_extensions
|
||||
from utils import local_actor_url
|
||||
from cache import storePersonInCache
|
||||
from content import addHtmlTags
|
||||
|
@ -471,7 +471,7 @@ def _getImageFile(base_dir: str, name: str, directory: str,
|
|||
"""
|
||||
returns the filenames for an image with the given name
|
||||
"""
|
||||
bannerExtensions = getImageExtensions()
|
||||
bannerExtensions = get_image_extensions()
|
||||
bannerFile = ''
|
||||
bannerFilename = ''
|
||||
for ext in bannerExtensions:
|
||||
|
@ -943,7 +943,7 @@ def _isImageMimeType(mimeType: str) -> bool:
|
|||
return True
|
||||
if not mimeType.startswith('image/'):
|
||||
return False
|
||||
extensions = getImageExtensions()
|
||||
extensions = get_image_extensions()
|
||||
ext = mimeType.split('/')[1]
|
||||
if ext in extensions:
|
||||
return True
|
||||
|
|
|
@ -12,7 +12,7 @@ from shutil import copyfile
|
|||
from utils import removeHtml
|
||||
from utils import loadJson
|
||||
from utils import get_config_param
|
||||
from utils import getImageExtensions
|
||||
from utils import get_image_extensions
|
||||
from utils import getImageFormats
|
||||
from utils import acct_dir
|
||||
from utils import local_actor_url
|
||||
|
@ -70,7 +70,7 @@ def htmlWelcomeProfile(base_dir: str, nickname: str, domain: str,
|
|||
profileForm = htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None)
|
||||
|
||||
# get the url of the avatar
|
||||
for ext in getImageExtensions():
|
||||
for ext in get_image_extensions():
|
||||
avatarFilename = \
|
||||
acct_dir(base_dir, nickname, domain) + '/avatar.' + ext
|
||||
if os.path.isfile(avatarFilename):
|
||||
|
|
Loading…
Reference in New Issue