def parse_media_range(range):
    """Carves up a media range and returns a tuple of the
       (type, subtype, params) where 'params' is a dictionary
       of all the parameters for the media range.
       For example, the media range 'application/*;q=0.5' would
       get parsed into:

       ('application', '*', {'q', '0.5'})

       In addition this function also guarantees that there
       is a value for 'q' in the params dictionary, filling it
       in with a proper default if necessary.
       """
    type, subtype, params = parse_mime_type(range)
    try:
        if not 0 <= float(params['q']) <= 1:
            raise ValueError
    except (KeyError, __HOLE__):
        params['q'] = '1'
    return type, subtype, params
dataset/ETHPy150Open cloudera/hue/desktop/core/ext-py/Paste-2.0.1/paste/util/mimeparse.py/parse_media_range