parameters: (self, null_init, inner_init_only = False)
return_statement: return outer_init
docstring: Return literal expression for this field's default value.
          null_init: If True, initialize to a 0 value instead of default from .proto
          inner_init_only: If True, exclude initialization for any count/has fields
docstring_summary: Return literal expression for this field's default value.
          null_init: If True, initialize to a 0 value instead of default from .proto
          inner_init_only: If True, exclude initialization for any count/has fields
docstring_tokens: Return literal expression for this field s default value . null_init : If True initialize to a 0 value instead of default from . proto inner_init_only : If True exclude initialization for any count / has fields
function: def get_initializer(self, null_init, inner_init_only = False):
          '''Return literal expression for this field's default value.
          null_init: If True, initialize to a 0 value instead of default from .proto
          inner_init_only: If True, exclude initialization for any count/has fields
          '''
  
          inner_init = None
          if self.pbtype == 'MESSAGE':
              if null_init:
                  inner_init = '%s_init_zero' % self.ctype
              else:
                  inner_init = '%s_init_default' % self.ctype
          elif self.default is None or null_init:
              if self.pbtype == 'STRING':
                  inner_init = '""'
              elif self.pbtype == 'BYTES':
                  if self.inline:
                      inner_init = '{0}'
                  else:
                      inner_init = '{0, {0}}'
              elif self.pbtype in ('ENUM', 'UENUM'):
                  inner_init = '(%s)0' % self.ctype
              else:
                  inner_init = '0'
          else:
              if self.pbtype == 'STRING':
                  inner_init = self.default.replace('"', '\\"')
                  inner_init = '"' + inner_init + '"'
              elif self.pbtype == 'BYTES':
                  data = ['0x%02x' % ord(c) for c in self.default]
                  if len(data) == 0:
                      if self.inline:
                          inner_init = '{0}'
                      else:
                          inner_init = '{0, {0}}'
                  else:
                      if self.inline:
                          inner_init = '{%s}' % ','.join(data)
                      else:
                          inner_init = '{%d, {%s}}' % (len(data), ','.join(data))
              elif self.pbtype in ['FIXED32', 'UINT32']:
                  inner_init = str(self.default) + 'u'
              elif self.pbtype in ['FIXED64', 'UINT64']:
                  inner_init = str(self.default) + 'ull'
              elif self.pbtype in ['SFIXED64', 'INT64']:
                  inner_init = str(self.default) + 'll'
              else:
                  inner_init = str(self.default)
  
          if inner_init_only:
              return inner_init
  
          outer_init = None
          if self.allocation == 'STATIC':
              if self.rules == 'REPEATED':
                  outer_init = '0, {'
                  outer_init += ', '.join([inner_init] * self.max_count)
                  outer_init += '}'
              elif self.rules == 'OPTIONAL':
                  outer_init = 'false, ' + inner_init
              else:
                  outer_init = inner_init
          elif self.allocation == 'POINTER':
              if self.rules == 'REPEATED':
                  outer_init = '0, NULL'
              else:
                  outer_init = 'NULL'
          elif self.allocation == 'CALLBACK':
              if self.pbtype == 'EXTENSION':
                  outer_init = 'NULL'
              else:
                  outer_init = '{{NULL}, NULL}'
  
          return outer_init
function_tokens: def get_initializer ( self , null_init , inner_init_only = False ) : inner_init = None if self . pbtype == 'MESSAGE' : if null_init : inner_init = '%s_init_zero' % self . ctype else : inner_init = '%s_init_default' % self . ctype elif self . default is None or null_init : if self . pbtype == 'STRING' : inner_init = '""' elif self . pbtype == 'BYTES' : if self . inline : inner_init = '{0}' else : inner_init = '{0, {0}}' elif self . pbtype in ( 'ENUM' , 'UENUM' ) : inner_init = '(%s)0' % self . ctype else : inner_init = '0' else : if self . pbtype == 'STRING' : inner_init = self . default . replace ( '"' , '\\"' ) inner_init = '"' + inner_init + '"' elif self . pbtype == 'BYTES' : data = [ '0x%02x' % ord ( c ) for c in self . default ] if len ( data ) == 0 : if self . inline : inner_init = '{0}' else : inner_init = '{0, {0}}' else : if self . inline : inner_init = '{%s}' % ',' . join ( data ) else : inner_init = '{%d, {%s}}' % ( len ( data ) , ',' . join ( data ) ) elif self . pbtype in [ 'FIXED32' , 'UINT32' ] : inner_init = str ( self . default ) + 'u' elif self . pbtype in [ 'FIXED64' , 'UINT64' ] : inner_init = str ( self . default ) + 'ull' elif self . pbtype in [ 'SFIXED64' , 'INT64' ] : inner_init = str ( self . default ) + 'll' else : inner_init = str ( self . default ) if inner_init_only : return inner_init outer_init = None if self . allocation == 'STATIC' : if self . rules == 'REPEATED' : outer_init = '0, {' outer_init += ', ' . join ( [ inner_init ] * self . max_count ) outer_init += '}' elif self . rules == 'OPTIONAL' : outer_init = 'false, ' + inner_init else : outer_init = inner_init elif self . allocation == 'POINTER' : if self . rules == 'REPEATED' : outer_init = '0, NULL' else : outer_init = 'NULL' elif self . allocation == 'CALLBACK' : if self . pbtype == 'EXTENSION' : outer_init = 'NULL' else : outer_init = '{{NULL}, NULL}' return outer_init