An AMQP array, a sequence of AMQP values of a single type. This class provides a convenient way to handle AMQP arrays when used with convenience methods :func:`Data.get_py_array` and :func:`Data.put_py_array`. :ivar descriptor: Optional descriptor if the array is to be described,
| 277 | |
| 278 | |
| 279 | class Array(object): |
| 280 | """ |
| 281 | An AMQP array, a sequence of AMQP values of a single type. |
| 282 | |
| 283 | This class provides a convenient way to handle AMQP arrays when used with |
| 284 | convenience methods :func:`Data.get_py_array` and :func:`Data.put_py_array`. |
| 285 | |
| 286 | :ivar descriptor: Optional descriptor if the array is to be described, otherwise ``None`` |
| 287 | :ivar type: Array element type, as an integer. The :class:`Data` class has constants defined |
| 288 | for all the valid AMQP types. For example, for an array of double values, use |
| 289 | :const:`Data.DOUBLE`, which has integer value 14. |
| 290 | :ivar elements: A Python list of elements of the appropriate type. |
| 291 | """ |
| 292 | |
| 293 | def __init__( |
| 294 | self, |
| 295 | descriptor: PythonAMQPData, |
| 296 | type: int, |
| 297 | *elements |
| 298 | ) -> None: |
| 299 | self.descriptor = descriptor |
| 300 | self.type = type |
| 301 | self.elements = elements |
| 302 | |
| 303 | def __iter__(self): |
| 304 | return iter(self.elements) |
| 305 | |
| 306 | def __repr__(self) -> str: |
| 307 | if self.elements: |
| 308 | els = ", %s" % (", ".join(map(repr, self.elements))) |
| 309 | else: |
| 310 | els = "" |
| 311 | return "Array(%r, %r%s)" % (self.descriptor, self.type, els) |
| 312 | |
| 313 | def __eq__(self, o: Any) -> bool: |
| 314 | if isinstance(o, Array): |
| 315 | return self.descriptor == o.descriptor and \ |
| 316 | self.type == o.type and self.elements == o.elements |
| 317 | else: |
| 318 | return False |
| 319 | |
| 320 | |
| 321 | def _check_type( |
no outgoing calls