pamqp.encode¶
AMQP Data Encoder¶
Functions for encoding data of various types including field tables and arrays
-
pamqp.encode.bit(value, byte, position)¶ 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)¶ Encode a boolean value.
Parameters: value (bool) – Value to encode Return type: bytes
-
pamqp.encode.by_type(value, data_type)¶ 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)¶ Encode a bytearray
Parameters: value (bytearray) – Value to encode Return type: bytes
-
pamqp.encode.decimal(value)¶ Encode a decimal.Decimal value.
Parameters: value (decimal.Decimal) – Value to encode Return type: bytes
-
pamqp.encode.double(value)¶ Encode a floating point value as a double
Parameters: value (float) – Value to encode Return type: str
-
pamqp.encode.encode_table_value(value)¶ 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)¶ Encode a field array from a dictionary.
Parameters: value (list) – Value to encode Return type: bytes Raises: TypeError
-
pamqp.encode.field_table(value)¶ 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)¶ Encode a floating point value.
Parameters: value (float) – Value to encode Return type: bytes
-
pamqp.encode.long_int(value)¶ Encode a long integer.
Parameters: value (int) – Value to encode Return type: bytes
-
pamqp.encode.long_long_int(value)¶ Encode a long-long int.
Parameters: or int value (long) – Value to encode Return type: bytes
-
pamqp.encode.long_string(value)¶ Encode a “long string” which the specific defines as any non-null data. We will auto-convert str and unicode to bytes but ignore bytes objects and place them opaquely.
Parameters: value (bytes or str or unicode) – Value to encode Return type: bytes Raises: TypeError
-
pamqp.encode.long_uint(value)¶ Encode a long integer.
Parameters: value (int) – Value to encode Return type: bytes
-
pamqp.encode.octet(value)¶ Encode an octet value.
Parameters: value – Value to encode Return type: bytes Raises: TypeError
-
pamqp.encode.short_int(value)¶ Encode a short integer.
Parameters: value (int) – Value to encode Return type: bytes Raises: TypeError
-
pamqp.encode.short_string(value)¶ Encode a string.
Parameters: value (bytes or str or unicode) – Value to encode Return type: bytes Raises: TypeError
-
pamqp.encode.short_uint(value)¶ Encode an unsigned short integer.
Parameters: value (int) – Value to encode Return type: bytes Raises: TypeError
-
pamqp.encode.support_deprecated_rabbitmq()¶ Invoke to restrict the data types available in field-tables that are sent to RabbitMQ.
-
pamqp.encode.table_integer(value)¶ Determines the best type of numeric type to encode value as, preferring the smallest data size first.
Parameters: value (int) – Value to encode Return type: bytes Raises: TypeError
-
pamqp.encode.timestamp(value)¶ Encode a datetime.datetime object or time.struct_time.
Parameters: value (datetime.datetime, time.struct_time, integer) – Value to encode Return type: bytes Raises: TypeError