MCPcopy Create free account
hub / github.com/apache/qpid-proton / Array

Class Array

python/proton/_data.py:279–318  ·  view source on GitHub ↗

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,

Source from the content-addressed store, hash-verified

277
278
279class 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
321def _check_type(

Callers 9

testCopyNestedArrayMethod · 0.90
testRoundTripMethod · 0.90
utils.pyFile · 0.90
test_described_arrayMethod · 0.90
test_arraysMethod · 0.90
test_coordinatorMethod · 0.90
to_arrayMethod · 0.70
get_py_arrayMethod · 0.70

Calls

no outgoing calls

Tested by 4

test_described_arrayMethod · 0.72
test_arraysMethod · 0.72
test_coordinatorMethod · 0.72