Hello community,
here is the log from the commit of package python3-python-mimeparse for
openSUSE:Factory checked in at 2016-02-01 19:57:24
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python3-python-mimeparse (Old)
and /work/SRC/openSUSE:Factory/.python3-python-mimeparse.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python3-python-mimeparse"
Changes:
--------
---
/work/SRC/openSUSE:Factory/python3-python-mimeparse/python3-python-mimeparse.changes
2013-06-25 07:28:05.000000000 +0200
+++
/work/SRC/openSUSE:Factory/.python3-python-mimeparse.new/python3-python-mimeparse.changes
2016-02-01 19:57:41.000000000 +0100
@@ -1,0 +2,11 @@
+Mon Feb 1 04:15:28 UTC 2016 - [email protected]
+
+- specfile:
+ * update copyright year
+ * add setuptools
+ * README -> README.md
+
+- update to version 1.5:
+ (no changelog available)
+
+-------------------------------------------------------------------
Old:
----
python-mimeparse-0.1.4.tar.gz
New:
----
python-mimeparse-1.5.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python3-python-mimeparse.spec ++++++
--- /var/tmp/diff_new_pack.uYppl6/_old 2016-02-01 19:57:42.000000000 +0100
+++ /var/tmp/diff_new_pack.uYppl6/_new 2016-02-01 19:57:42.000000000 +0100
@@ -1,7 +1,7 @@
#
-# spec file for package python3-mimeparse
+# spec file for package python3-python-mimeparse
#
-# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany.
+# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -15,16 +15,18 @@
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
+
Name: python3-python-mimeparse
-Version: 0.1.4
+Version: 1.5
Release: 0
-Url: http://code.google.com/p/mimeparse/
+Url: https://github.com/dbtsai/python-mimeparse
Summary: Basic functions for parsing and matching mime-type names
License: MIT
Group: Development/Languages/Python
Source:
https://pypi.python.org/packages/source/p/python-mimeparse/python-mimeparse-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildRequires: python3-devel
+BuildRequires: python3-setuptools
BuildArch: noarch
%description
@@ -46,7 +48,7 @@
%files
%defattr(-,root,root,-)
-%doc LICENSE README
+%doc LICENSE README.md
%{python3_sitelib}/*
%changelog
++++++ python-mimeparse-0.1.4.tar.gz -> python-mimeparse-1.5.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-mimeparse-0.1.4/MANIFEST.in
new/python-mimeparse-1.5/MANIFEST.in
--- old/python-mimeparse-0.1.4/MANIFEST.in 1970-01-01 01:00:00.000000000
+0100
+++ new/python-mimeparse-1.5/MANIFEST.in 2016-02-01 02:50:22.000000000
+0100
@@ -0,0 +1 @@
+include README.md LICENSE mimeparse_test.py testdata.json
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-mimeparse-0.1.4/PKG-INFO
new/python-mimeparse-1.5/PKG-INFO
--- old/python-mimeparse-0.1.4/PKG-INFO 2012-08-23 22:29:29.000000000 +0200
+++ new/python-mimeparse-1.5/PKG-INFO 2016-02-01 03:00:09.000000000 +0100
@@ -1,13 +1,14 @@
Metadata-Version: 1.1
Name: python-mimeparse
-Version: 0.1.4
+Version: 1.5
Summary: A module provides basic functions for parsing mime-type names and
matching them against a list of media-ranges.
Home-page: https://github.com/dbtsai/python-mimeparse
-Author: David Tsai
+Author: DB Tsai
Author-email: [email protected]
License: UNKNOWN
-Download-URL:
http://pypi.python.org/packages/source/p/python-mimeparse/python-mimeparse-0.1.4.tar.gz
-Description:
+Download-URL:
http://pypi.python.org/packages/source/p/python-mimeparse/python-mimeparse-0.1.4.1.tar.gz
+Description: # Travis CI Build Status [](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 14.1 of
the HTTP specification [RFC 2616] for a complete explanation.
@@ -21,6 +22,22 @@
- 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
+ =======
+ 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.
+
+ Python
+ ======
+ The Python tests require Python 2.6.
+
+ Run the tests by typing:
+ python mimeparse_test.py
+
+ To make sure that the package works in all the supported environments,
you can run tox tests:
+ pip install tox
+ tox
+
Keywords: mime-type
Platform: UNKNOWN
Classifier: Programming Language :: Python
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-mimeparse-0.1.4/README
new/python-mimeparse-1.5/README
--- old/python-mimeparse-0.1.4/README 2012-08-23 05:38:20.000000000 +0200
+++ new/python-mimeparse-1.5/README 1970-01-01 01:00:00.000000000 +0100
@@ -1,19 +0,0 @@
-This module provides basic functions for parsing mime-type names and matching
them against a list of media-ranges.
-
-See section 14.1 of RFC 2616 (the HTTP specification) for a complete
explanation.
-
-Testing
-=======
-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.
-
-
-Python
-======
-The Python tests require either Python 2.6 or the installation of the
SimpleJSON library.
-
-Installing SimpleJson can be done by:
-sudo easy_install simplejson
-
-Run the tests by typing:
-python mimeparse_test.py
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-mimeparse-0.1.4/README.md
new/python-mimeparse-1.5/README.md
--- old/python-mimeparse-0.1.4/README.md 1970-01-01 01:00:00.000000000
+0100
+++ new/python-mimeparse-1.5/README.md 2016-02-01 02:32:30.000000000 +0100
@@ -0,0 +1,30 @@
+# Travis CI Build Status [](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 14.1 of
+the HTTP specification [RFC 2616] for a complete explanation.
+
+ http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1
+
+Contents:
+ - 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
+=======
+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.
+
+Python
+======
+The Python tests require Python 2.6.
+
+Run the tests by typing:
+python mimeparse_test.py
+
+To make sure that the package works in all the supported environments, you can
run tox tests:
+pip install tox
+tox
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-mimeparse-0.1.4/mimeparse.py
new/python-mimeparse-1.5/mimeparse.py
--- old/python-mimeparse-0.1.4/mimeparse.py 2012-08-23 22:19:36.000000000
+0200
+++ new/python-mimeparse-1.5/mimeparse.py 2016-02-01 02:25:43.000000000
+0100
@@ -19,13 +19,17 @@
"""
from functools import reduce
-__version__ = '0.1.4'
+__version__ = '0.1.4.1'
__author__ = 'Joe Gregorio'
__email__ = '[email protected]'
__license__ = 'MIT License'
__credits__ = ''
+class MimeTypeParseException(Exception):
+ pass
+
+
def parse_mime_type(mime_type):
"""Parses a mime-type into its component parts.
@@ -45,6 +49,10 @@
# single '*'. Turn it into a legal wildcard.
if full_type == '*':
full_type = '*/*'
+
+ if '/' not in full_type:
+ raise MimeTypeParseException("Can't parse type
\"{}\"".format(full_type))
+
(type, subtype) = full_type.split('/')
return (type.strip(), subtype.strip(), params)
@@ -65,15 +73,14 @@
necessary.
"""
(type, subtype, params) = parse_mime_type(range)
- if not 'q' in params or not params['q'] or \
- not float(params['q']) or float(params['q']) > 1\
- or float(params['q']) < 0:
+ if 'q' not in params or not params['q'] or \
+ float(params['q']) > 1 or float(params['q']) < 0:
params['q'] = '1'
return (type, subtype, params)
-def fitness_and_quality_parsed(mime_type, parsed_ranges):
+def quality_and_fitness_parsed(mime_type, parsed_ranges):
"""Find the best match for a mime-type amongst parsed media-ranges.
Find the best match for a given mime-type against a list of media_ranges
@@ -95,7 +102,7 @@
target_subtype == '*')
if type_match and subtype_match:
param_matches = reduce(lambda x, y: x + y, [1 for (key, value) in
- list(target_params.items()) if key != 'q'
and
+ target_params.items() if key != 'q' and
key in params and value == params[key]], 0)
fitness = (type == target_type) and 100 or 0
fitness += (subtype == target_subtype) and 10 or 0
@@ -104,7 +111,7 @@
best_fitness = fitness
best_fit_q = params['q']
- return best_fitness, float(best_fit_q)
+ return float(best_fit_q), best_fitness
def quality_parsed(mime_type, parsed_ranges):
@@ -116,7 +123,7 @@
bahaves the same as quality() except that 'parsed_ranges' must be a list of
parsed media ranges. """
- return fitness_and_quality_parsed(mime_type, parsed_ranges)[1]
+ return quality_and_fitness_parsed(mime_type, parsed_ranges)[0]
def quality(mime_type, ranges):
@@ -154,12 +161,12 @@
weighted_matches = []
pos = 0
for mime_type in supported:
- weighted_matches.append((fitness_and_quality_parsed(mime_type,
+ weighted_matches.append((quality_and_fitness_parsed(mime_type,
parsed_header), pos, mime_type))
pos += 1
weighted_matches.sort()
- return weighted_matches[-1][0][1] and weighted_matches[-1][2] or ''
+ return weighted_matches[-1][0][0] and weighted_matches[-1][2] or ''
def _filter_blank(i):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-mimeparse-0.1.4/mimeparse_test.py
new/python-mimeparse-1.5/mimeparse_test.py
--- old/python-mimeparse-0.1.4/mimeparse_test.py 2012-08-23
05:38:20.000000000 +0200
+++ new/python-mimeparse-1.5/mimeparse_test.py 2016-02-01 02:25:43.000000000
+0100
@@ -5,68 +5,68 @@
This module loads a json file and converts the tests specified therein to a set
of PyUnitTestCases. Then it uses PyUnit to run them and report their status.
"""
-__version__ = "0.1"
-__author__ = 'Ade Oshineye'
-__email__ = "[email protected]"
-__credits__ = ""
-
import json
import mimeparse
import unittest
-from functools import partial
-
-
-def test_parse_media_range(args, expected):
- expected = tuple(expected)
- result = mimeparse.parse_media_range(args)
- message = "Expected: '%s' but got %s" % (expected, result)
- assert expected == result, message
-
-
-def test_quality(args, expected):
- result = mimeparse.quality(args[0], args[1])
- message = "Expected: '%s' but got %s" % (expected, result)
- assert expected == result, message
-def test_best_match(args, expected):
- result = mimeparse.best_match(args[0], args[1])
- message = "Expected: '%s' but got %s" % (expected, result)
- assert expected == result, message
-
-
-def test_parse_mime_type(args, expected):
- expected = tuple(expected)
- result = mimeparse.parse_mime_type(args)
- message = "Expected: '%s' but got %s" % (expected, result)
- assert expected == result, message
-
-
-def add_tests(suite, json_object, func_name, test_func):
- test_data = json_object[func_name]
- for test_datum in test_data:
- args, expected = test_datum[0], test_datum[1]
- desc = "%s(%s) with expected result: %s" % (func_name, str(args),
- str(expected))
- if len(test_datum) == 3:
- desc = test_datum[2] + " : " + desc
- func = partial(test_func, *(args, expected))
- testcase = unittest.FunctionTestCase(func, description=desc)
- suite.addTest(testcase)
-
+__version__ = "0.1"
+__author__ = 'Ade Oshineye'
+__email__ = "[email protected]"
+__credits__ = ""
-def run_tests():
- json_object = json.load(open("testdata.json"))
- suite = unittest.TestSuite()
- add_tests(suite, json_object, "parse_media_range", test_parse_media_range)
- add_tests(suite, json_object, "quality", test_quality)
- add_tests(suite, json_object, "best_match", test_best_match)
- add_tests(suite, json_object, "parse_mime_type", test_parse_mime_type)
+class MimeParseTestCase(unittest.TestCase):
- test_runner = unittest.TextTestRunner(verbosity=1)
- test_runner.run(suite)
+ def setUp(self):
+ super(MimeParseTestCase, self).setUp()
+ with open("testdata.json") as f:
+ self.test_data = json.load(f)
+
+ def _test_parse_media_range(self, args, expected):
+ expected = tuple(expected)
+ result = mimeparse.parse_media_range(args)
+ message = "Expected: '%s' but got %s" % (expected, result)
+ self.assertEqual(expected, result, message)
+
+ def _test_quality(self, args, expected):
+ result = mimeparse.quality(args[0], args[1])
+ message = "Expected: '%s' but got %s" % (expected, result)
+ self.assertEqual(expected, result, message)
+
+ def _test_best_match(self, args, expected, description):
+ if expected is None:
+ self.assertRaises(mimeparse.MimeTypeParseException,
mimeparse.best_match, args[0], args[1])
+ else:
+ result = mimeparse.best_match(args[0], args[1])
+ message = "Expected: '%s' but got %s. Description for this test:
%s" % (expected, result, description)
+ self.assertEqual(expected, result, message)
+
+ def _test_parse_mime_type(self, args, expected):
+ if expected is None:
+ self.assertRaises(mimeparse.MimeTypeParseException,
mimeparse.parse_mime_type, args)
+ else:
+ expected = tuple(expected)
+ result = mimeparse.parse_mime_type(args)
+ message = "Expected: '%s' but got %s" % (expected, result)
+ self.assertEqual(expected, result, message)
+
+ def test_parse_media_range(self):
+ for args, expected in self.test_data['parse_media_range']:
+ self._test_parse_media_range(args, expected)
+
+ def test_quality(self):
+ for args, expected in self.test_data['quality']:
+ self._test_quality(args, expected)
+
+ def test_best_match(self):
+ for args, expected, description in self.test_data['best_match']:
+ self._test_best_match(args, expected, description)
+
+ def test_parse_mime_type(self):
+ for args, expected in self.test_data['parse_mime_type']:
+ self._test_parse_mime_type(args, expected)
-if __name__ == "__main__":
- run_tests()
+if __name__ == '__main__':
+ unittest.main()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/python-mimeparse-0.1.4/python_mimeparse.egg-info/PKG-INFO
new/python-mimeparse-1.5/python_mimeparse.egg-info/PKG-INFO
--- old/python-mimeparse-0.1.4/python_mimeparse.egg-info/PKG-INFO
1970-01-01 01:00:00.000000000 +0100
+++ new/python-mimeparse-1.5/python_mimeparse.egg-info/PKG-INFO 2016-02-01
03:00:09.000000000 +0100
@@ -0,0 +1,50 @@
+Metadata-Version: 1.1
+Name: python-mimeparse
+Version: 1.5
+Summary: A module provides basic functions for parsing mime-type names and
matching them against a list of media-ranges.
+Home-page: https://github.com/dbtsai/python-mimeparse
+Author: DB Tsai
+Author-email: [email protected]
+License: UNKNOWN
+Download-URL:
http://pypi.python.org/packages/source/p/python-mimeparse/python-mimeparse-0.1.4.1.tar.gz
+Description: # Travis CI Build Status [](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 14.1 of
+ the HTTP specification [RFC 2616] for a complete explanation.
+
+ http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1
+
+ Contents:
+ - 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
+ =======
+ 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.
+
+ Python
+ ======
+ The Python tests require Python 2.6.
+
+ Run the tests by typing:
+ python mimeparse_test.py
+
+ To make sure that the package works in all the supported environments,
you can run tox tests:
+ pip install tox
+ tox
+
+Keywords: mime-type
+Platform: UNKNOWN
+Classifier: Programming Language :: Python
+Classifier: Programming Language :: Python :: 3
+Classifier: License :: OSI Approved :: MIT License
+Classifier: Operating System :: OS Independent
+Classifier: Development Status :: 5 - Production/Stable
+Classifier: Intended Audience :: Developers
+Classifier: Topic :: Internet :: WWW/HTTP
+Classifier: Topic :: Software Development :: Libraries :: Python Modules
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/python-mimeparse-0.1.4/python_mimeparse.egg-info/SOURCES.txt
new/python-mimeparse-1.5/python_mimeparse.egg-info/SOURCES.txt
--- old/python-mimeparse-0.1.4/python_mimeparse.egg-info/SOURCES.txt
1970-01-01 01:00:00.000000000 +0100
+++ new/python-mimeparse-1.5/python_mimeparse.egg-info/SOURCES.txt
2016-02-01 03:00:09.000000000 +0100
@@ -0,0 +1,11 @@
+LICENSE
+MANIFEST.in
+README.md
+mimeparse.py
+mimeparse_test.py
+setup.py
+testdata.json
+python_mimeparse.egg-info/PKG-INFO
+python_mimeparse.egg-info/SOURCES.txt
+python_mimeparse.egg-info/dependency_links.txt
+python_mimeparse.egg-info/top_level.txt
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/python-mimeparse-0.1.4/python_mimeparse.egg-info/dependency_links.txt
new/python-mimeparse-1.5/python_mimeparse.egg-info/dependency_links.txt
--- old/python-mimeparse-0.1.4/python_mimeparse.egg-info/dependency_links.txt
1970-01-01 01:00:00.000000000 +0100
+++ new/python-mimeparse-1.5/python_mimeparse.egg-info/dependency_links.txt
2016-02-01 03:00:09.000000000 +0100
@@ -0,0 +1 @@
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/python-mimeparse-0.1.4/python_mimeparse.egg-info/top_level.txt
new/python-mimeparse-1.5/python_mimeparse.egg-info/top_level.txt
--- old/python-mimeparse-0.1.4/python_mimeparse.egg-info/top_level.txt
1970-01-01 01:00:00.000000000 +0100
+++ new/python-mimeparse-1.5/python_mimeparse.egg-info/top_level.txt
2016-02-01 03:00:09.000000000 +0100
@@ -0,0 +1 @@
+mimeparse
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-mimeparse-0.1.4/setup.cfg
new/python-mimeparse-1.5/setup.cfg
--- old/python-mimeparse-0.1.4/setup.cfg 2012-08-23 07:15:20.000000000
+0200
+++ new/python-mimeparse-1.5/setup.cfg 2016-02-01 03:00:09.000000000 +0100
@@ -1,2 +1,5 @@
-[easy_install]
+[egg_info]
+tag_build =
+tag_date = 0
+tag_svn_revision = 0
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-mimeparse-0.1.4/setup.py
new/python-mimeparse-1.5/setup.py
--- old/python-mimeparse-0.1.4/setup.py 2012-08-23 22:28:43.000000000 +0200
+++ new/python-mimeparse-1.5/setup.py 2016-02-01 03:00:07.000000000 +0100
@@ -1,17 +1,26 @@
#!/usr/bin/env python
-from distutils.core import setup
+import os
+import codecs
import mimeparse
+from setuptools import setup
+
+
+def read(fname):
+ path = os.path.join(os.path.dirname(__file__), fname)
+ return codecs.open(path, encoding='utf-8').read()
setup(
name="python-mimeparse",
py_modules=["mimeparse"],
- version=mimeparse.__version__,
- description="A module provides basic functions for parsing mime-type names
and matching them against a list of media-ranges.",
- author="David Tsai",
+ version=1.5,
+ description=("A module provides basic functions for parsing mime-type "
+ "names and matching them against a list of media-ranges."),
+ author="DB Tsai",
author_email="[email protected]",
url="https://github.com/dbtsai/python-mimeparse",
-
download_url="http://pypi.python.org/packages/source/p/python-mimeparse/python-mimeparse-0.1.4.tar.gz",
+ download_url=("http://pypi.python.org/packages/source/p/python-mimeparse/"
+ "python-mimeparse-" + mimeparse.__version__ + ".tar.gz"),
keywords=["mime-type"],
classifiers=[
"Programming Language :: Python",
@@ -23,18 +32,5 @@
"Topic :: Internet :: WWW/HTTP",
"Topic :: Software Development :: Libraries :: Python Modules",
],
- long_description="""
-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.
-
- http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1
-
-Contents:
- - 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.
-"""
+ long_description=read('README.md')
)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-mimeparse-0.1.4/testdata.json
new/python-mimeparse-1.5/testdata.json
--- old/python-mimeparse-0.1.4/testdata.json 2012-08-23 05:38:20.000000000
+0200
+++ new/python-mimeparse-1.5/testdata.json 2016-02-01 02:25:43.000000000
+0100
@@ -1,42 +1,46 @@
{
"parse_media_range": [
- ["application/xml;q=1", ["application", "xml", {"q":
"1"}]],
- ["application/xml", ["application", "xml", {"q": "1"}]],
- ["application/xml;q=",["application", "xml", {"q": "1"}]],
- ["application/xml ;q=",["application", "xml", {"q": "1"}]],
- ["application/xml ; q=1;b=other",["application", "xml",
{"q": "1", "b":"other"}]],
- ["application/xml ; q=2;b=other",["application", "xml",
{"q": "1", "b":"other"}]],
- [" *; q=.2",["*", "*", {"q": ".2"}]]
+ ["application/xml;q=1", ["application", "xml", {"q": "1"}]],
+ ["application/xml", ["application", "xml", {"q": "1"}]],
+ ["application/xml;q=",["application", "xml", {"q": "1"}]],
+ ["application/xml ;q=",["application", "xml", {"q": "1"}]],
+ ["application/xml ; q=1;b=other",["application", "xml", {"q": "1",
"b":"other"}]],
+ ["application/xml ; q=2;b=other",["application", "xml", {"q": "1",
"b":"other"}]],
+ ["application/xml ; q=0",["application", "xml", {"q": "0"}]],
+ [" *; q=.2",["*", "*", {"q": ".2"}]]
],
"quality": [
- [["text/html;level=1", "text/*;q=0.3, text/html;q=0.7,
text/html;level=1, text/html;level=2;q=0.4, */*;q=0.5"], 1],
- [["text/html", "text/*;q=0.3, text/html;q=0.7, text/html;level=1,
text/html;level=2;q=0.4, */*;q=0.5"], 0.7],
- [["text/plain", "text/*;q=0.3, text/html;q=0.7, text/html;level=1,
text/html;level=2;q=0.4, */*;q=0.5"], 0.3],
- [["image/jpeg", "text/*;q=0.3, text/html;q=0.7, text/html;level=1,
text/html;level=2;q=0.4, */*;q=0.5"], 0.5],
- [["text/html;level=2", "text/*;q=0.3, text/html;q=0.7,
text/html;level=1, text/html;level=2;q=0.4, */*;q=0.5"], 0.4],
- [["text/html;level=3", "text/*;q=0.3, text/html;q=0.7,
text/html;level=1, text/html;level=2;q=0.4, */*;q=0.5"], 0.7],
- [["text/plain", "text/html, image/gif, image/jpeg, *;
q=.2, */*; q=.2"], 0.2]
+ [["text/html;level=1", "text/*;q=0.3, text/html;q=0.7, text/html;level=1,
text/html;level=2;q=0.4, */*;q=0.5"], 1],
+ [["text/html", "text/*;q=0.3, text/html;q=0.7, text/html;level=1,
text/html;level=2;q=0.4, */*;q=0.5"], 0.7],
+ [["text/plain", "text/*;q=0.3, text/html;q=0.7, text/html;level=1,
text/html;level=2;q=0.4, */*;q=0.5"], 0.3],
+ [["image/jpeg", "text/*;q=0.3, text/html;q=0.7, text/html;level=1,
text/html;level=2;q=0.4, */*;q=0.5"], 0.5],
+ [["text/html;level=2", "text/*;q=0.3, text/html;q=0.7, text/html;level=1,
text/html;level=2;q=0.4, */*;q=0.5"], 0.4],
+ [["text/html;level=3", "text/*;q=0.3, text/html;q=0.7, text/html;level=1,
text/html;level=2;q=0.4, */*;q=0.5"], 0.7],
+ [["text/plain", "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2"],
0.2]
],
"best_match": [
- [[["application/xbel+xml", "application/xml"],
"application/xbel+xml"], "application/xbel+xml", "direct match"],
- [[["application/xbel+xml", "application/xml"],
"application/xbel+xml; q=1"], "application/xbel+xml", "direct match with a q
parameter"],
- [[["application/xbel+xml", "application/xml"], "application/xml;
q=1"], "application/xml", "direct match of our second choice with a q
parameter"],
- [[["application/xbel+xml", "application/xml"], "application/*;
q=1"], "application/xml", "match using a subtype wildcard"],
- [[["application/xbel+xml", "application/xml"], "*/*",
"application/xml"], "application/xml", "match using a type wildcard"],
- [[["application/xbel+xml", "text/xml"], "text/*;q=0.5,*/*;
q=0.1"], "text/xml", "match using a type versus a lower weighted subtype"],
- [[["application/xbel+xml", "text/xml"],
"text/html,application/atom+xml; q=0.9"], "", "fail to match anything"],
- [[["application/json", "text/html"], "application/json,
text/javascript, */*"], "application/json", "common AJAX scenario"],
- [[["application/json", "text/html"], "application/json,
text/html;q=0.9"], "application/json", "verify fitness ordering"],
- [[["image/*", "application/xml"], "image/png"], "image/*", "match
using a type wildcard"],
- [[["image/*", "application/xml"], "image/*"], "image/*", "match
using a wildcard for both requested and supported"],
- [[["text/html", "application/rdf+xml"], "text/html,
application/rdf+xml"], "application/rdf+xml", "match should use highest order
of supported when there is a tie"],
- [[["application/rdf+xml", "text/html"], "text/html,
application/rdf+xml"], "text/html", "match should use highest order of
supported when there is a tie"]
+ [[["application/xbel+xml", "application/xml"], "application/xbel+xml"],
"application/xbel+xml", "direct match"],
+ [[["application/xbel+xml", "application/xml"], "application/xbel+xml;
q=1"], "application/xbel+xml", "direct match with a q parameter"],
+ [[["application/xbel+xml", "application/xml"], "application/xml; q=1"],
"application/xml", "direct match of our second choice with a q parameter"],
+ [[["application/xbel+xml", "application/xml"], "application/*; q=1"],
"application/xml", "match using a subtype wildcard"],
+ [[["application/xbel+xml", "application/xml"], "*/*", "application/xml"],
"application/xml", "match using a type wildcard"],
+ [[["application/xbel+xml", "text/xml"], "text/*;q=0.5,*/*; q=0.1"],
"text/xml", "match using a type versus a lower weighted subtype"],
+ [[["application/xbel+xml", "text/xml"], "text/html,application/atom+xml;
q=0.9"], "", "fail to match anything"],
+ [[["application/json", "text/html"], "application/json, text/javascript,
*/*"], "application/json", "common AJAX scenario"],
+ [[["application/json", "text/html"], "application/json, text/html;q=0.9"],
"application/json", "verify fitness ordering"],
+ [[["image/*", "application/xml"], "image/png"], "image/*", "match using a
type wildcard"],
+ [[["image/*", "application/xml"], "image/*"], "image/*", "match using a
wildcard for both requested and supported"],
+ [[["image/jpeg", "text/plain"], "text/*;q=0.3, text/html;q=0.7,
text/html;level=1, text/html;level=2;q=0.4, */*;q=0.5"], "image/jpeg", "media
type with highest associated quality factor should win, not necessarily most
specific"],
+ [[["text/html", "application/rdf+xml"], "text/html, application/rdf+xml"],
"application/rdf+xml", "match should use highest order of supported when there
is a tie"],
+ [[["application/rdf+xml", "text/html"], "text/html, application/rdf+xml"],
"text/html", "match should use highest order of supported when there is a tie"],
+ [[["application/json", "text/html"], "text"], null, "match should use the
default if an invalid Accept header is passed"]
],
"parse_mime_type": [
- ["application/xhtml;q=0.5", ["application", "xhtml", {"q":
"0.5"}]],
- ["application/xhtml;q=0.5;ver=1.2", ["application", "xhtml",
{"q": "0.5", "ver": "1.2"}]]
+ ["application/xhtml;q=0.5", ["application", "xhtml", {"q": "0.5"}]],
+ ["application/xhtml;q=0.5;ver=1.2", ["application", "xhtml", {"q": "0.5",
"ver": "1.2"}]],
+ ["text", null]
]
}