def define_message(message_descriptor, module_name):
 class_dict = {'__module__': module_name}
 for enum in (message_descriptor.enum_types or []):
  enum_instance = define_enum(enum, module_name)
  class_dict[enum.name] = enum_instance
 for field in (message_descriptor.fields or []):
  field_instance = define_field(field)
  class_dict[field.name] = field_instance
 class_name = message_descriptor.name.encode('utf-8')
 return type(class_name, (messages.Message,), class_dict)

def define_message ( message_descriptor , module_name ) : class_dict = { '__module__' : module_name } for enum in ( message_descriptor . enum_types or [ ] ) : enum_instance = define_enum ( enum , module_name ) class_dict [ enum . name ] = enum_instance for field in ( message_descriptor . fields or [ ] ) : field_instance = define_field ( field ) class_dict [ field . name ] = field_instance class_name = message_descriptor . name . encode ( 'utf-8' ) return type ( class_name , ( messages . Message , ) , class_dict )
define message class from descriptor .