diff --git a/file_manager.py b/file_manager.py index 71931aa..f31af0c 100644 --- a/file_manager.py +++ b/file_manager.py @@ -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:])