python-mimeparse


Namepython-mimeparse JSON
Version 1.6.0 PyPI version JSON
download
home_pagehttps://github.com/dbtsai/python-mimeparse
SummaryA module provides basic functions for parsing mime-type names and matching them against a list of media-ranges.
upload_time2016-10-16 22:54:17
maintainerNone
docs_urlNone
authorDB Tsai
requires_pythonNone
licenseUNKNOWN
keywords mime-type
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage No coveralls.
            Python-MimeParse
================

.. image:: https://travis-ci.org/dbtsai/python-mimeparse.svg?branch=master
   :target: https://travis-ci.org/dbtsai/python-mimeparse

This module provides basic functions for handling mime-types. It can
handle matching mime-types against a list of media-ranges. See section
5.3.2 of the HTTP 1.1 Semantics and Content specification [RFC 7231] for
a complete explanation: https://tools.ietf.org/html/rfc7231#section-5.3.2

Installation
------------

Use **pip**:

.. code-block:: sh

    $ pip install python-mimeparse

It supports Python 2.7 - 3.5 and PyPy.

Functions
---------

**parse_mime_type()**

Parses a mime-type into its component parts.

**parse_media_range()**

Media-ranges are mime-types with wild-cards and a "q" quality parameter.

**quality()**

Determines the quality ("q") of a mime-type when compared against a list of
media-ranges.

**quality_parsed()**

Just like ``quality()`` except the second parameter must be pre-parsed.

**best_match()**

Choose the mime-type with the highest quality ("q") from a list of candidates.

Testing
-------

Run the tests by typing: ``python mimeparse_test.py``. The tests require Python 2.6.

To make sure that the package works in all the supported environments, you can
run **tox** tests:

.. code-block:: sh

    $ pip install tox
    $ tox

The format of the JSON test data file is as follows: A top-level JSON object
which has a key for each of the functions to be tested. The value corresponding
to that key is a list of tests. Each test contains: the argument or arguments
to the function being tested, the expected results and an optional description.
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/dbtsai/python-mimeparse",
    "name": "python-mimeparse",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "mime-type",
    "author": "DB Tsai",
    "author_email": "dbtsai@dbtsai.com",
    "download_url": "https://files.pythonhosted.org/packages/0f/40/ac5f9e44a55b678c3cd881b4c3376e5b002677dbeab6fb3a50bac5d50d29/python-mimeparse-1.6.0.tar.gz",
    "platform": "UNKNOWN",
    "description": "Python-MimeParse\n================\n\n.. image:: https://travis-ci.org/dbtsai/python-mimeparse.svg?branch=master\n   :target: https://travis-ci.org/dbtsai/python-mimeparse\n\nThis module provides basic functions for handling mime-types. It can\nhandle matching mime-types against a list of media-ranges. See section\n5.3.2 of the HTTP 1.1 Semantics and Content specification [RFC 7231] for\na complete explanation: https://tools.ietf.org/html/rfc7231#section-5.3.2\n\nInstallation\n------------\n\nUse **pip**:\n\n.. code-block:: sh\n\n    $ pip install python-mimeparse\n\nIt supports Python 2.7 - 3.5 and PyPy.\n\nFunctions\n---------\n\n**parse_mime_type()**\n\nParses a mime-type into its component parts.\n\n**parse_media_range()**\n\nMedia-ranges are mime-types with wild-cards and a \"q\" quality parameter.\n\n**quality()**\n\nDetermines the quality (\"q\") of a mime-type when compared against a list of\nmedia-ranges.\n\n**quality_parsed()**\n\nJust like ``quality()`` except the second parameter must be pre-parsed.\n\n**best_match()**\n\nChoose the mime-type with the highest quality (\"q\") from a list of candidates.\n\nTesting\n-------\n\nRun the tests by typing: ``python mimeparse_test.py``. The tests require Python 2.6.\n\nTo make sure that the package works in all the supported environments, you can\nrun **tox** tests:\n\n.. code-block:: sh\n\n    $ pip install tox\n    $ tox\n\nThe format of the JSON test data file is as follows: A top-level JSON object\nwhich has a key for each of the functions to be tested. The value corresponding\nto that key is a list of tests. Each test contains: the argument or arguments\nto the function being tested, the expected results and an optional description.",
    "bugtrack_url": null,
    "license": "UNKNOWN",
    "summary": "A module provides basic functions for parsing mime-type names and matching them against a list of media-ranges.",
    "version": "1.6.0",
    "split_keywords": [
        "mime-type"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "e2780ceb12929f2f8557c467fa8c2567",
                "sha256": "a295f03ff20341491bfe4717a39cd0a8cc9afad619ba44b77e86b0ab8a2b8282"
            },
            "downloads": -1,
            "filename": "python_mimeparse-1.6.0-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e2780ceb12929f2f8557c467fa8c2567",
            "packagetype": "bdist_wheel",
            "python_version": "2.7",
            "requires_python": null,
            "size": 6057,
            "upload_time": "2016-10-16T22:54:20",
            "upload_time_iso_8601": "2016-10-16T22:54:20.046129Z",
            "url": "https://files.pythonhosted.org/packages/26/2e/03bce213a9bf02a2750dcb04e761785e9c763fc11071edc4b447eacbb842/python_mimeparse-1.6.0-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "a32ae1df93be1ddb581d1c0fa124bab4",
                "sha256": "76e4b03d700a641fd7761d3cd4fdbbdcd787eade1ebfac43f877016328334f78"
            },
            "downloads": -1,
            "filename": "python-mimeparse-1.6.0.tar.gz",
            "has_sig": false,
            "md5_digest": "a32ae1df93be1ddb581d1c0fa124bab4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 6541,
            "upload_time": "2016-10-16T22:54:17",
            "upload_time_iso_8601": "2016-10-16T22:54:17.818759Z",
            "url": "https://files.pythonhosted.org/packages/0f/40/ac5f9e44a55b678c3cd881b4c3376e5b002677dbeab6fb3a50bac5d50d29/python-mimeparse-1.6.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2016-10-16 22:54:17",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "dbtsai",
    "github_project": "python-mimeparse",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "python-mimeparse"
}
        
Elapsed time: 0.02510s