OpenQuizz
Une application de gestion des contenus pédagogiques
LanguageAccept Class Reference
Inheritance diagram for LanguageAccept:
Collaboration diagram for LanguageAccept:

Public Member Functions

def best_match (self, matches, default=None)
 
- Public Member Functions inherited from Accept
def __init__ (self, values=())
 
def __getitem__ (self, key)
 
def quality (self, key)
 
def __contains__ (self, value)
 
def __repr__ (self)
 
def index (self, key)
 
def find (self, key)
 
def values (self)
 
def to_header (self)
 
def __str__ (self)
 
def best (self)
 
- Public Member Functions inherited from ImmutableListMixin
def __hash__ (self)
 
def __reduce_ex__ (self, protocol)
 
def __delitem__ (self, key)
 
def __iadd__ (self, other)
 
def __setitem__ (self, key, value)
 
def append (self, item)
 
def extend (self, iterable)
 
def insert (self, pos, value)
 
def pop (self, index=-1)
 
def reverse (self)
 
def sort (self, cmp=None, key=None, reverse=None)
 

Additional Inherited Members

- Data Fields inherited from Accept
 provided
 
- Static Public Attributes inherited from ImmutableListMixin
 remove
 

Detailed Description

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

Member Function Documentation

◆ best_match()

def best_match (   self,
  matches,
  default = None 
)
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.

Reimplemented from Accept.


The documentation for this class was generated from the following file: