diff options
author | D.B. Tsai <dbtsai@dbtsai.com> | 2012-08-22 16:52:17 -0700 |
---|---|---|
committer | D.B. Tsai <dbtsai@dbtsai.com> | 2012-08-27 20:02:40 -0700 |
commit | 0ae0ebf94de6366490e0b2ed62d36c0ba5cc5e99 (patch) | |
tree | 14222d897772444aee9dcd16a29fd5f0d13becad | |
parent | 694ff00b2e7362ce2b128d7d02c7ccc2852300c2 (diff) | |
download | python-mimeparse-0ae0ebf94de6366490e0b2ed62d36c0ba5cc5e99.tar.gz |
Ported to python3k, and added pypy into the tox test automation.
-rw-r--r-- | .travis.yml | 2 | ||||
-rwxr-xr-x | mimeparse.py | 3 | ||||
-rwxr-xr-x | setup.py | 53 | ||||
-rw-r--r-- | tox.ini | 5 |
4 files changed, 32 insertions, 31 deletions
diff --git a/.travis.yml b/.travis.yml index b6cfd0b..7780b1a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ env: - TOXENV=py26 - TOXENV=py27 - TOXENV=py32 - - TOXENV=py33 + - TOXENV=pypy - TOXENV=pep8,pyflakes # command to install dependencies diff --git a/mimeparse.py b/mimeparse.py index 3d63fc8..075272d 100755 --- a/mimeparse.py +++ b/mimeparse.py @@ -17,6 +17,7 @@ Contents: - best_match(): Choose the mime-type with the highest quality ('q') from a list of candidates. """ +from functools import reduce __version__ = '0.1.3' __author__ = 'Joe Gregorio' @@ -94,7 +95,7 @@ def fitness_and_quality_parsed(mime_type, parsed_ranges): target_subtype == '*') if type_match and subtype_match: param_matches = reduce(lambda x, y: x + y, [1 for (key, value) in - target_params.iteritems() if key != 'q' and + list(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 @@ -1,16 +1,13 @@ - +#!/usr/bin/env python # -*- coding: utf-8 -*- -#old way -from distutils.core import setup +from setuptools import setup -#new way -#from setuptools import setup, find_packages - -setup(name='mimeparse', - version='0.1.3', - description='A module provides basic functions for parsing mime-type names and matching them against a list of media-ranges.', - long_description=""" +setup( + name='mimeparse', + version='0.1.3', + description='A module provides basic functions for parsing mime-type names and matching them against a list of media-ranges.', + 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. @@ -24,21 +21,21 @@ Contents: - 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. """, - classifiers=[ - # Get strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers - 'Intended Audience :: Developers', - 'License :: OSI Approved :: MIT License', - 'Programming Language :: Python', - 'Topic :: Internet :: WWW/HTTP', - 'Topic :: Software Development :: Libraries :: Python Modules', - ], - keywords='mime-type', - author='Joe Gregorio', - author_email='joe@bitworking.org', - maintainer='Joe Gregorio', - maintainer_email='joe@bitworking.org', - url='http://code.google.com/p/mimeparse/', - license='MIT', - py_modules=['mimeparse'], - zip_safe=True, - ) + classifiers=[ + # Get strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers + 'Intended Audience :: Developers', + 'License :: OSI Approved :: MIT License', + 'Programming Language :: Python', + 'Topic :: Internet :: WWW/HTTP', + 'Topic :: Software Development :: Libraries :: Python Modules', + ], + keywords='mime-type', + author='Joe Gregorio', + author_email='joe@bitworking.org', + maintainer='Joe Gregorio', + maintainer_email='joe@bitworking.org', + url='http://code.google.com/p/mimeparse/', + license='MIT', + py_modules=['mimeparse'], + zip_safe=True, +) @@ -1,5 +1,5 @@ [tox] -envlist = py33,py32,py27,py26,pep8,pyflakes +envlist = py33,py32,py27,py26,pypy,pep8,pyflakes [testenv] commands = ./mimeparse_test.py @@ -16,6 +16,9 @@ basepython = python2.7 [testenv:py26] basepython = python2.6 +[testenv:pypy] +basepython = pypy + [testenv:pep8] deps = pep8 commands = pep8 --statistics --show-source --ignore=E501 --exclude=.venv,.tox,*egg . |