fsleyes_props.serialise
This module provides functions for serialising and deserialising the values
of most fsleyes_props
property types (which are defined in
properties_types
).
This module only contains logic for those property types that the default
python conversion routines would not be able to handle. For example, an
Int
property value can be serialised with str
, and deserialised
with int
. Such logic is already built into the Int
class, so there
is no need for this module to duplicate it.
An example of where specific serialisation/deserialisation logic is useful is
the Boolean
property. Passing a boolean value,``True`` or False
to the str
function will result in a string 'True'
or
'False'
. However, passing a string 'True'
or 'False'
to the
bool
function will result in True
in both cases.
The logic needed to safely serialise/deserialise Boolean
values, and
other property types for which it is needed, is provided by this module.
- fsleyes_props.serialise.DELIMITER = '#'
Delimiter string used to join multi-valued properties.
- fsleyes_props.serialise.serialise(hasProps, propName)[source]
Get the value of the named property from the given
HasProperties
instance, serialise it, and return the serialised string.
- fsleyes_props.serialise.deserialise(hasProps, propName, string)[source]
Deserialise the given string, under the assumption that it is a serialised value of the named property from the given
HasProperties
instance.