Decode a BSON int32 to python int.
346753
def _get_int(data, position, dummy0, dummy1, dummy2):
    """"""
    end = position + 4
    return _UNPACK_INT(data[position:end])[0], end
384770
def uint32(self, val):
        """"""
        try:
            self.msg += [pack("!I", val)]
        except struct.error:
            raise ValueError("Expected uint32")
        return self
146459
def _encode_int(name, value, dummy0, dummy1):
    """"""
    if -2147483648 <= value <= 2147483647:
        return b"\x10" + name + _PACK_INT(value)
    else:
        try:
            return b"\x12" + name + _PACK_LONG(value)
        except struct.error:
            raise OverflowError("BSON can only handle up to 8-byte ints")
1325198
def LEB128toint(LEBinput):
    '''
    
    '''

    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)
1123405
function bytes_to_int32(arr, off) {
        return (arr[off + 3] << 24) | (arr[off + 2] << 16) | (arr[off + 1] << 8) | (arr[off])
    }
1119560
def convert_bytes_to_ints(in_bytes, num):
    """"""
    out_arr = []
    for i in range(len(in_bytes)//num):
        val = in_bytes[i * num:i * num + num]
        unpacked = struct.unpack(mmtf.utils.constants.NUM_DICT[num], val)
        out_arr.append(unpacked[0])
    return out_arr
906552
def read_large_int(self, bits, signed=True):
        """"""
        return int.from_bytes(
            self.read(bits // 8), byteorder='little', signed=signed)
948079
def unpack_int(s):
    
    ret = 0
    i = 0
    while True:
        b = ord(s[i])
        ret |= (b & 127) << (i * 7)
        i += 1
        if b & 128 == 0:
            break
    return ret
500353
def _from_bytes(bytes, byteorder="big", signed=False):
    """"""
    return int.from_bytes(bytes, byteorder=byteorder, signed=signed)
550701
def decodepackbits(encoded):
    
    func = ord if sys.version[0] == '2' else lambda x: x
    result = []
    i = 0
    try:
        while True:
            n = func(encoded[i]) + 1
            i += 1
            if n < 129:
                result.extend(encoded[i:i+n])
                i += n
            elif n > 129:
                result.extend(encoded[i:i+1] * (258-n))
                i += 1
    except IndexError:
        pass
    return b''.join(result) if sys.version[0] == '2' else bytes(result)
1029194
static public int unpackInt(DataInput is)
      throws IOException {
    for (int offset = 0, result = 0; offset < 32; offset += 7) {
      int b = is.readUnsignedByte();
      result |= (b & 0x7F) << offset;
      if ((b & 0x80) == 0) {
        return result;
      }
    }
    throw new Error("Malformed integer.");
  }
428883
def _get_int64(data, position, dummy0, dummy1, dummy2):
    """"""
    end = position + 8
    return Int64(_UNPACK_LONG(data[position:end])[0]), end
1034819
def bytes_to_int(b, order='big'):  # pragma: no cover
        """"""
        if six.PY2:
            # save the original type of b without having to copy any data
            _b = b.__class__()
            if order != 'little':
                b = reversed(b)

            if not isinstance(_b, bytearray):
                b = six.iterbytes(b)

            return sum(c << (i * 8) for i, c in enumerate(b))

        return int.from_bytes(b, order)
141435
def ints2str(self, int_values):
    """"""
    if not self._encoder:
      raise ValueError(
          "Text.ints2str is not available because encoder hasn't been defined.")
    return self._encoder.decode(int_values)
1184568
def recursive_index_decode(int_array, max=32767, min=-32768):
    """"""
    out_arr = []
    encoded_ind = 0
    while encoded_ind < len(int_array):
        decoded_val = 0
        while int_array[encoded_ind]==max or int_array[encoded_ind]==min:
            decoded_val += int_array[encoded_ind]
            encoded_ind+=1
            if int_array[encoded_ind]==0:
                break
        decoded_val += int_array[encoded_ind]
        encoded_ind+=1
        out_arr.append(decoded_val)
    return out_arr
1255566
def encode_int(v):
    """"""
    if not is_numeric(v) or v < 0 or v >= TT256:
        raise Exception("Integer invalid or out of range: %r" % v)
    return int_to_big_endian(v)
268383
def decode_list(self, integers):
    """"""
    integers = list(np.squeeze(integers))
    return self.encoders["inputs"].decode_list(integers)