pamqp.decode

Functions for decoding data of various types including field tables and arrays

pamqp.decode.by_type(value, data_type, offset=0)[source]

Decodes values using the specified type

Parameters
  • value (bytes) – The binary value to decode

  • data_type (str) – The data type name of the value

  • offset (int) – The starting position of the data in the byte stream

Return type

tuple (int, pamqp.common.FieldValue)

Raises

ValueError – when the data type is unknown

pamqp.decode.bit(value, position)[source]

Decode a bit value, returning bytes consumed and the value.

Parameters
  • value (bytes) – The binary value to decode

  • position (int) – The position in the byte of the bit value

Return type

tuple (int, bool)

Raises

ValueError – when the binary data can not be unpacked

pamqp.decode.boolean(value)[source]

Decode a boolean value, returning bytes consumed and the value.

Parameters

value (bytes) – The binary value to decode

Return type

tuple (int, bool)

Raises

ValueError – when the binary data can not be unpacked

pamqp.decode.byte_array(value)[source]

Decode a byte_array value, returning bytes consumed and the value.

Parameters

value (bytes) – The binary value to decode

Return type

tuple (int, bytearray)

Raises

ValueError – when the binary data can not be unpacked

pamqp.decode.decimal(value)[source]

Decode a decimal value, returning bytes consumed and the value.

Parameters

value (bytes) – The binary value to decode

Return type

tuple (int, decimal.Decimal)

Raises

ValueError – when the binary data can not be unpacked

pamqp.decode.double(value)[source]

Decode a double value, returning bytes consumed and the value.

Parameters

value (bytes) – The binary value to decode

Return type

tuple (int, float)

Raises

ValueError – when the binary data can not be unpacked

pamqp.decode.floating_point(value)[source]

Decode a floating point value, returning bytes consumed and the value.

Parameters

value (bytes) – The binary value to decode

Return type

tuple (int, float)

Raises

ValueError – when the binary data can not be unpacked

pamqp.decode.long_int(value)[source]

Decode a long integer value, returning bytes consumed and the value.

Parameters

value (bytes) – The binary value to decode

Return type

tuple (int, int)

Raises

ValueError – when the binary data can not be unpacked

pamqp.decode.long_uint(value)[source]

Decode an unsigned long integer value, returning bytes consumed and the value.

Parameters

value (bytes) – The binary value to decode

Return type

tuple (int, int)

Raises

ValueError – when the binary data can not be unpacked

pamqp.decode.long_long_int(value)[source]

Decode a long-long integer value, returning bytes consumed and the value.

Parameters

value (bytes) – The binary value to decode

Return type

tuple (int, int)

Raises

ValueError – when the binary data can not be unpacked

pamqp.decode.long_str(value)[source]

Decode a string value, returning bytes consumed and the value.

Parameters

value (bytes) – The binary value to decode

Return type

tuple (int, str)

Raises

ValueError – when the binary data can not be unpacked

pamqp.decode.octet(value)[source]

Decode an octet value, returning bytes consumed and the value.

Parameters

value (bytes) – The binary value to decode

Return type

tuple (int, int)

Raises

ValueError – when the binary data can not be unpacked

pamqp.decode.short_int(value)[source]

Decode a short integer value, returning bytes consumed and the value.

Parameters

value (bytes) – The binary value to decode

Return type

tuple (int, int)

Raises

ValueError – when the binary data can not be unpacked

pamqp.decode.short_uint(value)[source]

Decode an unsigned short integer value, returning bytes consumed and the value.

Parameters

value (bytes) – The binary value to decode

Return type

tuple (int, int)

Raises

ValueError – when the binary data can not be unpacked

pamqp.decode.short_short_int(value)[source]

Decode a short-short integer value, returning bytes consumed and the value.

Parameters

value (bytes) – The binary value to decode

Return type

tuple (int, int)

Raises

ValueError – when the binary data can not be unpacked

pamqp.decode.short_short_uint(value)[source]

Decode a unsigned short-short integer value, returning bytes consumed and the value.

Parameters

value (bytes) – The binary value to decode

Return type

tuple (int, int)

Raises

ValueError – when the binary data can not be unpacked

pamqp.decode.short_str(value)[source]

Decode a string value, returning bytes consumed and the value.

Parameters

value (bytes) – The binary value to decode

Return type

tuple (int, str)

Raises

ValueError – when the binary data can not be unpacked

pamqp.decode.timestamp(value)[source]

Decode a timestamp value, returning bytes consumed and the value.

Parameters

value (bytes) – The binary value to decode

Return type

tuple (int, datetime.datetime)

Raises

ValueError – when the binary data can not be unpacked

pamqp.decode.embedded_value(value)[source]

Dynamically decode a value based upon the starting byte

Parameters

value (bytes) – The binary value to decode

Return type

tuple (int, pamqp.common.FieldValue)

Raises

ValueError – when the binary data can not be unpacked

pamqp.decode.field_array(value)[source]

Decode a field array value, returning bytes consumed and the value.

Parameters

value (bytes) – The binary value to decode

Return type

tuple (int, pamqp.common.FieldArray)

Raises

ValueError – when the binary data can not be unpacked

pamqp.decode.field_table(value)[source]

Decode a field array value, returning bytes consumed and the value.

Parameters

value (bytes) – The binary value to decode

Return type

tuple (int, pamqp.common.FieldTable)

Raises

ValueError – when the binary data can not be unpacked

pamqp.decode.void(_)[source]

Return a void, no data to decode

Parameters
  • _ (bytes) – The empty bytes object to ignore

  • _

Return type

tuple (int, None)