OpenQuizz
Une application de gestion des contenus pédagogiques
|
Public Member Functions | |
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_match (self, matches, default=None) |
def | best (self) |
![]() | |
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) |
Data Fields | |
provided | |
Additional Inherited Members | |
![]() | |
remove | |
An :class:`Accept` object is just a list subclass for lists of ``(value, quality)`` tuples. It is automatically sorted by specificity and quality. All :class:`Accept` objects work similar to a list but provide extra functionality for working with the data. Containment checks are normalized to the rules of that header: >>> a = CharsetAccept([('ISO-8859-1', 1), ('utf-8', 0.7)]) >>> a.best 'ISO-8859-1' >>> 'iso-8859-1' in a True >>> 'UTF8' in a True >>> 'utf7' in a False To get the quality for an item you can use normal item lookup: >>> print a['utf-8'] 0.7 >>> a['utf7'] 0 .. versionchanged:: 0.5 :class:`Accept` objects are forced immutable now. .. versionchanged:: 1.0.0 :class:`Accept` internal values are no longer ordered alphabetically for equal quality tags. Instead the initial order is preserved.
def __init__ | ( | self, | |
values = () |
|||
) |
def __contains__ | ( | self, | |
value | |||
) |
def __getitem__ | ( | self, | |
key | |||
) |
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``.
def __repr__ | ( | self | ) |
Reimplemented from ImmutableList.
def __str__ | ( | self | ) |
def best | ( | self | ) |
The best match as value.
def best_match | ( | self, | |
matches, | |||
default = None |
|||
) |
Returns the best match from a list of possible matches based on the specificity and quality of the client. If two items have the same quality and specificity, the one is returned that comes first. :param matches: a list of matches to check for :param default: the value that is returned if none match
Reimplemented in LanguageAccept.
def find | ( | self, | |
key | |||
) |
Get the position of an entry or return -1. :param key: The key to be looked up.
def index | ( | self, | |
key | |||
) |
Get the position of an entry or raise :exc:`ValueError`. :param key: The key to be looked up. .. versionchanged:: 0.5 This used to raise :exc:`IndexError`, which was inconsistent with the list API.
def quality | ( | self, | |
key | |||
) |
Returns the quality of the key. .. versionadded:: 0.6 In previous versions you had to use the item-lookup syntax (eg: ``obj[key]`` instead of ``obj.quality(key)``)
def to_header | ( | self | ) |
Convert the header set into an HTTP header string.
def values | ( | self | ) |
Iterate over all values.
provided |