"""Helper for file-related functions.""" from os import path class FileHelper: """File Helper utility class.""" @staticmethod def _get_extension(file_path: str) -> str: """Get file extension from file.""" return path.splitext(file_path)[1] @staticmethod def _file_info() -> dict[str, dict[str, str]]: """Return a dictionary mapping extension to Content Type.""" return { "wav": {"content_type": "audio/wav"}, "flac": {"content_type": "audio/flac"}, } @staticmethod def get_file_data_from_asset(asset_file: str) -> dict[str, str]: """Return file extension, content type from an asset.""" file_ext = FileHelper._get_extension(asset_file)[1:] content_type = FileHelper._file_info()[file_ext]["content_type"] return {"file_ext": file_ext, "content_type": content_type}