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