summaryrefslogtreecommitdiffstats
path: root/scripts/external_libs/pyzmq-14.5.0/python3/cel59/32bit/zmq/utils/z85.py
diff options
context:
space:
mode:
authorYaroslav Brustinov <ybrustin@cisco.com>2017-02-01 21:13:23 +0200
committerYaroslav Brustinov <ybrustin@cisco.com>2017-02-02 14:26:12 +0200
commit781d71db20b0c5acbe940eff1b1ef2f1b765ce54 (patch)
tree444ef9944a789eaf7d51729d8e84f0b1ab70bda4 /scripts/external_libs/pyzmq-14.5.0/python3/cel59/32bit/zmq/utils/z85.py
parent7b39a77194c736194b40a40fdd19928b98310959 (diff)
zmq os independent
Change-Id: Iaf5a782be4db26a979a7535454719e8e62b5969a Signed-off-by: Yaroslav Brustinov <ybrustin@cisco.com>
Diffstat (limited to 'scripts/external_libs/pyzmq-14.5.0/python3/cel59/32bit/zmq/utils/z85.py')
-rw-r--r--scripts/external_libs/pyzmq-14.5.0/python3/cel59/32bit/zmq/utils/z85.py56
1 files changed, 0 insertions, 56 deletions
diff --git a/scripts/external_libs/pyzmq-14.5.0/python3/cel59/32bit/zmq/utils/z85.py b/scripts/external_libs/pyzmq-14.5.0/python3/cel59/32bit/zmq/utils/z85.py
deleted file mode 100644
index 1bb1784e..00000000
--- a/scripts/external_libs/pyzmq-14.5.0/python3/cel59/32bit/zmq/utils/z85.py
+++ /dev/null
@@ -1,56 +0,0 @@
-"""Python implementation of Z85 85-bit encoding
-
-Z85 encoding is a plaintext encoding for a bytestring interpreted as 32bit integers.
-Since the chunks are 32bit, a bytestring must be a multiple of 4 bytes.
-See ZMQ RFC 32 for details.
-
-
-"""
-
-# Copyright (C) PyZMQ Developers
-# Distributed under the terms of the Modified BSD License.
-
-import sys
-import struct
-
-PY3 = sys.version_info[0] >= 3
-# Z85CHARS is the base 85 symbol table
-Z85CHARS = b"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-:+=^!/*?&<>()[]{}@%$#"
-# Z85MAP maps integers in [0,84] to the appropriate character in Z85CHARS
-Z85MAP = dict([(c, idx) for idx, c in enumerate(Z85CHARS)])
-
-_85s = [ 85**i for i in range(5) ][::-1]
-
-def encode(rawbytes):
- """encode raw bytes into Z85"""
- # Accepts only byte arrays bounded to 4 bytes
- if len(rawbytes) % 4:
- raise ValueError("length must be multiple of 4, not %i" % len(rawbytes))
-
- nvalues = len(rawbytes) / 4
-
- values = struct.unpack('>%dI' % nvalues, rawbytes)
- encoded = []
- for v in values:
- for offset in _85s:
- encoded.append(Z85CHARS[(v // offset) % 85])
-
- # In Python 3, encoded is a list of integers (obviously?!)
- if PY3:
- return bytes(encoded)
- else:
- return b''.join(encoded)
-
-def decode(z85bytes):
- """decode Z85 bytes to raw bytes"""
- if len(z85bytes) % 5:
- raise ValueError("Z85 length must be multiple of 5, not %i" % len(z85bytes))
-
- nvalues = len(z85bytes) / 5
- values = []
- for i in range(0, len(z85bytes), 5):
- value = 0
- for j, offset in enumerate(_85s):
- value += Z85MAP[z85bytes[i+j]] * offset
- values.append(value)
- return struct.pack('>%dI' % nvalues, *values)