Snake case

merge-requests/30/head
Bob Mottram 2021-12-27 15:58:46 +00:00
parent e9a569b44f
commit 2ab472fad4
4 changed files with 20 additions and 20 deletions

View File

@ -302,7 +302,7 @@ from utils import save_json
from utils import is_suspended from utils import is_suspended
from utils import dangerousMarkup from utils import dangerousMarkup
from utils import refresh_newswire from utils import refresh_newswire
from utils import isImageFile from utils import is_image_file
from utils import has_group_type from utils import has_group_type
from manualapprove import manualDenyFollowRequestThread from manualapprove import manualDenyFollowRequestThread
from manualapprove import manualApproveFollowRequestThread from manualapprove import manualApproveFollowRequestThread
@ -7208,7 +7208,7 @@ class PubServer(BaseHTTPRequestHandler):
GETstartTime) -> None: GETstartTime) -> None:
"""Returns a media file """Returns a media file
""" """
if isImageFile(path) or \ if is_image_file(path) or \
pathIsVideo(path) or \ pathIsVideo(path) or \
pathIsAudio(path): pathIsAudio(path):
mediaStr = path.split('/media/')[1] mediaStr = path.split('/media/')[1]
@ -7294,7 +7294,7 @@ class PubServer(BaseHTTPRequestHandler):
base_dir: str, GETstartTime) -> None: base_dir: str, GETstartTime) -> None:
"""Returns an emoji image """Returns an emoji image
""" """
if isImageFile(path): if is_image_file(path):
emojiStr = path.split('/emoji/')[1] emojiStr = path.split('/emoji/')[1]
emojiFilename = base_dir + '/emoji/' + emojiStr emojiFilename = base_dir + '/emoji/' + emojiStr
if not os.path.isfile(emojiFilename): if not os.path.isfile(emojiFilename):
@ -7385,7 +7385,7 @@ class PubServer(BaseHTTPRequestHandler):
base_dir: str, GETstartTime) -> None: base_dir: str, GETstartTime) -> None:
"""Shows a help screen image """Shows a help screen image
""" """
if not isImageFile(path): if not is_image_file(path):
return return
mediaStr = path.split('/helpimages/')[1] mediaStr = path.split('/helpimages/')[1]
if '/' not in mediaStr: if '/' not in mediaStr:
@ -12745,7 +12745,7 @@ class PubServer(BaseHTTPRequestHandler):
base_dir: str, GETstartTime) -> bool: base_dir: str, GETstartTime) -> bool:
"""Show a shared item image """Show a shared item image
""" """
if not isImageFile(path): if not is_image_file(path):
self._404() self._404()
return True return True
@ -12791,7 +12791,7 @@ class PubServer(BaseHTTPRequestHandler):
'/accounts/avatars/' not in path and \ '/accounts/avatars/' not in path and \
'/accounts/headers/' not in path: '/accounts/headers/' not in path:
return False return False
if not isImageFile(path): if not is_image_file(path):
return False return False
if '/system/accounts/avatars/' in path: if '/system/accounts/avatars/' in path:
avatarStr = path.split('/system/accounts/avatars/')[1] avatarStr = path.split('/system/accounts/avatars/')[1]
@ -14576,7 +14576,7 @@ class PubServer(BaseHTTPRequestHandler):
# if not authorized then show the login screen # if not authorized then show the login screen
if htmlGET and self.path != '/login' and \ if htmlGET and self.path != '/login' and \
not isImageFile(self.path) and \ not is_image_file(self.path) and \
self.path != '/' and \ self.path != '/' and \
self.path != '/users/news/linksmobile' and \ self.path != '/users/news/linksmobile' and \
self.path != '/users/news/newswiremobile': self.path != '/users/news/newswiremobile':
@ -14686,7 +14686,7 @@ class PubServer(BaseHTTPRequestHandler):
self.server.debug) self.server.debug)
# image on login screen or qrcode # image on login screen or qrcode
if (isImageFile(self.path) and if (is_image_file(self.path) and
(self.path.startswith('/login.') or (self.path.startswith('/login.') or
self.path.startswith('/qrcode.png'))): self.path.startswith('/qrcode.png'))):
iconFilename = \ iconFilename = \
@ -16397,7 +16397,7 @@ class PubServer(BaseHTTPRequestHandler):
fileLength = -1 fileLength = -1
if '/media/' in self.path: if '/media/' in self.path:
if isImageFile(self.path) or \ if is_image_file(self.path) or \
pathIsVideo(self.path) or \ pathIsVideo(self.path) or \
pathIsAudio(self.path): pathIsAudio(self.path):
mediaStr = self.path.split('/media/')[1] mediaStr = self.path.split('/media/')[1]
@ -16506,7 +16506,7 @@ class PubServer(BaseHTTPRequestHandler):
print('DEBUG: no media filename in POST') print('DEBUG: no media filename in POST')
if filename: if filename:
if isImageFile(filename): if is_image_file(filename):
postImageFilename = filename.replace('.temp', '') postImageFilename = filename.replace('.temp', '')
print('Removing metadata from ' + postImageFilename) print('Removing metadata from ' + postImageFilename)
city = getSpoofedCity(self.server.city, city = getSpoofedCity(self.server.city,

View File

@ -54,7 +54,7 @@ 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 get_image_extensions from utils import get_image_extensions
from utils import isImageFile from utils import is_image_file
from utils import acct_dir from utils import acct_dir
from utils import get_user_paths from utils import get_user_paths
from utils import get_group_paths from utils import get_group_paths
@ -100,7 +100,7 @@ def setProfileImage(base_dir: str, http_prefix: str,
image for the given person image for the given person
""" """
image_filename = image_filename.replace('\n', '').replace('\r', '') image_filename = image_filename.replace('\n', '').replace('\r', '')
if not isImageFile(image_filename): if not is_image_file(image_filename):
print('Profile image must be png, jpg, gif or svg format') print('Profile image must be png, jpg, gif or svg format')
return False return False

View File

@ -10,7 +10,7 @@ __module_group__ = "Session"
import os import os
import requests import requests
from utils import urlPermitted from utils import urlPermitted
from utils import isImageFile from utils import is_image_file
from httpsig import createSignedHeader from httpsig import createSignedHeader
import json import json
from socket import error as SocketError from socket import error as SocketError
@ -398,7 +398,7 @@ def postImage(session, attachImageFilename: str, federation_list: [],
print('postJson: ' + inboxUrl + ' not permitted') print('postJson: ' + inboxUrl + ' not permitted')
return None return None
if not isImageFile(attachImageFilename): if not is_image_file(attachImageFilename):
print('Image must be png, jpg, webp, avif, gif or svg') print('Image must be png, jpg, webp, avif, gif or svg')
return None return None
if not os.path.isfile(attachImageFilename): if not os.path.isfile(attachImageFilename):

View File

@ -417,7 +417,7 @@ def get_image_formats() -> str:
return imageFormats return imageFormats
def isImageFile(filename: str) -> bool: def is_image_file(filename: str) -> bool:
"""Is the given filename an image? """Is the given filename an image?
""" """
for ext in get_image_extensions(): for ext in get_image_extensions():
@ -432,12 +432,12 @@ def get_media_formats() -> str:
""" """
media_ext = get_media_extensions() media_ext = get_media_extensions()
mediaFormats = '' media_formats = ''
for ext in media_ext: for ext in media_ext:
if mediaFormats: if media_formats:
mediaFormats += ', ' media_formats += ', '
mediaFormats += '.' + ext media_formats += '.' + ext
return mediaFormats return media_formats
def remove_html(content: str) -> str: def remove_html(content: str) -> str: