def MakeDescriptor(desc_proto, package='<STR_LIT>', build_file_if_cpp=True,<EOL>syntax=None):
if api_implementation.Type() == '<STR_LIT>' and build_file_if_cpp:<EOL><INDENT>from typy.google.protobuf import descriptor_pb2<EOL>file_descriptor_proto = descriptor_pb2.FileDescriptorProto()<EOL>file_descriptor_proto.message_type.add().MergeFrom(desc_proto)<EOL>proto_name = str(uuid.uuid4())<EOL>if package:<EOL><INDENT>file_descriptor_proto.name = os.path.join(package.replace('<STR_LIT:.>', '<STR_LIT:/>'),<EOL>proto_name + '<STR_LIT>')<EOL>file_descriptor_proto.package = package<EOL><DEDENT>else:<EOL><INDENT>file_descriptor_proto.name = proto_name + '<STR_LIT>'<EOL><DEDENT>_message.default_pool.Add(file_descriptor_proto)<EOL>result = _message.default_pool.FindFileByName(file_descriptor_proto.name)<EOL>if _USE_C_DESCRIPTORS:<EOL><INDENT>return result.message_types_by_name[desc_proto.name]<EOL><DEDENT><DEDENT>full_message_name = [desc_proto.name]<EOL>if package: full_message_name.insert(<NUM_LIT:0>, package)<EOL>enum_types = {}<EOL>for enum_proto in desc_proto.enum_type:<EOL><INDENT>full_name = '<STR_LIT:.>'.join(full_message_name + [enum_proto.name])<EOL>enum_desc = EnumDescriptor(<EOL>enum_proto.name, full_name, None, [<EOL>EnumValueDescriptor(enum_val.name, ii, enum_val.number)<EOL>for ii, enum_val in enumerate(enum_proto.value)])<EOL>enum_types[full_name] = enum_desc<EOL><DEDENT>nested_types = {}<EOL>for nested_proto in desc_proto.nested_type:<EOL><INDENT>full_name = '<STR_LIT:.>'.join(full_message_name + [nested_proto.name])<EOL>nested_desc = MakeDescriptor(nested_proto,<EOL>package='<STR_LIT:.>'.join(full_message_name),<EOL>build_file_if_cpp=False,<EOL>syntax=syntax)<EOL>nested_types[full_name] = nested_desc<EOL><DEDENT>fields = []<EOL>for field_proto in desc_proto.field:<EOL><INDENT>full_name = '<STR_LIT:.>'.join(full_message_name + [field_proto.name])<EOL>enum_desc = None<EOL>nested_desc = None<EOL>if field_proto.HasField('<STR_LIT>'):<EOL><INDENT>type_name = field_proto.type_name<EOL>full_type_name = '<STR_LIT:.>'.join(full_message_name +<EOL>[type_name[type_name.rfind('<STR_LIT:.>')+<NUM_LIT:1>:]])<EOL>if full_type_name in nested_types:<EOL><INDENT>nested_desc = nested_types[full_type_name]<EOL><DEDENT>elif full_type_name in enum_types:<EOL><INDENT>enum_desc = enum_types[full_type_name]<EOL><DEDENT><DEDENT>field = FieldDescriptor(<EOL>field_proto.name, full_name, field_proto.number - <NUM_LIT:1>,<EOL>field_proto.number, field_proto.type,<EOL>FieldDescriptor.ProtoTypeToCppProtoType(field_proto.type),<EOL>field_proto.label, None, nested_desc, enum_desc, None, False, None,<EOL>options=field_proto.options, has_default_value=False)<EOL>fields.append(field)<EOL><DEDENT>desc_name = '<STR_LIT:.>'.join(full_message_name)<EOL>return Descriptor(desc_proto.name, desc_name, None, None, fields,<EOL>list(nested_types.values()), list(enum_types.values()), [],<EOL>options=desc_proto.options)<EOL>
Make a protobuf Descriptor given a DescriptorProto protobuf.

    Handles nested descriptors. Note that this is limited to the scope of defining
    a message inside of another message. Composite fields can currently only be
    resolved if the message is defined in the same scope as the field.

    Args:
      desc_proto: The descriptor_pb2.DescriptorProto protobuf message.
      package: Optional package name for the new message Descriptor (string).
      build_file_if_cpp: Update the C++ descriptor pool if api matches.
                         Set to False on recursion, so no duplicates are created.
      syntax: The syntax/semantics that should be used.  Set to "proto3" to get
              proto3 field presence semantics.
    Returns:
      A Descriptor for protobuf messages.