diff options
author | 2016-03-21 12:55:37 +0200 | |
---|---|---|
committer | 2016-03-21 12:55:37 +0200 | |
commit | 14b94326315f1fa46187868dac16503b3f454b9e (patch) | |
tree | b1fa98d5d8ebabd3256d691d47944b763684fae9 /scripts/external_libs/pyzmq-14.5.0/cel59/python2/64bit/zmq/backend/cffi/message.py | |
parent | 1831e9bbc03484b078dbd604dfec0e025cea8eca (diff) | |
parent | bd933929deb40243e4fb218ec2c5b33a12a6e02a (diff) |
Merge Scapy 3.0
Diffstat (limited to 'scripts/external_libs/pyzmq-14.5.0/cel59/python2/64bit/zmq/backend/cffi/message.py')
-rw-r--r-- | scripts/external_libs/pyzmq-14.5.0/cel59/python2/64bit/zmq/backend/cffi/message.py | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/scripts/external_libs/pyzmq-14.5.0/cel59/python2/64bit/zmq/backend/cffi/message.py b/scripts/external_libs/pyzmq-14.5.0/cel59/python2/64bit/zmq/backend/cffi/message.py new file mode 100644 index 00000000..c35decb6 --- /dev/null +++ b/scripts/external_libs/pyzmq-14.5.0/cel59/python2/64bit/zmq/backend/cffi/message.py @@ -0,0 +1,69 @@ +"""Dummy Frame object""" + +# Copyright (C) PyZMQ Developers +# Distributed under the terms of the Modified BSD License. + +from ._cffi import ffi, C + +import zmq +from zmq.utils.strtypes import unicode + +try: + view = memoryview +except NameError: + view = buffer + +_content = lambda x: x.tobytes() if type(x) == memoryview else x + +class Frame(object): + _data = None + tracker = None + closed = False + more = False + buffer = None + + + def __init__(self, data, track=False): + try: + view(data) + except TypeError: + raise + + self._data = data + + if isinstance(data, unicode): + raise TypeError("Unicode objects not allowed. Only: str/bytes, " + + "buffer interfaces.") + + self.more = False + self.tracker = None + self.closed = False + if track: + self.tracker = zmq.MessageTracker() + + self.buffer = view(self.bytes) + + @property + def bytes(self): + data = _content(self._data) + return data + + def __len__(self): + return len(self.bytes) + + def __eq__(self, other): + return self.bytes == _content(other) + + def __str__(self): + if str is unicode: + return self.bytes.decode() + else: + return self.bytes + + @property + def done(self): + return True + +Message = Frame + +__all__ = ['Frame', 'Message'] |