Python file extension to ContentType conversion for mime types for over 4000 file extensions.

Overview

MIME List

Discover the content type for your media type

>>> from mime_list import mediatypes
>>> mediatypes.get('png')
'image/png'


>>> from mime_list import mediatypes
>>> mediatypes.get('png')
'image/png'

If the extension is unknown the package will raise a UnknownMediaType

>>> mediatypes.get('x-ng')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/package/mime_list/mediatypes.py", line 32, in get
    raise UnknownMediaType(ext)
mime_list.mediatypes.UnknownMediaType: x-ng

Provide a default to squash the error

>>> mediatypes.get('x-ng', None)
>>> mediatypes.get('x-ng', "plain/text")
"plain/text"

The filter function can find multiple types for a query:

>>> mediatypes.filter('png')
('image/png', 'image/x-png', 'image/x-citrix-png')

>>> mediatypes.filter('x-png')
('image/png',)

Defaults are not required for the iterable response. Empty results return an empty tuple:

>>> mediatypes.filter('x-ng')
()

Some examples:

>>> mediatypes.get('jpg')
'image/jpeg'
>>> mediatypes.get('jpeg')
'image/jpeg'
>>> mediatypes.get('png')
'image/png'
>>> mediatypes.get('gif')
'image/gif'
>>> mediatypes.get('mp3')
'audio/mpeg'
>>> mediatypes.get('wav')
'audio/x-wav'
>>> mediatypes.get('pdf')
'application/pdf'
>>> mediatypes.get('html')
'text/html'
>>> mediatypes.get('txt')
'text/plain'
>>> mediatypes.get('yaml')
'text/yaml'
>>> mediatypes.get('json')
'application/json'
>>> mediatypes.get('js')
'application/javascript'

A comprehesive list of all the content types I've generally found, to provide 'mime' extension types for file suffix's

You might also like...

Experimental utilities, extensions, and frontend interfaces for the diffusers library (stable-diffusion)

g-diffuser-lib - Experimental utilities, extensions, and frontend interfaces for the diffusers library (stable-diffusion) Step 27/2022 Update - Just t

Sep 28, 2022

FHIRPACK (FHIR Python Analysis Conversion Kit) is a general purpose library that simplifies the access, analysis and representation of FHIR and EHR data

FHIRPACK (FHIR Python Analysis Conversion Kit) is a general purpose library that simplifies the access, analysis and representation of FHIR and EHR data. FHIRPACK was designed and developed at Institute for Artificial Intelligence in Medicine (IKIM) and the Database Systems Research Group of the University of Heidelberg (HDDBS).

Sep 19, 2022

Python GUI project - Raster image format conversion GUI

Python GUI project - Raster image format conversion GUI

RasterConvert - Raster Image file format converter Description RasterConvert is a Windows OS application that can be used to seamlessly convert Raster

Sep 21, 2022

A Python Binder that merge 2 files with any extension by creating a new python file and compiling it to exe which runs both payloads.

A Python Binder that merge 2 files with any extension by creating a new python file and compiling it to exe which runs both payloads.

Update ! ANONFILE MIGHT NOT WORK ! About A Python Binder that merge 2 files with any extension by creating a new python file and compiling it to exe w

Sep 7, 2022

IIIF to METS/MODS conversion script

IIIMETS Zusammenfassung Dieses Script erzeugt aus einer Liste von URLs zu IIIF-Manifesten zu Zeitungsausgaben der BSB Zeitungsportal-valide METS/MODS

Mar 30, 2022

Very simple NCHW and NHWC conversion tool for ONNX. Change to the specified input order for each and every input OP

Very simple NCHW and NHWC conversion tool for ONNX. Change to the specified input order for each and every input OP

Very simple NCHW and NHWC conversion tool for ONNX. Change to the specified input order for each and every input OP. Also, change the channel order of RGB and BGR. Simple Channel Converter for ONNX.

Aug 31, 2022

A set of simple tools for splitting, merging, OP deletion, size compression, rewriting attributes and constants, OP generation, change opset, change to the specified input order, and RGB to BGR conversion for ONNX models.

A set of simple tools for splitting, merging, OP deletion, size compression, rewriting attributes and constants, OP generation, change opset, change to the specified input order, and RGB to BGR conversion for ONNX models.

simple-onnx-processing-tools A set of simple tools for splitting, merging, OP deletion, size compression, rewriting attributes and constants, OP gener

Sep 27, 2022

Provides a conversion flow for YOLACT_Edge to models compatible with ONNX, TensorRT, OpenVINO and Myriad (OAK)

Provides a conversion flow for YOLACT_Edge to models compatible with ONNX, TensorRT, OpenVINO and Myriad (OAK)

Provides a conversion flow for YOLACT_Edge to models compatible with ONNX, TensorRT, OpenVINO and Myriad (OAK). My own implementation of post-processing allows for e2e inference.

Sep 2, 2022

Joint CTC-S2S Phoneme-level ASR for Voice Conversion and TTS (Text-Mel Alignment)

AuxiliaryASR This repo contains the training code for Phoneme-level ASR for Voice Conversion (VC) and TTS (Text-Mel Alignment) used in StarGANv2-VC an

Sep 27, 2022
Owner
Jay Jagpal
Jay Jagpal
It lets you see folder in a hierarchical manner and also counts every file extensions present in that folder.

Folder Tree github.com / patelka2211 / Folder-Tree Description It lets you see folder in a hierarchical manner and also counts every file extensions p

Kartavya Patel 1 May 1, 2022
A coding language I made, the file extensions you can use are .scrp or .txt

Scorpion-scrp A coding language I made, the file extensions you can use are .scrp or .txt Does this actually work? I hope it does because all it does

null 1 Jun 3, 2022
An opensource mega-tool for modding il2cpp games including deobfuscation, script generation, cloud file sharing, arm hex conversion, and more

Il2cppWorkshop A WIP opensource mega-tool for modding il2cpp games including deobfuscation, script generation, cloud file sharing, arm hex conversion,

HorridModz 4 Sep 14, 2022
A tree-based file format. Leaves are primitive types, branches are descendants of STFObject.

Serializable Tree File Format (STF) Version a.0.0.3 A tree-based file format. Leaves are primitive types, branches are descendants of STFObject. STFOb

null 3 Jun 1, 2022
Demos of how to use Poetry to build various C/C++ extensions for Python.

This project is a collection of examples on how to build various types of C code from poetry. The following examples are currently included: extension

Sebastian Wallk├Âtter 9 Sep 22, 2022
Python program to organize files based on their extensions.

File Organizer Python Python program to organize files based on their extensions. ---Prerequisite--- You must install python on your PC to run this pr

Gautam Patil 2 Sep 1, 2022
Configurable event system for Jupyter applications and extensions.

Jupyter Events An event system for Jupyter Applications and extensions. Jupyter Events enables Jupyter Applications (e.g. Jupyter Server, Jupyter Note

Project Jupyter 4 Sep 8, 2022
Various Odoo apps and/or extensions

various_odoo_apps Apps related to various (third party) Odoo apps auditlog_extra: expansion of https://github.com/OCA/server-tools/tree/14.0/auditlog

Yenthe Van Ginneken 7 Jul 13, 2022
Extensions for ops.testing.Harness

What this is This is a library providing a utility for unittesting events fired on a Harness-ed Charm. Good when: you want to verify that a specific e

null 2 Aug 18, 2022
Helpful celery task queue extensions.

celery-heimdall Celery Heimdall is a set of common utilities useful for the Celery background worker framework, built on top of Redis. It's not trying

Tyler Kennedy 1 Aug 20, 2022