MobileBlur

util.py at [2ac904a27b]
Login

util.py at [2ac904a27b]

File gluon/contrib/pymysql/util.py artifact 43d79c2f5e part of check-in 2ac904a27b


import struct

def byte2int(b):
    if isinstance(b, int):
        return b
    else:
        return struct.unpack("!B", b)[0]

def int2byte(i):
    return struct.pack("!B", i)

def join_bytes(bs):
    if len(bs) == 0:
        return ""
    else:
        rv = bs[0]
        for b in bs[1:]:
            rv += b
        return rv