summaryrefslogtreecommitdiff
path: root/paste/util
diff options
context:
space:
mode:
authorChristoph Zwerschke <cito@online.de>2010-08-19 17:06:41 +0200
committerChristoph Zwerschke <cito@online.de>2010-08-19 17:06:41 +0200
commit7a2cde4d6e1f19088652f5048662ce3e84e7a454 (patch)
tree2ef787611e64eb4aaa47e94b6d7a03147dea4ba5 /paste/util
parent8bac38f24dd068c859da813a2981129ab3827284 (diff)
downloadpaste-7a2cde4d6e1f19088652f5048662ce3e84e7a454.tar.gz
Minor simplification.
Diffstat (limited to 'paste/util')
-rw-r--r--paste/util/mimeparse.py12
1 files changed, 4 insertions, 8 deletions
diff --git a/paste/util/mimeparse.py b/paste/util/mimeparse.py
index 7a68772..238fcdc 100644
--- a/paste/util/mimeparse.py
+++ b/paste/util/mimeparse.py
@@ -60,14 +60,10 @@ def parse_media_range(range):
in with a proper default if necessary.
"""
type, subtype, params = parse_mime_type(range)
- if 'q' in params:
- try:
- q = float(params['q'])
- if not 0 <= q <= 1:
- raise ValueError
- except ValueError:
- params['q'] = '1'
- else:
+ try:
+ if not 0 <= float(params['q']) <= 1:
+ raise ValueError
+ except (KeyError, ValueError):
params['q'] = '1'
return type, subtype, params