Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2988)

Unified Diff: appengine/chromium_build_logs/third_party/googleapiclient/mimeparse.py

Issue 1260293009: make version of ts_mon compatible with appengine (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: clean up code Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: appengine/chromium_build_logs/third_party/googleapiclient/mimeparse.py
diff --git a/appengine/chromium_build_logs/third_party/apiclient/mimeparse.py b/appengine/chromium_build_logs/third_party/googleapiclient/mimeparse.py
similarity index 95%
rename from appengine/chromium_build_logs/third_party/apiclient/mimeparse.py
rename to appengine/chromium_build_logs/third_party/googleapiclient/mimeparse.py
index cbb9d077e7522cb6dd2829e85212cf11c0264a73..bc9ad0944b5f5a5599835b1197cd418a076d47d6 100644
--- a/appengine/chromium_build_logs/third_party/apiclient/mimeparse.py
+++ b/appengine/chromium_build_logs/third_party/googleapiclient/mimeparse.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2007 Joe Gregorio
+# Copyright 2014 Joe Gregorio
#
# Licensed under the MIT License
@@ -21,6 +21,9 @@ Contents:
- best_match(): Choose the mime-type with the highest quality ('q')
from a list of candidates.
"""
+from __future__ import absolute_import
+from functools import reduce
+import six
__version__ = '0.1.3'
__author__ = 'Joe Gregorio'
@@ -68,7 +71,7 @@ def parse_media_range(range):
necessary.
"""
(type, subtype, params) = parse_mime_type(range)
- if not params.has_key('q') or not params['q'] or \
+ if 'q' not in params or not params['q'] or \
not float(params['q']) or float(params['q']) > 1\
or float(params['q']) < 0:
params['q'] = '1'
@@ -98,8 +101,8 @@ 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 \
- params.has_key(key) and value == params[key]], 0)
+ six.iteritems(target_params) 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
fitness += param_matches

Powered by Google App Engine
This is Rietveld 408576698