amqp.serialization¶
Convert between bytestreams and higher-level AMQP types.
2007-11-05 Barry Pederson <bp@barryp.org>
- class amqp.serialization.AMQPReader(source)¶
Read higher-level AMQP types from a bytestream.
- close()¶
- read(n)¶
Read n bytes.
- read_array()¶
- read_bit()¶
Read a single boolean value.
- read_float()¶
Read float value.
- read_item()¶
- read_long()¶
Read an unsigned 32-bit integer
- read_longlong()¶
Read an unsigned 64-bit integer
- read_longstr()¶
Read a string that’s up to 2**32 bytes.
The encoding isn’t specified in the AMQP spec, so assume it’s utf-8
- read_octet()¶
Read one byte, return as an integer
- read_short()¶
Read an unsigned 16-bit integer
- read_shortstr()¶
Read a short string that’s stored in up to 255 bytes.
The encoding isn’t specified in the AMQP spec, so assume it’s utf-8
- read_table()¶
Read an AMQP table, and return as a Python dictionary.
- read_timestamp()¶
Read and AMQP timestamp, which is a 64-bit integer representing seconds since the Unix epoch in 1-second resolution.
Return as a Python datetime.datetime object, expressed as localtime.
- class amqp.serialization.AMQPWriter(dest=None)¶
Convert higher-level AMQP types to bytestreams.
- close()¶
Pass through if possible to any file-like destinations.
- flush()¶
Pass through if possible to any file-like destinations.
- getvalue()¶
Get what’s been encoded so far if we’re working with a BytesIO.
- write(s)¶
Write a plain Python string with no special encoding in Python 2.x, or bytes in Python 3.x
- write_array(a)¶
- write_bit(b)¶
Write a boolean value.
- write_item(v, k=None)¶
- write_long(n)¶
Write an integer as an unsigned2 32-bit value.
- write_longlong(n)¶
Write an integer as an unsigned 64-bit value.
- write_longstr(s)¶
Write a string up to 2**32 bytes long after encoding.
If passed a unicode string, encode as UTF-8.
- write_octet(n)¶
Write an integer as an unsigned 8-bit value.
- write_short(n)¶
Write an integer as an unsigned 16-bit value.
- write_shortstr(s)¶
Write a string up to 255 bytes long (after any encoding).
If passed a unicode string, encode with UTF-8.
- write_table(d)¶
Write out a Python dictionary made of up string keys, and values that are strings, signed integers, Decimal, datetime.datetime, or sub-dictionaries following the same constraints.
- write_timestamp(v)¶
Write out a Python datetime.datetime object as a 64-bit integer representing seconds since the Unix epoch.