Snake case

main
Bob Mottram 2021-12-27 16:02:54 +00:00
parent 2ab472fad4
commit 7bd8d630e0
2 changed files with 12 additions and 12 deletions

View File

@ -256,7 +256,7 @@ from utils import valid_password
from utils import remove_line_endings
from utils import get_base_content_from_post
from utils import acct_dir
from utils import getImageExtensionFromMimeType
from utils import get_image_extension_from_mime_type
from utils import get_image_mime_type
from utils import has_object_dict
from utils import user_agent_domain
@ -3808,7 +3808,7 @@ class PubServer(BaseHTTPRequestHandler):
mediaFilenameBase = accountsDir + '/upload'
mediaFilename = \
mediaFilenameBase + '.' + \
getImageExtensionFromMimeType(self.headers['Content-type'])
get_image_extension_from_mime_type(self.headers['Content-type'])
try:
with open(mediaFilename, 'wb') as avFile:
avFile.write(mediaBytes)

View File

@ -378,7 +378,7 @@ def get_image_mime_type(image_filename: str) -> str:
return 'image/png'
def getImageExtensionFromMimeType(content_type: str) -> str:
def get_image_extension_from_mime_type(content_type: str) -> str:
"""Returns the image extension from a mime type, such as image/jpeg
"""
image_media = {
@ -390,8 +390,8 @@ def getImageExtensionFromMimeType(content_type: str) -> str:
'avif': 'avif',
'x-icon': 'ico'
}
for mimeExt, ext in image_media.items():
if content_type.endswith(mimeExt):
for mime_ext, ext in image_media.items():
if content_type.endswith(mime_ext):
return ext
return 'png'
@ -407,14 +407,14 @@ def get_image_formats() -> str:
"""Returns a string of permissable image formats
used when selecting an image for a new post
"""
imageExt = get_image_extensions()
image_ext = get_image_extensions()
imageFormats = ''
for ext in imageExt:
if imageFormats:
imageFormats += ', '
imageFormats += '.' + ext
return imageFormats
image_formats = ''
for ext in image_ext:
if image_formats:
image_formats += ', '
image_formats += '.' + ext
return image_formats
def is_image_file(filename: str) -> bool: