What's new? | Help | Directory | Sign in
Google
mimeparse
Basic functions for handling mime-types in Python
  
  
  
  
    
License: MIT License
Labels: python, ruby, php
Groups:

This module provides basic functions for handling mime-types. It can handle matching mime-types against a list of media-ranges.See section 14.1 of the HTTP specification RFC 2616 for a complete explanation.

Contents

Usage

>>> import mimeparse
>>> mimeparse.best_match(['application/xbel+xml', 'text/xml'], 
      'text/*;q=0.5,*/*; q=0.1')
'text/xml'

Usage (Ruby version)

require "mimeparse"
    ==>true
MIMEParse.best_match(['application/xbel+xml', 'text/xml'],
  'text/*;q=0.5,*/*; q=0.1')
    ==>"text/xml"

Usage (PHP version)

include_once 'mimeparse.php';

echo Mimeparse::best_match(array('application/xbel+xml', 'text/xml'),
  'text/*;q=0.5,*/*; q=0.1');
    ==>"text/xml"

Further Reading

More information on the library can be found on the XML.com article Just use Media Types?