OpenQuizz
Une application de gestion des contenus pédagogiques
flask_restplus.utils Namespace Reference

Functions

def merge (first, second)
 
def camel_to_dash (value)
 
def default_id (resource, method)
 
def not_none (data)
 
def not_none_sorted (data)
 
def unpack (response, default_code=HTTPStatus.OK)
 

Variables

 FIRST_CAP_RE = re.compile('(.)([A-Z][a-z]+)')
 
 ALL_CAP_RE = re.compile('([a-z0-9])([A-Z])')
 

Function Documentation

◆ camel_to_dash()

def flask_restplus.utils.camel_to_dash (   value)
Transform a CamelCase string into a low_dashed one

:param str value: a CamelCase string to transform
:return: the low_dashed string
:rtype: str

◆ default_id()

def flask_restplus.utils.default_id (   resource,
  method 
)
Default operation ID generator

◆ merge()

def flask_restplus.utils.merge (   first,
  second 
)
Recursively merges two dictionnaries.

Second dictionnary values will take precedance over those from the first one.
Nested dictionnaries are merged too.

:param dict first: The first dictionnary
:param dict second: The second dictionnary
:return: the resulting merged dictionnary
:rtype: dict

◆ not_none()

def flask_restplus.utils.not_none (   data)
Remove all keys where value is None

:param dict data: A dictionnary with potentialy some values set to None
:return: The same dictionnary without the keys with values to ``None``
:rtype: dict

◆ not_none_sorted()

def flask_restplus.utils.not_none_sorted (   data)
Remove all keys where value is None

:param OrderedDict data: A dictionnary with potentialy some values set to None
:return: The same dictionnary without the keys with values to ``None``
:rtype: OrderedDict

◆ unpack()

def flask_restplus.utils.unpack (   response,
  default_code = HTTPStatus.OK 
)
Unpack a Flask standard response.

Flask response can be:
- a single value
- a 2-tuple ``(value, code)``
- a 3-tuple ``(value, code, headers)``

.. warning::

    When using this function, you must ensure that the tuple is not the reponse data.
    To do so, prefer returning list instead of tuple for listings.

:param response: A Flask style response
:param int default_code: The HTTP code to use as default if none is provided
:return: a 3-tuple ``(data, code, headers)``
:rtype: tuple
:raise ValueError: if the response does not have one of the expected format

Variable Documentation

◆ ALL_CAP_RE

ALL_CAP_RE = re.compile('([a-z0-9])([A-Z])')

◆ FIRST_CAP_RE

FIRST_CAP_RE = re.compile('(.)([A-Z][a-z]+)')