

def parse_accept_header(value, cls=None):
    'Parses an HTTP Accept-* header.  This does not implement a complete\n    valid algorithm but one that supports at least value and quality\n    extraction.\n\n    Returns a new :class:`Accept` object (basically a list of ``(value, quality)``\n    tuples sorted by the quality with some additional accessor methods).\n\n    The second parameter can be a subclass of :class:`Accept` that is created\n    with the parsed values and returned.\n\n    :param value: the accept header string to be parsed.\n    :param cls: the wrapper class for the return value (can be\n                         :class:`Accept` or a subclass thereof)\n    :return: an instance of `cls`.\n    '
    if (cls is None):
        cls = Accept
    if (not value):
        return cls(None)
    result = []
    for match in _accept_re.finditer(value):
        quality = match.group(2)
        if (not quality):
            quality = 1
        else:
            quality = max(min(float(quality), 1), 0)
        result.append((match.group(1), quality))
    return cls(result)

dataset/ETHPy150Open Eforcers/gae-flask-todo/lib/werkzeug/http.py parse_accept_header/original