(range)
return (type, subtype, params)
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.
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:
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 :
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)
    if not params.has_key('q') or not params['q'] or \
            not float(params['q']) or float(params['q']) > 1\
            or float(params['q']) < 0:
        params['q'] = '1'
    return (type, subtype, params)
def parse_media_range ( range ) : ( type , subtype , params ) = parse_mime_type ( range ) if not params . has_key ( 'q' ) or not params [ 'q' ] or not float ( params [ 'q' ] ) or float ( params [ 'q' ] ) > 1 or float ( params [ 'q' ] ) < 0 : params [ 'q' ] = '1' return ( type , subtype , params )