def BoolEncoder(field_number, is_repeated, is_packed):
 false_byte = chr(0)
 true_byte = chr(1)
 if is_packed:
  tag_bytes = TagBytes(field_number, wire_format.WIRETYPE_LENGTH_DELIMITED)
  local_EncodeVarint = _EncodeVarint
  def EncodePackedField(write, value):
   write(tag_bytes)
   local_EncodeVarint(write, len(value))
   for element in value:
    if element:
     write(true_byte)
    else:
     write(false_byte)
  return EncodePackedField
 elif is_repeated:
  tag_bytes = TagBytes(field_number, wire_format.WIRETYPE_VARINT)
  def EncodeRepeatedField(write, value):
   for element in value:
    write(tag_bytes)
    if element:
     write(true_byte)
    else:
     write(false_byte)
  return EncodeRepeatedField
 else:
  tag_bytes = TagBytes(field_number, wire_format.WIRETYPE_VARINT)
  def EncodeField(write, value):
   write(tag_bytes)
   if value:
    return write(true_byte)
   return write(false_byte)
  return EncodeField

def BoolEncoder ( field_number , is_repeated , is_packed ) : false_byte = chr ( 0 ) true_byte = chr ( 1 ) if is_packed : tag_bytes = TagBytes ( field_number , wire_format . WIRETYPE_LENGTH_DELIMITED ) local_EncodeVarint = _EncodeVarint def EncodePackedField ( write , value ) : write ( tag_bytes ) local_EncodeVarint ( write , len ( value ) ) for element in value : if element : write ( true_byte ) else : write ( false_byte ) return EncodePackedField elif is_repeated : tag_bytes = TagBytes ( field_number , wire_format . WIRETYPE_VARINT ) def EncodeRepeatedField ( write , value ) : for element in value : write ( tag_bytes ) if element : write ( true_byte ) else : write ( false_byte ) return EncodeRepeatedField else : tag_bytes = TagBytes ( field_number , wire_format . WIRETYPE_VARINT ) def EncodeField ( write , value ) : write ( tag_bytes ) if value : return write ( true_byte ) return write ( false_byte ) return EncodeField
returns an encoder for a boolean field .