A convenience method for decoding an AMQP array into an :class:`Array` object. This method encapsulates all the steps described in :func:`get_array` into a single function. If the current node is an array, return an Array object representing the array and it
(self)
| 1512 | self.exit() |
| 1513 | |
| 1514 | def get_py_array(self) -> Optional[Array]: |
| 1515 | """ |
| 1516 | A convenience method for decoding an AMQP array into an |
| 1517 | :class:`Array` object. This method encapsulates all the |
| 1518 | steps described in :func:`get_array` into a single function. |
| 1519 | |
| 1520 | If the current node is an array, return an Array object |
| 1521 | representing the array and its contents. Otherwise return ``None``. |
| 1522 | |
| 1523 | :returns: The decoded AMQP array. |
| 1524 | """ |
| 1525 | |
| 1526 | count, described, type = self.get_array() |
| 1527 | if type is None: |
| 1528 | return None |
| 1529 | if self.enter(): |
| 1530 | try: |
| 1531 | if described: |
| 1532 | self.next() |
| 1533 | descriptor = self.get_object() |
| 1534 | else: |
| 1535 | descriptor = UNDESCRIBED |
| 1536 | elements = [] |
| 1537 | while self.next(): |
| 1538 | elements.append(self.get_object()) |
| 1539 | finally: |
| 1540 | self.exit() |
| 1541 | return Array(descriptor, type, *elements) |
| 1542 | |
| 1543 | def put_py_array(self, a: Array) -> None: |
| 1544 | """ |