Convert unsigned LEB128 hex to integer

def LEB128toint(LEBinput):
    '''
    Convert unsigned LEB128 hex to integer
    '''

    reversedbytes = hexreverse(LEBinput)
    binstr = ""
    for i in range(len(LEBinput) // 2):
        if i == 0:
            assert int(reversedbytes[2*i:(2*i + 2)],16) < 128
        else:
            assert int(reversedbytes[2*i:(2*i + 2)],16) >= 128
        tempbin = str(bin(int(reversedbytes[2*i:(2*i + 2)],16))) \
                  .lstrip("0b").replace("b","").replace("L","") \
                  .replace("'","").replace('"',"") \
                  .zfill(8)
        binstr += tempbin[1:]
    return int(binstr,2)