autopep8 --in-place --recursive  --max-line-length=200 ifcopenshell
This commit is contained in:
thorade
2017-11-06 09:10:28 +01:00
committed by Thomas Krijnen
parent 403f64a0d0
commit 8439e5b46d
9 changed files with 285 additions and 211 deletions
+13 -8
View File
@@ -28,23 +28,28 @@ from functools import reduce
chars = string.digits + string.ascii_uppercase + string.ascii_lowercase + '_$'
def compress(g):
bs = [int(g[i:i+2], 16) for i in range(0, len(g), 2)]
bs = [int(g[i:i + 2], 16) for i in range(0, len(g), 2)]
def b64(v, l=4):
return ''.join([chars[(v // (64**i))%64] for i in range(l)][::-1])
return ''.join([b64(bs[0], 2)] + [b64((bs[i] << 16) + (bs[i+1] << 8) + bs[i+2]) for i in range(1,16,3)])
return ''.join([chars[(v // (64**i)) % 64] for i in range(l)][::-1])
return ''.join([b64(bs[0], 2)] + [b64((bs[i] << 16) + (bs[i + 1] << 8) + bs[i + 2]) for i in range(1, 16, 3)])
def expand(g):
def b64(v):
return reduce(lambda a, b: a * 64 + b, map(lambda c: chars.index(c), v))
bs = [b64(g[0:2])]
for i in range(5):
d = b64(g[2+4*i:6+4*i])
bs += [(d >> (8*(2-j)))%256 for j in range(3)]
return ''.join(['%02x'%b for b in bs])
d = b64(g[2 + 4 * i:6 + 4 * i])
bs += [(d >> (8 * (2 - j))) % 256 for j in range(3)]
return ''.join(['%02x' % b for b in bs])
def split(g):
return '{%s-%s-%s-%s-%s}'%(g[:8], g[8:12], g[12:16], g[16:20], g[20:])
return '{%s-%s-%s-%s-%s}' % (g[:8], g[8:12], g[12:16], g[16:20], g[20:])
def new():
return compress(uuid.uuid4().hex)