rsb.converter

A module containing various converter implementations as well as logic for registering and selecting them.

Code author: jmoringe

Code author: jwienke

Code author: plueckin

Functions

getGlobalConverterMap(wireType) Get a map with all globally known converters for the wireType.
makeStructBasedConverter(name, dataType, …)
registerGlobalConverter(converter[, …]) Register converter as a globally available converter.

Classes

BoolConverter()
ByteArrayConverter() A converter which just passes through the original byte array of a message.
BytesConverter([wireSchema, dataType]) Handles byte arrays.
Converter(wireType, dataType, wireSchema) Base class for converters to a certain target type.
ConverterMap(wireType) A class managing converters for for a certain target type.
ConverterSelectionStrategy This class defines the interface for converter selection strategy classes.
DoubleConverter()
EventsByScopeMapConverter([converterRepository]) A converter for aggregated events ordered by their scope and time for each scope.
FloatConverter()
IdentityConverter() This converter does nothing.
Int32Converter()
Int64Converter()
NoneConverter() This converter produces a serialized value that represents instances of NoneType.
PredicateConverterList(wireType) Objects of this class are used to perform converter selection via a chain-of-responsibility strategy.
ProtocolBufferConverter(messageClass) This converter serializes and deserializes objects of protocol buffer data-holder classes.
SchemaAndByteArrayConverter() A converter which passes through the wireSchema as well as the original byte array of a message.
ScopeConverter() (De)serializes Scope objects.
StringConverter([wireSchema, dataType, encoding]) A converter that serializes strings to bytearrays with a specified
Uint32Converter()
Uint64Converter()
UnambiguousConverterMap(wireType)

Exceptions

UnknownConverterError(sourceType, wireSchema)

Code author: jwienke

exception rsb.converter.UnknownConverterError(sourceType, wireSchema)

Bases: exceptions.KeyError

Code author: jwienke

args
message
class rsb.converter.BoolConverter

Bases: rsb.converter.Converter

deserialize(inp, wireSchema)
getDataType()

Returns the data type this converter is applicable for.

Returns:A type object.
Return type:types.TypeType
getWireSchema()

Returns the name of the wire schema this converter can (de)serialize from/to.

Returns:A string designating the wire schema from/to this converter can (de)serialize
Return type:str
getWireType()

Returns the type of the wire-type to/from this converter serializes/deserializes.

Returns:A type object.
Return type:types.TypeType
serialize(inp)
dataType

Returns the data type this converter is applicable for.

Returns:A type object.
Return type:types.TypeType
wireSchema

Returns the name of the wire schema this converter can (de)serialize from/to.

Returns:A string designating the wire schema from/to this converter can (de)serialize
Return type:str
wireType

Returns the type of the wire-type to/from this converter serializes/deserializes.

Returns:A type object.
Return type:types.TypeType
class rsb.converter.ByteArrayConverter

Bases: rsb.converter.Converter

A converter which just passes through the original byte array of a message.

Code author: jwienke

deserialize(data, wireSchema)
getDataType()

Returns the data type this converter is applicable for.

Returns:A type object.
Return type:types.TypeType
getWireSchema()

Returns the name of the wire schema this converter can (de)serialize from/to.

Returns:A string designating the wire schema from/to this converter can (de)serialize
Return type:str
getWireType()

Returns the type of the wire-type to/from this converter serializes/deserializes.

Returns:A type object.
Return type:types.TypeType
serialize(data)
dataType

Returns the data type this converter is applicable for.

Returns:A type object.
Return type:types.TypeType
wireSchema

Returns the name of the wire schema this converter can (de)serialize from/to.

Returns:A string designating the wire schema from/to this converter can (de)serialize
Return type:str
wireType

Returns the type of the wire-type to/from this converter serializes/deserializes.

Returns:A type object.
Return type:types.TypeType
class rsb.converter.BytesConverter(wireSchema='bytes', dataType=<type 'bytearray'>)

Bases: rsb.converter.Converter

Handles byte arrays.

Code author: jmoringe

deserialize(inp, wireSchema)
getDataType()

Returns the data type this converter is applicable for.

Returns:A type object.
Return type:types.TypeType
getWireSchema()

Returns the name of the wire schema this converter can (de)serialize from/to.

Returns:A string designating the wire schema from/to this converter can (de)serialize
Return type:str
getWireType()

Returns the type of the wire-type to/from this converter serializes/deserializes.

Returns:A type object.
Return type:types.TypeType
serialize(inp)
dataType

Returns the data type this converter is applicable for.

Returns:A type object.
Return type:types.TypeType
wireSchema

Returns the name of the wire schema this converter can (de)serialize from/to.

Returns:A string designating the wire schema from/to this converter can (de)serialize
Return type:str
wireType

Returns the type of the wire-type to/from this converter serializes/deserializes.

Returns:A type object.
Return type:types.TypeType
class rsb.converter.Converter(wireType, dataType, wireSchema)

Bases: object

Base class for converters to a certain target type.

Code author: jwienke

Constructor.

Parameters:
  • wireType (types.TypeType) – Python type to/from which the converter serializes/deserializes
  • dataType (types.TypeType) – Python type of data accepted by the converter for serialization (also Python type of deserialized data)
  • wireSchema (str) – Wire-schema understood by the converter when deserializing (also wire-schema of data serialized with the converter)
deserialize(inp, wireSchema)
getDataType()

Returns the data type this converter is applicable for.

Returns:A type object.
Return type:types.TypeType
getWireSchema()

Returns the name of the wire schema this converter can (de)serialize from/to.

Returns:A string designating the wire schema from/to this converter can (de)serialize
Return type:str
getWireType()

Returns the type of the wire-type to/from this converter serializes/deserializes.

Returns:A type object.
Return type:types.TypeType
serialize(inp)
dataType

Returns the data type this converter is applicable for.

Returns:A type object.
Return type:types.TypeType
wireSchema

Returns the name of the wire schema this converter can (de)serialize from/to.

Returns:A string designating the wire schema from/to this converter can (de)serialize
Return type:str
wireType

Returns the type of the wire-type to/from this converter serializes/deserializes.

Returns:A type object.
Return type:types.TypeType
class rsb.converter.ConverterMap(wireType)

Bases: rsb.converter.ConverterSelectionStrategy

A class managing converters for for a certain target type.

Code author: jwienke

addConverter(converter, replaceExisting=False)
getConverterForDataType(dataType)
getConverterForWireSchema(wireSchema)
getConverters()
getWireType()
hasConverterForDataType(dataType)
hasConverterForWireSchema(wireSchema)
class rsb.converter.ConverterSelectionStrategy

Bases: object

This class defines the interface for converter selection strategy classes.

Code author: jmoringe

getConverterForDataType(dataType)
getConverterForWireSchema(wireSchema)
hasConverterForDataType(dataType)
hasConverterForWireSchema(wireSchema)
class rsb.converter.DoubleConverter

Bases: rsb.converter.Converter

deserialize(inp, wireSchema)
getDataType()

Returns the data type this converter is applicable for.

Returns:A type object.
Return type:types.TypeType
getWireSchema()

Returns the name of the wire schema this converter can (de)serialize from/to.

Returns:A string designating the wire schema from/to this converter can (de)serialize
Return type:str
getWireType()

Returns the type of the wire-type to/from this converter serializes/deserializes.

Returns:A type object.
Return type:types.TypeType
serialize(inp)
dataType

Returns the data type this converter is applicable for.

Returns:A type object.
Return type:types.TypeType
wireSchema

Returns the name of the wire schema this converter can (de)serialize from/to.

Returns:A string designating the wire schema from/to this converter can (de)serialize
Return type:str
wireType

Returns the type of the wire-type to/from this converter serializes/deserializes.

Returns:A type object.
Return type:types.TypeType
class rsb.converter.EventsByScopeMapConverter(converterRepository=<rsb.converter.ConverterMap object>)

Bases: rsb.converter.Converter

A converter for aggregated events ordered by their scope and time for each scope. As a client data type dictionaries are used. Think about this when you register the converter and also have other dictionaries to transmit.

Code author: jwienke

deserialize(wire, wireSchema)
getDataType()

Returns the data type this converter is applicable for.

Returns:A type object.
Return type:types.TypeType
getWireSchema()

Returns the name of the wire schema this converter can (de)serialize from/to.

Returns:A string designating the wire schema from/to this converter can (de)serialize
Return type:str
getWireType()

Returns the type of the wire-type to/from this converter serializes/deserializes.

Returns:A type object.
Return type:types.TypeType
serialize(data)
dataType

Returns the data type this converter is applicable for.

Returns:A type object.
Return type:types.TypeType
wireSchema

Returns the name of the wire schema this converter can (de)serialize from/to.

Returns:A string designating the wire schema from/to this converter can (de)serialize
Return type:str
wireType

Returns the type of the wire-type to/from this converter serializes/deserializes.

Returns:A type object.
Return type:types.TypeType
class rsb.converter.FloatConverter

Bases: rsb.converter.Converter

deserialize(inp, wireSchema)
getDataType()

Returns the data type this converter is applicable for.

Returns:A type object.
Return type:types.TypeType
getWireSchema()

Returns the name of the wire schema this converter can (de)serialize from/to.

Returns:A string designating the wire schema from/to this converter can (de)serialize
Return type:str
getWireType()

Returns the type of the wire-type to/from this converter serializes/deserializes.

Returns:A type object.
Return type:types.TypeType
serialize(inp)
dataType

Returns the data type this converter is applicable for.

Returns:A type object.
Return type:types.TypeType
wireSchema

Returns the name of the wire schema this converter can (de)serialize from/to.

Returns:A string designating the wire schema from/to this converter can (de)serialize
Return type:str
wireType

Returns the type of the wire-type to/from this converter serializes/deserializes.

Returns:A type object.
Return type:types.TypeType
class rsb.converter.IdentityConverter

Bases: rsb.converter.Converter

This converter does nothing. Use it in combination with the “AlwaysApplicable”-wireSchema.

Code author: plueckin

AlwaysApplicable()
deserialize(inp, wireSchema)
getDataType()

Returns the data type this converter is applicable for.

Returns:A type object.
Return type:types.TypeType
getWireSchema()

Returns the name of the wire schema this converter can (de)serialize from/to.

Returns:A string designating the wire schema from/to this converter can (de)serialize
Return type:str
getWireType()

Returns the type of the wire-type to/from this converter serializes/deserializes.

Returns:A type object.
Return type:types.TypeType
serialize(inp)
dataType

Returns the data type this converter is applicable for.

Returns:A type object.
Return type:types.TypeType
wireSchema

Returns the name of the wire schema this converter can (de)serialize from/to.

Returns:A string designating the wire schema from/to this converter can (de)serialize
Return type:str
wireType

Returns the type of the wire-type to/from this converter serializes/deserializes.

Returns:A type object.
Return type:types.TypeType
class rsb.converter.Int32Converter

Bases: rsb.converter.Converter

deserialize(inp, wireSchema)
getDataType()

Returns the data type this converter is applicable for.

Returns:A type object.
Return type:types.TypeType
getWireSchema()

Returns the name of the wire schema this converter can (de)serialize from/to.

Returns:A string designating the wire schema from/to this converter can (de)serialize
Return type:str
getWireType()

Returns the type of the wire-type to/from this converter serializes/deserializes.

Returns:A type object.
Return type:types.TypeType
serialize(inp)
dataType

Returns the data type this converter is applicable for.

Returns:A type object.
Return type:types.TypeType
wireSchema

Returns the name of the wire schema this converter can (de)serialize from/to.

Returns:A string designating the wire schema from/to this converter can (de)serialize
Return type:str
wireType

Returns the type of the wire-type to/from this converter serializes/deserializes.

Returns:A type object.
Return type:types.TypeType
class rsb.converter.Int64Converter

Bases: rsb.converter.Converter

deserialize(inp, wireSchema)
getDataType()

Returns the data type this converter is applicable for.

Returns:A type object.
Return type:types.TypeType
getWireSchema()

Returns the name of the wire schema this converter can (de)serialize from/to.

Returns:A string designating the wire schema from/to this converter can (de)serialize
Return type:str
getWireType()

Returns the type of the wire-type to/from this converter serializes/deserializes.

Returns:A type object.
Return type:types.TypeType
serialize(inp)
dataType

Returns the data type this converter is applicable for.

Returns:A type object.
Return type:types.TypeType
wireSchema

Returns the name of the wire schema this converter can (de)serialize from/to.

Returns:A string designating the wire schema from/to this converter can (de)serialize
Return type:str
wireType

Returns the type of the wire-type to/from this converter serializes/deserializes.

Returns:A type object.
Return type:types.TypeType
class rsb.converter.NoneConverter

Bases: rsb.converter.Converter

This converter produces a serialized value that represents instances of NoneType.

Such a converter is required for serializing “results” of RPC calls that do not return a value.

Code author: jmoringe

deserialize(inp, wireSchema)
getDataType()

Returns the data type this converter is applicable for.

Returns:A type object.
Return type:types.TypeType
getWireSchema()

Returns the name of the wire schema this converter can (de)serialize from/to.

Returns:A string designating the wire schema from/to this converter can (de)serialize
Return type:str
getWireType()

Returns the type of the wire-type to/from this converter serializes/deserializes.

Returns:A type object.
Return type:types.TypeType
serialize(inp)
dataType

Returns the data type this converter is applicable for.

Returns:A type object.
Return type:types.TypeType
wireSchema

Returns the name of the wire schema this converter can (de)serialize from/to.

Returns:A string designating the wire schema from/to this converter can (de)serialize
Return type:str
wireType

Returns the type of the wire-type to/from this converter serializes/deserializes.

Returns:A type object.
Return type:types.TypeType
class rsb.converter.PredicateConverterList(wireType)

Bases: rsb.converter.ConverterMap

Objects of this class are used to perform converter selection via a chain-of-responsibility strategy.

A list of predicates and associated converters is maintained. Converter selection queries are processed by traversing the list and selected the first converter the associated predicate of which matches the query wire-schema or data-type.

Code author: jmoringe

addConverter(converter, wireSchemaPredicate=None, dataTypePredicate=None, replaceExisting=True)
getConverterForDataType(dataType)
getConverterForWireSchema(wireSchema)
getConverters()
getWireType()
hasConverterForDataType(dataType)
hasConverterForWireSchema(wireSchema)
class rsb.converter.ProtocolBufferConverter(messageClass)

Bases: rsb.converter.Converter

This converter serializes and deserializes objects of protocol buffer data-holder classes.

These data-holder classes are generated by the protocol buffer compiler protoc.

Code author: jmoringe

deserialize(inp, wireSchema)
getDataType()

Returns the data type this converter is applicable for.

Returns:A type object.
Return type:types.TypeType
getMessageClass()
getMessageClassName()
getWireSchema()

Returns the name of the wire schema this converter can (de)serialize from/to.

Returns:A string designating the wire schema from/to this converter can (de)serialize
Return type:str
getWireType()

Returns the type of the wire-type to/from this converter serializes/deserializes.

Returns:A type object.
Return type:types.TypeType
serialize(inp)
dataType

Returns the data type this converter is applicable for.

Returns:A type object.
Return type:types.TypeType
messageClass
wireSchema

Returns the name of the wire schema this converter can (de)serialize from/to.

Returns:A string designating the wire schema from/to this converter can (de)serialize
Return type:str
wireType

Returns the type of the wire-type to/from this converter serializes/deserializes.

Returns:A type object.
Return type:types.TypeType
class rsb.converter.SchemaAndByteArrayConverter

Bases: rsb.converter.Converter

A converter which passes through the wireSchema as well as the original byte array of a message.

Code author: nkoester

deserialize(data, wireSchema)
getDataType()

Returns the data type this converter is applicable for.

Returns:A type object.
Return type:types.TypeType
getWireSchema()

Returns the name of the wire schema this converter can (de)serialize from/to.

Returns:A string designating the wire schema from/to this converter can (de)serialize
Return type:str
getWireType()

Returns the type of the wire-type to/from this converter serializes/deserializes.

Returns:A type object.
Return type:types.TypeType
serialize(data)
dataType

Returns the data type this converter is applicable for.

Returns:A type object.
Return type:types.TypeType
wireSchema

Returns the name of the wire schema this converter can (de)serialize from/to.

Returns:A string designating the wire schema from/to this converter can (de)serialize
Return type:str
wireType

Returns the type of the wire-type to/from this converter serializes/deserializes.

Returns:A type object.
Return type:types.TypeType
class rsb.converter.ScopeConverter

Bases: rsb.converter.Converter

(De)serializes Scope objects.

Code author: jmoringe

deserialize(inp, wireSchema)
getDataType()

Returns the data type this converter is applicable for.

Returns:A type object.
Return type:types.TypeType
getWireSchema()

Returns the name of the wire schema this converter can (de)serialize from/to.

Returns:A string designating the wire schema from/to this converter can (de)serialize
Return type:str
getWireType()

Returns the type of the wire-type to/from this converter serializes/deserializes.

Returns:A type object.
Return type:types.TypeType
serialize(inp)
dataType

Returns the data type this converter is applicable for.

Returns:A type object.
Return type:types.TypeType
wireSchema

Returns the name of the wire schema this converter can (de)serialize from/to.

Returns:A string designating the wire schema from/to this converter can (de)serialize
Return type:str
wireType

Returns the type of the wire-type to/from this converter serializes/deserializes.

Returns:A type object.
Return type:types.TypeType
class rsb.converter.StringConverter(wireSchema='utf-8-string', dataType=<type 'unicode'>, encoding='utf_8')

Bases: rsb.converter.Converter

A converter that serializes strings to bytearrays with a specified encoding

Code author: jwienke

deserialize(inp, wireSchema)
getDataType()

Returns the data type this converter is applicable for.

Returns:A type object.
Return type:types.TypeType
getWireSchema()

Returns the name of the wire schema this converter can (de)serialize from/to.

Returns:A string designating the wire schema from/to this converter can (de)serialize
Return type:str
getWireType()

Returns the type of the wire-type to/from this converter serializes/deserializes.

Returns:A type object.
Return type:types.TypeType
serialize(inp)
dataType

Returns the data type this converter is applicable for.

Returns:A type object.
Return type:types.TypeType
wireSchema

Returns the name of the wire schema this converter can (de)serialize from/to.

Returns:A string designating the wire schema from/to this converter can (de)serialize
Return type:str
wireType

Returns the type of the wire-type to/from this converter serializes/deserializes.

Returns:A type object.
Return type:types.TypeType
class rsb.converter.Uint32Converter

Bases: rsb.converter.Converter

deserialize(inp, wireSchema)
getDataType()

Returns the data type this converter is applicable for.

Returns:A type object.
Return type:types.TypeType
getWireSchema()

Returns the name of the wire schema this converter can (de)serialize from/to.

Returns:A string designating the wire schema from/to this converter can (de)serialize
Return type:str
getWireType()

Returns the type of the wire-type to/from this converter serializes/deserializes.

Returns:A type object.
Return type:types.TypeType
serialize(inp)
dataType

Returns the data type this converter is applicable for.

Returns:A type object.
Return type:types.TypeType
wireSchema

Returns the name of the wire schema this converter can (de)serialize from/to.

Returns:A string designating the wire schema from/to this converter can (de)serialize
Return type:str
wireType

Returns the type of the wire-type to/from this converter serializes/deserializes.

Returns:A type object.
Return type:types.TypeType
class rsb.converter.Uint64Converter

Bases: rsb.converter.Converter

deserialize(inp, wireSchema)
getDataType()

Returns the data type this converter is applicable for.

Returns:A type object.
Return type:types.TypeType
getWireSchema()

Returns the name of the wire schema this converter can (de)serialize from/to.

Returns:A string designating the wire schema from/to this converter can (de)serialize
Return type:str
getWireType()

Returns the type of the wire-type to/from this converter serializes/deserializes.

Returns:A type object.
Return type:types.TypeType
serialize(inp)
dataType

Returns the data type this converter is applicable for.

Returns:A type object.
Return type:types.TypeType
wireSchema

Returns the name of the wire schema this converter can (de)serialize from/to.

Returns:A string designating the wire schema from/to this converter can (de)serialize
Return type:str
wireType

Returns the type of the wire-type to/from this converter serializes/deserializes.

Returns:A type object.
Return type:types.TypeType
class rsb.converter.UnambiguousConverterMap(wireType)

Bases: rsb.converter.ConverterMap

addConverter(converter, replaceExisting=False)
getConverterForDataType(dataType)
getConverterForWireSchema(wireSchema)
getConverters()
getWireType()
hasConverterForDataType(dataType)
hasConverterForWireSchema(wireSchema)
rsb.converter.getGlobalConverterMap(wireType)

Get a map with all globally known converters for the wireType.

Parameters:wireType (types.TypeType) – Python type for designating the wire-type.
Returns:converter map constantly updated
rsb.converter.makeStructBasedConverter(name, dataType, wireSchema, fmt, size)
rsb.converter.registerGlobalConverter(converter, replaceExisting=False)

Register converter as a globally available converter.

Parameters:
  • converter – converter to register
  • replaceExisting – controls whether an existing converter for the same data-type and/or wire-type should be replaced by the new converter. If this is False and such a converter exists, an error is raised.