pamqp.encode¶
AMQP Data Encoder
Functions for encoding data of various types including field tables and arrays
-
pamqp.encode.bit(value, byte, position)[source]¶ Encode a bit value
- Parameters
value (int) – Value to decode
byte (int) – The byte to apply the value to
position (int) – The position in the byte to set the bit on
- Return type
tuple of bytes used and a bool value
-
pamqp.encode.boolean(value)[source]¶ Encode a boolean value.
- Parameters
value (bool) – Value to encode
- Return type
bytes
-
pamqp.encode.by_type(value, data_type)[source]¶ Takes a value of any type and tries to encode it with the specified encoder.
- Parameters
value (any) – Value to encode
data_type (str) – type of data to encode
- Return type
bytes
- Raises
TypeError
-
pamqp.encode.byte_array(value)[source]¶ Encode a bytearray
- Parameters
value (bytearray) – Value to encode
- Return type
bytes
-
pamqp.encode.decimal(value)[source]¶ Encode a decimal.Decimal value.
- Parameters
value (decimal.Decimal) – Value to encode
- Return type
bytes
-
pamqp.encode.double(value)[source]¶ Encode a floating point value as a double
- Parameters
value (float) – Value to encode
- Return type
str
-
pamqp.encode.encode_table_value(value)[source]¶ Takes a value of any type and tries to encode it with the proper encoder
- Parameters
value (any) – Value to encode
- Return type
bytes
- Raises
TypeError
-
pamqp.encode.field_array(value)[source]¶ Encode a field array from a dictionary.
- Parameters
value (list) – Value to encode
- Return type
bytes
- Raises
TypeError
-
pamqp.encode.field_table(value)[source]¶ Encode a field table from a dictionary.
- Parameters
or None value (dict) – Value to encode
- Return type
bytes
- Raises
TypeError
-
pamqp.encode.floating_point(value)[source]¶ Encode a floating point value.
- Parameters
value (float) – Value to encode
- Return type
bytes
-
pamqp.encode.long_int(value)[source]¶ Encode a long integer.
- Parameters
value (int) – Value to encode
- Return type
bytes
-
pamqp.encode.long_long_int(value)[source]¶ Encode a long-long int.
- Parameters
or int value (long) – Value to encode
- Return type
bytes
-
pamqp.encode.long_string(value)[source]¶ Encode a string.
- Parameters
value (bytes) – Value to encode
- Return type
bytes
- Raises
TypeError
-
pamqp.encode.octet(value)[source]¶ Encode an octet value.
- Parameters
value – Value to encode
- Return type
bytes
- Raises
TypeError
-
pamqp.encode.short_int(value)[source]¶ Encode a short integer.
- Parameters
value (int) – Value to encode
- Return type
bytes
- Raises
TypeError
-
pamqp.encode.short_string(value)[source]¶ Encode a string.
- Parameters
value (str) – Value to encode
- Return type
bytes
- Raises
TypeError