{"id":31035956,"url":"https://github.com/fpgmaas/mime-enum","last_synced_at":"2025-09-14T03:57:15.562Z","repository":{"id":313258836,"uuid":"1050709107","full_name":"fpgmaas/mime-enum","owner":"fpgmaas","description":"Type-safe MIME type enumeration for Python","archived":false,"fork":false,"pushed_at":"2025-09-04T20:33:21.000Z","size":781,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-04T22:21:32.163Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fpgmaas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-04T20:17:04.000Z","updated_at":"2025-09-04T20:28:08.000Z","dependencies_parsed_at":"2025-09-04T22:21:34.875Z","dependency_job_id":null,"html_url":"https://github.com/fpgmaas/mime-enum","commit_stats":null,"previous_names":["fpgmaas/mime-enum"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/fpgmaas/mime-enum","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fpgmaas%2Fmime-enum","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fpgmaas%2Fmime-enum/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fpgmaas%2Fmime-enum/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fpgmaas%2Fmime-enum/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fpgmaas","download_url":"https://codeload.github.com/fpgmaas/mime-enum/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fpgmaas%2Fmime-enum/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275058575,"owners_count":25398173,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-14T02:00:10.474Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-09-14T03:57:14.328Z","updated_at":"2025-09-14T03:57:15.548Z","avatar_url":"https://github.com/fpgmaas.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mime-enum\n\n[![Release](https://img.shields.io/github/v/release/fpgmaas/mime-enum)](https://img.shields.io/github/v/release/fpgmaas/mime-enum)\n[![Build status](https://img.shields.io/github/actions/workflow/status/fpgmaas/mime-enum/main.yml?branch=main)](https://github.com/fpgmaas/mime-enum/actions/workflows/main.yml?query=branch%3Amain)\n[![codecov](https://codecov.io/gh/fpgmaas/mime-enum/branch/main/graph/badge.svg)](https://codecov.io/gh/fpgmaas/mime-enum)\n[![License](https://img.shields.io/github/license/fpgmaas/mime-enum)](https://img.shields.io/github/license/fpgmaas/mime-enum)\n\n**A type-safe Python library for working with MIME types and file extensions.**\n\nThe `mime-enum` package provides a comprehensive enumeration of MIME types with their associated file extensions. It offers a clean, type-safe API for parsing MIME type strings, looking up MIME types by file extension, and working with file paths.\n\n\n## Installation\n\nInstall using pip:\n\n```bash\npip install mime-enum\n```\n\nOr using uv:\n\n```bash\nuv add mime-enum\n```\n\n## Quick Start\n\nThe `mime-enum` library provides three key capabilities: type-safe MIME type access, flexible string parsing, and file extension lookups.\n\n### Type-Safe MIME Types\n\nAccess MIME types as strongly-typed enum values with full IDE support:\n\n```python\nfrom mime_enum import MimeType\n\n# Enum values work as strings with autocompletion and type checking\njson_mime = MimeType.APPLICATION_JSON\nprint(json_mime)  # \"application/json\"\nprint(json_mime.extensions)  # (\"json\",)\n\n```\n\n### Convenient Aliases\n\nFor commonly used MIME types with verbose names, convenient aliases are provided:\n\n```python\n# Microsoft Office formats - use short aliases instead of verbose names\ndocx = MimeType.APPLICATION_DOCX  # vs APPLICATION_VND_OPENXMLFORMATS_OFFICEDOCUMENT_WORDPROCESSINGML_DOCUMENT\nxlsx = MimeType.APPLICATION_XLSX  # vs APPLICATION_VND_OPENXMLFORMATS_OFFICEDOCUMENT_SPREADSHEETML_SHEET\npptx = MimeType.APPLICATION_PPTX  # vs APPLICATION_VND_OPENXMLFORMATS_OFFICEDOCUMENT_PRESENTATIONML_PRESENTATION\n\n# String representation shows the full MIME type\nprint(docx)  # \"application/vnd.openxmlformats-officedocument.wordprocessingml.document\"\nprint(xlsx)  # \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\"\nprint(pptx)  # \"application/vnd.openxmlformats-officedocument.presentationml.presentation\"\n\n# All aliases point to the same enum instances\nassert MimeType.APPLICATION_DOCX is MimeType.APPLICATION_VND_OPENXMLFORMATS_OFFICEDOCUMENT_WORDPROCESSINGML_DOCUMENT\n\n# Available aliases: DOCX, XLSX, PPTX, DOTX, XLTX, POTX, PPSX, SLDX\n```\n\n### Flexible String Parsing\n\nParse real-world MIME type strings with automatic parameter stripping and alias normalization:\n\n```python\nfrom mime_enum import parse, try_parse\n\n# Strips parameters automatically\nmime_type = parse(\"application/json; charset=utf-8\")\nprint(mime_type)  # MimeType.APPLICATION_JSON\n\n# Normalizes common aliases to canonical forms\ncanonical = parse(\"text/json\")  # → MimeType.APPLICATION_JSON\ncanonical = parse(\"application/javascript\")  # → MimeType.TEXT_JAVASCRIPT\n\n# Safe parsing returns None instead of raising exceptions\nunknown = try_parse(\"application/unknown\")\nprint(unknown)  # None\n```\n\n### File Extension Lookups\n\nDetect MIME types from file extensions and paths:\n\n```python\nfrom mime_enum import from_extension, from_path\n\n# Look up by extension (with or without dot, case-insensitive)\npdf_mime = from_extension(\".pdf\")  # MimeType.APPLICATION_PDF\njson_mime = from_extension(\"JSON\")  # MimeType.APPLICATION_JSON\n\n# Detect from complete file paths\nmime_type = from_path(\"/path/to/document.pdf\")  # MimeType.APPLICATION_PDF\n```\n\n\u003e **Note:** These functions only examine file extensions, not actual file content. For content-based detection, consider `python-magic` or `filetype` packages.\n\nFor detailed usage examples, see the [Usage Guide](docs/usage.md).\n\nFor complete API documentation, see the [API Reference](docs/api.md).\n\n## Acknowledgments\n\nThis project uses the `mimeData.json` file from [mimetype-io](https://github.com/patrickmccallum/mimetype-io) by Patrick McCallum.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffpgmaas%2Fmime-enum","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffpgmaas%2Fmime-enum","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffpgmaas%2Fmime-enum/lists"}