Encode integer `v` to file `f`.

    Parameters
    ----------
    v: int
        Integer v >= 0.
    f: file
        Object containing a write method.

    Returns
    -------
    int
        Number of bytes written.
977206
def encode_varint(v, f):
    
    assert v >= 0
    num_bytes = 0

    while True:
        b = v % 0x80
        v = v // 0x80

        if v > 0:
            b = b | 0x80

        f.write(FIELD_U8.pack(b))

        num_bytes += 1
        if v == 0:
            break

    return num_bytes
1062035
def to_struct_file(self, f):
        
        if isinstance(f, str):
            f = open(f,'w')
        f.write("VARIOGRAM {0}\n".format(self.name))
        f.write("  VARTYPE {0}\n".format(self.vartype))
        f.write("  A {0}\n".format(self.a))
        f.write("  ANISOTROPY {0}\n".format(self.anisotropy))
        f.write("  BEARING {0}\n".format(self.bearing))
        f.write("END VARIOGRAM\n\n")
369833
def _SignedVarintEncoder():
  """"""

  def EncodeSignedVarint(write, value):
    if value < 0:
      value += (1 << 64)
    bits = value & 0x7f
    value >>= 7
    while value:
      write(six.int2byte(0x80|bits))
      bits = value & 0x7f
      value >>= 7
    return write(six.int2byte(bits))

  return EncodeSignedVarint
110774
def _encode_uvarint(data, n):
    ''' '''
    if n < 0:
        raise ValueError('only support positive integer')
    while True:
        this_byte = n & 0x7f
        n >>= 7
        if n == 0:
            data.append(this_byte)
            break
        data.append(this_byte | 0x80)
417163
protected final void writeLEInt(int v) throws IOException {
		ensureAvailableBytes(4);
		this.buffer.order(ByteOrder.LITTLE_ENDIAN);
		this.buffer.putInt(v);
	}
865879
def getv(self, r):
        
        v = self.get(r)
        if not is_unknown(v):
            try:
                v = int(v)
            except ValueError:
                v = None
        else:
            v = None
        return v
1045024
def encode_varint(i)
      raise ArgumentError, "int must be present" if !i
      raise ArgumentError, "int must be non-negative" if i < 0

      buf = if i <  0xfd
        [i].pack("C")
      elsif i <= 0xffff
        [0xfd, i].pack("Cv")
      elsif i <= 0xffffffff
        [0xfe, i].pack("CV")
      elsif i <= 0xffffffffffffffff
        [0xff, i].pack("CQ<")
      else
        raise ArgumentError, "Does not support integers larger 0xffffffffffffffff (i = 0x#{i.to_s(16)})"
      end

      buf
    end
339962
def tofile(self, f):
        """"""
        f.write(pack(self.FILE_FMT, self.error_rate, self.num_slices,
                     self.bits_per_slice, self.capacity, self.count))
        (f.write(self.bitarray.tobytes()) if is_string_io(f)
         else self.bitarray.tofile(f))
100115
def _uint2objs(ftype, num, length=None):
    """"""
    if num == 0:
        objs = [ftype.box(0)]
    else:
        _num = num
        objs = list()
        while _num != 0:
            objs.append(ftype.box(_num & 1))
            _num >>= 1

    if length:
        if length < len(objs):
            fstr = "overflow: num = {} requires length >= {}, got length = {}"
            raise ValueError(fstr.format(num, len(objs), length))
        else:
            while len(objs) < length:
                objs.append(ftype.box(0))

    return objs
156393
def _write_cvvr(self, f, data):
        '''
        
        '''
        f.seek(0, 2)
        byte_loc = f.tell()
        cSize = len(data)
        block_size = CDF.CVVR_BASE_SIZE64 + cSize
        section_type = CDF.CVVR_
        rfuA = 0

        cvvr1 = bytearray(24)
        cvvr1[0:8] = struct.pack('>q', block_size)
        cvvr1[8:12] = struct.pack('>i', section_type)
        cvvr1[12:16] = struct.pack('>i', rfuA)
        cvvr1[16:24] = struct.pack('>q', cSize)
        f.write(cvvr1)
        f.write(data)

        return byte_loc
569884
def codes_write(handle, outfile):
    # type: (cffi.FFI.CData, T.BinaryIO) -> None
    
    mess = ffi.new('const void **')
    mess_len = ffi.new('size_t*')
    codes_get_message = check_return(lib.codes_get_message)
    codes_get_message(handle, mess, mess_len)
    message = ffi.buffer(mess[0], size=mess_len[0])
    outfile.write(message)
692210
def encode_uvarint(n, data):
    ''''''
    if n < 0:
        raise ValueError('only support positive integer')
    while True:
        this_byte = n & 127
        n >>= 7
        if n == 0:
            data.append(this_byte)
            break
        data.append(this_byte | 128)
66979
protected final void writeLEDouble(double v) throws IOException {
		ensureAvailableBytes(8);
		this.buffer.order(ByteOrder.LITTLE_ENDIAN);
		this.buffer.putDouble(v);
	}
986182
@Override
	public void writeInt(int v) throws IOException {
		growingByteBuffer.ensureExtraCapacity(4);
		dataOutputStream.write(0xFF & v);
		dataOutputStream.write(0xFF & (v >> 8));
		dataOutputStream.write(0xFF & (v >> 16));
		dataOutputStream.write(0xFF & (v >> 24));
	}
1229811
@Override
  public void writeShort(int v) throws IOException {
    work[0] = (byte) (0xff & v);
    work[1] = (byte) (0xff & (v >> 8));
    write(work, 0, 2);
  }
820809
async def dump_varint_t(writer, type_or, pv):
    
    width = int_mark_to_size(type_or)
    n = (pv << 2) | type_or

    buffer = _UINT_BUFFER
    for _ in range(width):
        buffer[0] = n & 0xff
        await writer.awrite(buffer)
        n >>= 8

    return width
1268567
def write_float(self, number):
        
        buf = pack(self.byte_order + "f", number)
        self.write(buf)