mirror of
https://github.com/hubHarmony/servii-backend.git
synced 2024-11-17 21:40:31 +00:00
[+] File extension parser
This commit is contained in:
parent
f74d1cf937
commit
a7decf8dac
@ -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.")
|
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:
|
def kebab_to_camel_case(s: str) -> str:
|
||||||
parts = s.split('-')
|
parts = s.split('-')
|
||||||
return parts[0] + ''.join(part.title() for part in parts[1:])
|
return parts[0] + ''.join(part.title() for part in parts[1:])
|
||||||
|
Loading…
Reference in New Issue
Block a user