def b85decode(b): _b85dec = [None] * 256 for i, c in enumerate(iterbytes(_b85alphabet)): _b85dec[c] = i padding = (-len(b)) % 5 b = b + b'~' * padding out = [] packI = struct.Struct('!I').pack for i in range(0, len(b), 5): chunk = b[i:i + 5] acc = 0 try: for c in iterbytes(chunk): acc = acc * 85 + _b85dec[c] except TypeError: for j, c in enumerate(iterbytes(chunk)): if _b85dec[c] is None: raise ValueError( 'bad base85 character at position %d' % (i + j) ) raise try: out.append(packI(acc)) except struct.error: raise ValueError('base85 overflow in hunk starting at byte %d' % i)
Ech, not much changed since I was looking at python programming style years ago. Its not language fault, it is more about how well people are writing open source code. How much does it take to understand what a method above is doing - the method name is a great help, but to understand implementation takes more than few minutes, and it is far more time than few seconds.
No comments:
Post a Comment