(self)
Loop over the schemas in the discovery doc and build definitions.
Loop over the schemas in the discovery doc and build definitions.
Loop over the schemas in the discovery doc and build definitions .
def _BuildSchemaDefinitions(self):
    """Loop over the schemas in the discovery doc and build definitions."""
    schemas = self.values.get('schemas')
    if schemas:
      for name, def_dict in schemas.iteritems():
        # Upgrade the string format schema to a dict.
        if isinstance(def_dict, unicode):
          def_dict = json.loads(def_dict)
        self._schemas[name] = self.DataTypeFromJson(def_dict, name)

      # Late bind info for variant types, and mark the discriminant
      # field and value.
      for name, info in self._variant_info.iteritems():
        if name not in self._schemas:
          # The error will be reported elsewhere
          continue
        schema = self._schemas[name]
        for prop in schema.values.get('properties'):
          if prop.values['wireName'] == info['discriminant']:
            # Filter out the discriminant property as it is already
            # contained in the base type.
            schema.SetTemplateValue(
                'properties',
                [p for p in schema.values.get('properties') if p != prop])
            break
        else:
          logging.warn("Variant schema '%s' for base schema '%s' "
                       "has not the expected discriminant property '%s'.",
                       name, info['schema'].values['wireName'],
                       info['discriminant'])
        schema.SetTemplateValue('superClass', info['schema'].class_name)
        # TODO(user): baseType is for backwards compatability only. It should
        # have always been a different name. When the old Java generators roll
        # off, remove it.
        schema.SetTemplateValue('baseType', info['schema'].class_name)
        schema.SetTemplateValue('discriminantValue', info['value'])
def _BuildSchemaDefinitions ( self ) : schemas = self . values . get ( 'schemas' ) if schemas : for name , def_dict in schemas . iteritems ( ) : # Upgrade the string format schema to a dict. if isinstance ( def_dict , unicode ) : def_dict = json . loads ( def_dict ) self . _schemas [ name ] = self . DataTypeFromJson ( def_dict , name ) # Late bind info for variant types, and mark the discriminant # field and value. for name , info in self . _variant_info . iteritems ( ) : if name not in self . _schemas : # The error will be reported elsewhere continue schema = self . _schemas [ name ] for prop in schema . values . get ( 'properties' ) : if prop . values [ 'wireName' ] == info [ 'discriminant' ] : # Filter out the discriminant property as it is already # contained in the base type. schema . SetTemplateValue ( 'properties' , [ p for p in schema . values . get ( 'properties' ) if p != prop ] ) break else : logging . warn ( "Variant schema '%s' for base schema '%s' " "has not the expected discriminant property '%s'." , name , info [ 'schema' ] . values [ 'wireName' ] , info [ 'discriminant' ] ) schema . SetTemplateValue ( 'superClass' , info [ 'schema' ] . class_name ) # TODO(user): baseType is for backwards compatability only. It should # have always been a different name. When the old Java generators roll # off, remove it. schema . SetTemplateValue ( 'baseType' , info [ 'schema' ] . class_name ) schema . SetTemplateValue ( 'discriminantValue' , info [ 'value' ] )