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

Public Member Functions

def __init__ (self, mask=None, skip=False, **kwargs)
 
def parse (self, mask)
 
def clean (self, mask)
 
def apply (self, data)
 
def filter_data (self, data)
 
def __str__ (self)
 

Data Fields

 skip
 

Detailed Description

Hold a parsed mask.

:param str|dict|Mask mask: A mask, parsed or not
:param bool skip: If ``True``, missing fields won't appear in result

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  mask = None,
  skip = False,
**  kwargs 
)

Member Function Documentation

◆ __str__()

def __str__ (   self)

◆ apply()

def apply (   self,
  data 
)
Apply a fields mask to the data.

:param data: The data or model to apply mask on
:raises MaskError: when unable to apply the mask

◆ clean()

def clean (   self,
  mask 
)
Remove unecessary characters

◆ filter_data()

def filter_data (   self,
  data 
)
Handle the data filtering given a parsed mask

:param dict data: the raw data to filter
:param list mask: a parsed mask tofilter against
:param bool skip: whether or not to skip missing fields

◆ parse()

def parse (   self,
  mask 
)
Parse a fields mask.
Expect something in the form::

    {field,nested{nested_field,another},last}

External brackets are optionals so it can also be written::

    field,nested{nested_field,another},last

All extras characters will be ignored.

:param str mask: the mask string to parse
:raises ParseError: when a mask is unparseable/invalid

Field Documentation

◆ skip

skip

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