class documentation

class LanguageAccept(Accept): (source)

View In Hierarchy

Like :class:`Accept` but with normalization for language tags.

Method best_match Given a list of supported values, finds the best match from the list of accepted values.
Method _value_matches Check if a value matches a given accept item.

Inherited from Accept:

Method __contains__ Undocumented
Method __getitem__ Besides index lookup (getting item n) you can also pass it a string to get the quality for the item. If the item is not in the list, the returned quality is ``0``.
Method __init__ Undocumented
Method __repr__ Undocumented
Method __str__ Undocumented
Method find Get the position of an entry or return -1.
Method index Get the position of an entry or raise :exc:`ValueError`.
Method quality Returns the quality of the key.
Method to_header Convert the header set into an HTTP header string.
Method values Iterate over all values.
Instance Variable provided Undocumented
Property best The best match as value.
Method _best_single_match Undocumented
Method _specificity Returns a tuple describing the value's specificity.

Inherited from ImmutableListMixin (via Accept, ImmutableList):

Method __delitem__ Undocumented
Method __hash__ Undocumented
Method __iadd__ Undocumented
Method __imul__ Undocumented
Method __reduce_ex__ Undocumented
Method __setitem__ Undocumented
Method append Undocumented
Method extend Undocumented
Method insert Undocumented
Method pop Undocumented
Method remove Undocumented
Method reverse Undocumented
Method sort Undocumented
Instance Variable _hash_cache Undocumented
def best_match(self, matches, default=None): (source)

Given a list of supported values, finds the best match from the list of accepted values. Language tags are normalized for the purpose of matching, but are returned unchanged. If no exact match is found, this will fall back to matching the first subtag (primary language only), first with the accepted values then with the match values. This partial is not applied to any other language subtags. The default is returned if no exact or fallback match is found. :param matches: A list of supported languages to find a match. :param default: The value that is returned if none match.

def _value_matches(self, value, item): (source)

Check if a value matches a given accept item.