#  google.protobuf.message_factory  ¶

Provides a factory class for generating dynamic messages.

The easiest way to use this class is if you have access to the FileDescriptor
protos containing the messages you want to create you can just do the
following:

message_classes = message_factory.GetMessages(iterable_of_file_descriptors)
my_proto_instance = message_classes[‘some.proto.package.MessageName’]()

` google.protobuf.message_factory. ` ` GetMessages ` (  _file_protos_ )  ¶

    

Builds a dictionary of all the messages available in a set of files.

Parameters  :

    

**file_protos** – Iterable of FileDescriptorProto to build messages out of.

Returns  :

    

A dictionary mapping proto names to the message classes. This will include any
dependent messages as well as any messages defined in the same file as a
specified message.

_class_ ` google.protobuf.message_factory. ` ` MessageFactory ` (  _pool=None_
)  ¶

    

Factory for creating Proto2 messages from descriptors in a pool.

` CreatePrototype ` (  _descriptor_ )  ¶

    

Builds a proto2 message class based on the passed in descriptor.

Don’t call this function directly, it always creates a new class. Call
GetPrototype() instead. This method is meant to be overridden in subblasses to
perform additional operations on the newly constructed class.

Parameters  :

    

**descriptor** – The descriptor to build from.

Returns  :

    

A class describing the passed in descriptor.

` GetMessages ` (  _files_ )  ¶

    

Gets all the messages from a specified file.

This will find and resolve dependencies, failing if the descriptor pool cannot
satisfy them.

Parameters  :

    

**files** – The file names to extract messages from.

Returns  :

    

A dictionary mapping proto names to the message classes. This will include any
dependent messages as well as any messages defined in the same file as a
specified message.

` GetPrototype ` (  _descriptor_ )  ¶

    

Obtains a proto2 message class based on the passed in descriptor.

Passing a descriptor with a fully qualified name matching a previous
invocation will cause the same class to be returned.

Parameters  :

    

**descriptor** – The descriptor to build from.

Returns  :

    

A class describing the passed in descriptor.

###  [ Table of Contents ](../../index.html)

  * [ google.protobuf ](../protobuf.html)
  * [ google.protobuf.any_pb2 ](any_pb2.html)
  * [ google.protobuf.descriptor ](descriptor.html)
  * [ google.protobuf.descriptor_database ](descriptor_database.html)
  * [ google.protobuf.descriptor_pb2 ](descriptor_pb2.html)
  * [ google.protobuf.descriptor_pool ](descriptor_pool.html)
  * [ google.protobuf.duration_pb2 ](duration_pb2.html)
  * [ google.protobuf.empty_pb2 ](empty_pb2.html)
  * [ google.protobuf.field_mask_pb2 ](field_mask_pb2.html)
  * [ google.protobuf.internal.containers ](internal/containers.html)
  * [ google.protobuf.json_format ](json_format.html)
  * [ google.protobuf.message ](message.html)
  * google.protobuf.message_factory 
  * [ google.protobuf.proto_builder ](proto_builder.html)
  * [ google.protobuf.reflection ](reflection.html)
  * [ google.protobuf.service ](service.html)
  * [ google.protobuf.service_reflection ](service_reflection.html)
  * [ google.protobuf.struct_pb2 ](struct_pb2.html)
  * [ google.protobuf.symbol_database ](symbol_database.html)
  * [ google.protobuf.text_encoding ](text_encoding.html)
  * [ google.protobuf.text_format ](text_format.html)
  * [ google.protobuf.timestamp_pb2 ](timestamp_pb2.html)
  * [ google.protobuf.type_pb2 ](type_pb2.html)
  * [ google.protobuf.unknown_fields ](unknown_fields.html)
  * [ google.protobuf.wrappers_pb2 ](wrappers_pb2.html)

###  Related Topics

  * [ Documentation overview ](../../index.html)
    * Previous: [ google.protobuf.message ](message.html "previous chapter")
    * Next: [ google.protobuf.proto_builder ](proto_builder.html "next chapter")

###  This Page

  * [ Show Source ](../../_sources/google/protobuf/mess