def write_varint(outfile, value):
 if (value == 0):
  outfile.write(ZERO_BYTE)
  return 1
 written_bytes = 0
 while (value > 0):
  to_write = (value & 127)
  value = (value >> 7)
  if (value > 0):
   to_write |= 128
  outfile.write(byte(to_write))
  written_bytes += 1
 return written_bytes

def write_varint ( outfile , value ) : if ( value == 0 ) : outfile . write ( ZERO_BYTE ) return 1 written_bytes = 0 while ( value > 0 ) : to_write = ( value & 127 ) value = ( value >> 7 ) if ( value > 0 ) : to_write |= 128 outfile . write ( byte ( to_write ) ) written_bytes += 1 return written_bytes
writes a varint to a file .