@classmethod
def from_string(cls, value):
    """Return single instance parsed from given accept header string."""
    match = cls.pattern.search(value)
    if match is None:
        raise ValueError('"%s" is not a valid media type' % value)
    try:
        return cls(match.group('mime_type'), float(match.group('weight') or 1))
    except ValueError:
        return cls(value)
