[+] File extension parser

This commit is contained in:
Charles Le Maux 2024-09-10 01:05:15 +02:00
parent f74d1cf937
commit a7decf8dac

View File

@ -86,6 +86,22 @@ def log_action(user_id: str, name: str, action: str, details: str = None):
log_error(type(e).__name__, str(e) + " error trying to access history file on not existing server.")
def get_path_from_extension(filename) -> str or None:
allowed_extensions = {
'zip': "world/datapacks",
'jar': "plugins"
}
filename_lower = filename.strip().lower()
if '.' not in filename_lower:
return None
file_extension = filename_lower.split('.')[-1]
if file_extension in allowed_extensions:
return allowed_extensions[file_extension]
else:
return None
def kebab_to_camel_case(s: str) -> str:
parts = s.split('-')
return parts[0] + ''.join(part.title() for part in parts[1:])