{ "info": { "author": "Tim Martin", "author_email": "tim.martin@vertical-knowledge.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "License :: OSI Approved :: GNU General Public License v2 (GPLv2)", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "Accept-Header-Match\n===================\n\n.. image:: https://travis-ci.org/vertical-knowledge/ripozo.svg?branch=master&style=flat\n :target: https://travis-ci.org/vertical-knowledge/mimetype-match\n :alt: test status\n\n.. image:: https://readthedocs.org/projects/ripozo/badge/?version=latest\n :target: https://mimetype-match.readthedocs.org/\n :alt: Documentation Status\n\nA tool to make parsing Accept headers and finding the appropriate mimetype to\nreturn easy. Simply pass your accept header and the mimetype your server can\nreturn and it will find the best match.\n\nThere is both a programmatic interface to this package as well as a\ncommand line interface.\n\nInstallation\n------------\n\nIt can easily be installed using pip\n\n.. code-block:: bash\n\n pip install mimetype-match\n\nOr if you prefer clone the repo and install it simply run the following\nfrom the root directory of the package.\n\n.. code-block:: bash\n\n python setup.py develop\n\nFull Documentation\n------------------\n\n`Documentation `_\n\nUsing the command line interface\n--------------------------------\n\n.. code-block:: bash\n\n mimetype-match [accept-header] [server-mimetype1] [server-mimetype2] ...\n\nThe first argument should be the comma delimited\nmimetypes as an appropriately formatted accept header.\nThe additional arguments are the mimetypes from the server\nthat you wish to match. For example you may have an Accept header\nof the following:\n``text/*;q=0.3, text/html;q=0.7, text/html;level=1, /html;level=2;q=0.4, */*;q=0.5``\nand the server can serve the following content types:\n``[\"text/html\", \"application/json\", \"audio/basic\"]``\n\nIn this case we would run the following command:\n\n.. code-block:: bash\n\n mimetype-match \"text/*;q=0.3, text/html;q=0.7, text/html;level=1, /html;level=2;q=0.4, */*;q=0.5\" \"text/html\" \"application/json\" \"audio/basic\"\n\nThis command would tell you that \"text/html\" is the best choice.\n\nUsing the package\n-----------------\n\nUsing the package programmatically is very similar to the cli.\n\n.. code-block:: python\n\n from mimetype_match import AcceptHeader\n\n available_types = [\"text/html\", \"application/json\", \"audio/basic\"]\n accept_header = AcceptHeader(\"text/*;q=0.3, text/html;q=0.7, text/html;level=1, /html;level=2;q=0.4, */*;q=0.5\")\n best_match = accept_header.get_best_match(available_types)\n # It returns a tuple. The first object is a MimeType object\n # which has the orinal requested type from the client\n # The second object is the available type from the\n # server that best matches the clients requested types.\n print(best_match[0].mimetype)\n print(best_match[0].weight)\n print(best_match[1])\n\n\nVersioning\n----------\n\nPrior to version 1.0.0 versioning follows `sentimental\nversioning `_. Releases after 1.0.0 ollow\na standard *major.minor.patch* style.\n\n- patch: forwards and backwards compatible\n- minor: backwards compatible\n- major: No guarantees\n\nContributing\n------------\n\nWant to help out? We'd love it! Github will be the hub of development for mimetype-matching.\nIf you have any issues, comments, or complaints post them there. Additionally, we\nare definitely accepting pull requests (hint: we almost always love more tests and\ndocumentation). We do have just a few requests:\n\n* Every method, function, and class should have a thorough docstring\n* There should be at least one unit test for each function and method\n* Keep your pull requests to one issue. (Preferably open an issue on github first for record keeping)\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/timmartin19/mimetype-match", "keywords": "H,T,T,P, ,p,y,t,h,o,n, ,A,c,c,e,p,t, ,H,e,a,d,e,r, ,H,T,T,P,_,A,C,C,E,P,T, ,m,i,m,e,t,y,p,e, ,m,a,t,c,h, ,C,o,n,t,e,n,t,-,T,y,p,e, ,c,o,n,t,e,n,t, ,t,y,p,e", "license": "", "maintainer": "", "maintainer_email": "", "name": "mimetype-match", "package_url": "https://pypi.org/project/mimetype-match/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/mimetype-match/", "project_urls": { "Homepage": "https://github.com/timmartin19/mimetype-match" }, "release_url": "https://pypi.org/project/mimetype-match/1.0.4/", "requires_dist": null, "requires_python": "", "summary": "A tool to make finding the appropriate mimetype to return easy", "version": "1.0.4" }, "last_serial": 1998623, "releases": { "1.0.1": [ { "comment_text": "", "digests": { "md5": "f222457d78681dac5b37141161176317", "sha256": "5b1df75986df14c5da9a2b6c5be7fbe4af34f1f849500cf6a492691e140cc3f7" }, "downloads": -1, "filename": "mimetype-match-1.0.1.tar.gz", "has_sig": false, "md5_digest": "f222457d78681dac5b37141161176317", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2730, "upload_time": "2015-11-29T05:26:43", "url": "https://files.pythonhosted.org/packages/57/72/e01efc83ee7cfca3fa17a61a71a3ae8ba761e139803b3a37851b13cda776/mimetype-match-1.0.1.tar.gz" } ], "1.0.2": [ { "comment_text": "", "digests": { "md5": "28c0c8cb9f3bf4d1b36e20220d8e325a", "sha256": "f0944bf6da895c3ae3781000a5f531eb9c650e63b0b64aede2edd59d3342a14c" }, "downloads": -1, "filename": "mimetype-match-1.0.2.tar.gz", "has_sig": false, "md5_digest": "28c0c8cb9f3bf4d1b36e20220d8e325a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5090, "upload_time": "2016-03-10T04:37:37", "url": "https://files.pythonhosted.org/packages/83/29/8a4fd2394f4217ded18ea0693b009ba9ba1ef5fa637c640115088754670c/mimetype-match-1.0.2.tar.gz" } ], "1.0.3": [ { "comment_text": "", "digests": { "md5": "e43d02028dec2b9d3e31c193ed3e6abf", "sha256": "e59590da764fd4ffa0699947f785aaf185d813d3dba57cb4af33dd1945fa7f22" }, "downloads": -1, "filename": "mimetype-match-1.0.3.tar.gz", "has_sig": false, "md5_digest": "e43d02028dec2b9d3e31c193ed3e6abf", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5092, "upload_time": "2016-03-10T04:41:06", "url": "https://files.pythonhosted.org/packages/a7/76/9dc904dba898375f8b6b00e534008a3d965035e22a5f99d18dbdc5876b08/mimetype-match-1.0.3.tar.gz" } ], "1.0.4": [ { "comment_text": "", "digests": { "md5": "9985e931444c9fb3bd2b5b9d78a4cd81", "sha256": "d097cc13b0ebcbfa2b335fb9516394d8f13b62e56ce1a88c8f855772b27afc89" }, "downloads": -1, "filename": "mimetype-match-1.0.4.tar.gz", "has_sig": false, "md5_digest": "9985e931444c9fb3bd2b5b9d78a4cd81", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5091, "upload_time": "2016-03-10T04:48:57", "url": "https://files.pythonhosted.org/packages/21/ac/7785920928ddc7199758c83ab0286194e917d77db51df1237704f484fd61/mimetype-match-1.0.4.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "9985e931444c9fb3bd2b5b9d78a4cd81", "sha256": "d097cc13b0ebcbfa2b335fb9516394d8f13b62e56ce1a88c8f855772b27afc89" }, "downloads": -1, "filename": "mimetype-match-1.0.4.tar.gz", "has_sig": false, "md5_digest": "9985e931444c9fb3bd2b5b9d78a4cd81", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5091, "upload_time": "2016-03-10T04:48:57", "url": "https://files.pythonhosted.org/packages/21/ac/7785920928ddc7199758c83ab0286194e917d77db51df1237704f484fd61/mimetype-match-1.0.4.tar.gz" } ] }