def parse_media_range(range):
(type, subtype, params) = parse_mime_type(range)<EOL>if '<STR_LIT:q>' not in params or not params['<STR_LIT:q>'] orfloat(params['<STR_LIT:q>']) > <NUM_LIT:1> or float(params['<STR_LIT:q>']) < <NUM_LIT:0>:<EOL><INDENT>params['<STR_LIT:q>'] = '<STR_LIT:1>'<EOL><DEDENT>return (type, subtype, params)<EOL>
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.