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 /mimeparse.py | |
parent | 694ff00b2e7362ce2b128d7d02c7ccc2852300c2 (diff) | |
download | python-mimeparse-0ae0ebf94de6366490e0b2ed62d36c0ba5cc5e99.tar.gz |
Ported to python3k, and added pypy into the tox test automation.
Diffstat (limited to 'mimeparse.py')
-rwxr-xr-x | mimeparse.py | 3 |
1 files changed, 2 insertions, 1 deletions
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 |