Package ganeti :: Module outils
[hide private]
[frames] | no frames]

Module outils

source code

Module for object related utils.

Classes [hide private]
  AutoSlots
Meta base class for __slots__ definitions.
  ValidatedSlots
Sets and validates slots.
Functions [hide private]
 
ContainerToDicts(container)
Convert the elements of a container to standard Python types.
source code
 
ContainerFromDicts(source, c_type, e_type)
Convert a container from standard python types.
source code
Variables [hide private]
  _SEQUENCE_TYPES = list, tuple, set, frozenset
Supported container types for serialization/de-serialization (must be a tuple as it's used as a parameter for isinstance)
Function Details [hide private]

ContainerToDicts(container)

source code 

Convert the elements of a container to standard Python types.

This method converts a container with elements to standard Python types. If the input container is of the type dict, only its values are touched. Those values, as well as all elements of input sequences, must support a ToDict method returning a serialized version.

Parameters:

ContainerFromDicts(source, c_type, e_type)

source code 

Convert a container from standard python types.

This method converts a container with standard Python types to objects. If the container is a dict, we don't touch the keys, only the values.

Parameters:
  • source (None, dict or sequence (see _SEQUENCE_TYPES)) - Input data
  • c_type (type class) - Desired type for returned container
  • e_type (element type class) - Item type for elements in returned container (must have a FromDict class method)