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

Public Member Functions

def __init__ (self, choices, case_sensitive=True)
 
def get_metavar (self, param)
 
def get_missing_message (self, param)
 
def convert (self, value, param, ctx)
 
def __repr__ (self)
 
- Public Member Functions inherited from ParamType
def __call__ (self, value, param=None, ctx=None)
 
def split_envvar_value (self, rv)
 
def fail (self, message, param=None, ctx=None)
 

Data Fields

 choices
 
 case_sensitive
 

Static Public Attributes

string name = "choice"
 
- Static Public Attributes inherited from ParamType
bool is_composite = False
 
 name = None
 
 envvar_list_splitter = None
 

Detailed Description

The choice type allows a value to be checked against a fixed set
of supported values. All of these values have to be strings.

You should only pass a list or tuple of choices. Other iterables
(like generators) may lead to surprising results.

The resulting value will always be one of the originally passed choices
regardless of ``case_sensitive`` or any ``ctx.token_normalize_func``
being specified.

See :ref:`choice-opts` for an example.

:param case_sensitive: Set to false to make choices case
    insensitive. Defaults to true.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  choices,
  case_sensitive = True 
)

Member Function Documentation

◆ __repr__()

def __repr__ (   self)

◆ convert()

def convert (   self,
  value,
  param,
  ctx 
)
Converts the value.  This is not invoked for values that are
`None` (the missing value).

Reimplemented from ParamType.

◆ get_metavar()

def get_metavar (   self,
  param 
)
Returns the metavar default for this param if it provides one.

Reimplemented from ParamType.

◆ get_missing_message()

def get_missing_message (   self,
  param 
)
Optionally might return extra information about a missing
parameter.

.. versionadded:: 2.0

Reimplemented from ParamType.

Field Documentation

◆ case_sensitive

case_sensitive

◆ choices

choices

◆ name

string name = "choice"
static

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