Example #1
0
    def _ConvertMessageDescriptor(self,
                                  desc_proto,
                                  package=None,
                                  file_desc=None,
                                  scope=None):
        """Adds the proto to the pool in the specified package.

    Args:
      desc_proto: The descriptor_pb2.DescriptorProto protobuf message.
      package: The package the proto should be located in.
      file_desc: The file containing this message.
      scope: Dict mapping short and full symbols to message and enum types.

    Returns:
      The added descriptor.
    """

        if package:
            desc_name = '.'.join((package, desc_proto.name))
        else:
            desc_name = desc_proto.name

        if file_desc is None:
            file_name = None
        else:
            file_name = file_desc.name

        if scope is None:
            scope = {}

        nested = [
            self._ConvertMessageDescriptor(nested, desc_name, file_desc, scope)
            for nested in desc_proto.nested_type
        ]
        enums = [
            self._ConvertEnumDescriptor(enum, desc_name, file_desc, None,
                                        scope) for enum in desc_proto.enum_type
        ]
        fields = [
            self.MakeFieldDescriptor(field, desc_name, index)
            for index, field in enumerate(desc_proto.field)
        ]
        extensions = [
            self.MakeFieldDescriptor(extension,
                                     desc_name,
                                     index,
                                     is_extension=True)
            for index, extension in enumerate(desc_proto.extension)
        ]
        oneofs = [
            descriptor.OneofDescriptor(desc.name, '.'.join(
                (desc_name, desc.name)), index, None, [])
            for index, desc in enumerate(desc_proto.oneof_decl)
        ]
        extension_ranges = [(r.start, r.end)
                            for r in desc_proto.extension_range]
        if extension_ranges:
            is_extendable = True
        else:
            is_extendable = False
        desc = descriptor.Descriptor(name=desc_proto.name,
                                     full_name=desc_name,
                                     filename=file_name,
                                     containing_type=None,
                                     fields=fields,
                                     oneofs=oneofs,
                                     nested_types=nested,
                                     enum_types=enums,
                                     extensions=extensions,
                                     options=desc_proto.options,
                                     is_extendable=is_extendable,
                                     extension_ranges=extension_ranges,
                                     file=file_desc,
                                     serialized_start=None,
                                     serialized_end=None)
        for nested in desc.nested_types:
            nested.containing_type = desc
        for enum in desc.enum_types:
            enum.containing_type = desc
        for field_index, field_desc in enumerate(desc_proto.field):
            if field_desc.HasField('oneof_index'):
                oneof_index = field_desc.oneof_index
                oneofs[oneof_index].fields.append(fields[field_index])
                fields[field_index].containing_oneof = oneofs[oneof_index]

        scope[_PrefixWithDot(desc_name)] = desc
        self._descriptors[desc_name] = desc
        return desc
Example #2
0
_CODEGENERATORREQUEST = _descriptor.Descriptor(
  name='CodeGeneratorRequest',
  full_name='google.protobuf.compiler.CodeGeneratorRequest',
  filename=None,
  file=DESCRIPTOR,
  containing_type=None,
  fields=[
    _descriptor.FieldDescriptor(
      name='file_to_generate', full_name='google.protobuf.compiler.CodeGeneratorRequest.file_to_generate', index=0,
      number=1, type=9, cpp_type=9, label=3,
      has_default_value=False, default_value=[],
      message_type=None, enum_type=None, containing_type=None,
      is_extension=False, extension_scope=None,
      options=None),
    _descriptor.FieldDescriptor(
      name='parameter', full_name='google.protobuf.compiler.CodeGeneratorRequest.parameter', index=1,
      number=2, type=9, cpp_type=9, label=1,
      has_default_value=False, default_value=_b("").decode('utf-8'),
      message_type=None, enum_type=None, containing_type=None,
      is_extension=False, extension_scope=None,
      options=None),
    _descriptor.FieldDescriptor(
      name='proto_file', full_name='google.protobuf.compiler.CodeGeneratorRequest.proto_file', index=2,
      number=15, type=11, cpp_type=10, label=3,
      has_default_value=False, default_value=[],
      message_type=None, enum_type=None, containing_type=None,
      is_extension=False, extension_scope=None,
      options=None),
  ],
  extensions=[
  ],
  nested_types=[],
  enum_types=[
  ],
  options=None,
  is_extendable=False,
  extension_ranges=[],
  oneofs=[
  ],
  serialized_start=101,
  serialized_end=226,
)
Example #3
0
_CONFIG = _descriptor.Descriptor(
    name='Config',
    full_name='Config',
    filename=None,
    file=DESCRIPTOR,
    containing_type=None,
    fields=[
        _descriptor.FieldDescriptor(name='version',
                                    full_name='Config.version',
                                    index=0,
                                    number=1,
                                    type=5,
                                    cpp_type=1,
                                    label=1,
                                    has_default_value=False,
                                    default_value=0,
                                    message_type=None,
                                    enum_type=None,
                                    containing_type=None,
                                    is_extension=False,
                                    extension_scope=None,
                                    options=None),
        _descriptor.FieldDescriptor(name='cq_name',
                                    full_name='Config.cq_name',
                                    index=1,
                                    number=2,
                                    type=9,
                                    cpp_type=9,
                                    label=1,
                                    has_default_value=False,
                                    default_value=_b("").decode('utf-8'),
                                    message_type=None,
                                    enum_type=None,
                                    containing_type=None,
                                    is_extension=False,
                                    extension_scope=None,
                                    options=None),
        _descriptor.FieldDescriptor(name='verifiers',
                                    full_name='Config.verifiers',
                                    index=2,
                                    number=3,
                                    type=11,
                                    cpp_type=10,
                                    label=1,
                                    has_default_value=False,
                                    default_value=None,
                                    message_type=None,
                                    enum_type=None,
                                    containing_type=None,
                                    is_extension=False,
                                    extension_scope=None,
                                    options=None),
        _descriptor.FieldDescriptor(name='cq_status_url',
                                    full_name='Config.cq_status_url',
                                    index=3,
                                    number=4,
                                    type=9,
                                    cpp_type=9,
                                    label=1,
                                    has_default_value=False,
                                    default_value=_b("").decode('utf-8'),
                                    message_type=None,
                                    enum_type=None,
                                    containing_type=None,
                                    is_extension=False,
                                    extension_scope=None,
                                    options=None),
        _descriptor.FieldDescriptor(
            name='hide_ref_in_committed_msg',
            full_name='Config.hide_ref_in_committed_msg',
            index=4,
            number=5,
            type=8,
            cpp_type=7,
            label=1,
            has_default_value=False,
            default_value=False,
            message_type=None,
            enum_type=None,
            containing_type=None,
            is_extension=False,
            extension_scope=None,
            options=None),
        _descriptor.FieldDescriptor(name='commit_burst_delay',
                                    full_name='Config.commit_burst_delay',
                                    index=5,
                                    number=6,
                                    type=5,
                                    cpp_type=1,
                                    label=1,
                                    has_default_value=False,
                                    default_value=0,
                                    message_type=None,
                                    enum_type=None,
                                    containing_type=None,
                                    is_extension=False,
                                    extension_scope=None,
                                    options=None),
        _descriptor.FieldDescriptor(name='max_commit_burst',
                                    full_name='Config.max_commit_burst',
                                    index=6,
                                    number=7,
                                    type=5,
                                    cpp_type=1,
                                    label=1,
                                    has_default_value=False,
                                    default_value=0,
                                    message_type=None,
                                    enum_type=None,
                                    containing_type=None,
                                    is_extension=False,
                                    extension_scope=None,
                                    options=None),
        _descriptor.FieldDescriptor(name='in_production',
                                    full_name='Config.in_production',
                                    index=7,
                                    number=8,
                                    type=8,
                                    cpp_type=7,
                                    label=1,
                                    has_default_value=False,
                                    default_value=False,
                                    message_type=None,
                                    enum_type=None,
                                    containing_type=None,
                                    is_extension=False,
                                    extension_scope=None,
                                    options=None),
        _descriptor.FieldDescriptor(name='rietveld',
                                    full_name='Config.rietveld',
                                    index=8,
                                    number=9,
                                    type=11,
                                    cpp_type=10,
                                    label=1,
                                    has_default_value=False,
                                    default_value=None,
                                    message_type=None,
                                    enum_type=None,
                                    containing_type=None,
                                    is_extension=False,
                                    extension_scope=None,
                                    options=None),
        _descriptor.FieldDescriptor(name='gerrit',
                                    full_name='Config.gerrit',
                                    index=9,
                                    number=15,
                                    type=11,
                                    cpp_type=10,
                                    label=1,
                                    has_default_value=False,
                                    default_value=None,
                                    message_type=None,
                                    enum_type=None,
                                    containing_type=None,
                                    is_extension=False,
                                    extension_scope=None,
                                    options=None),
        _descriptor.FieldDescriptor(name='git_repo_url',
                                    full_name='Config.git_repo_url',
                                    index=10,
                                    number=10,
                                    type=9,
                                    cpp_type=9,
                                    label=1,
                                    has_default_value=False,
                                    default_value=_b("").decode('utf-8'),
                                    message_type=None,
                                    enum_type=None,
                                    containing_type=None,
                                    is_extension=False,
                                    extension_scope=None,
                                    options=None),
        _descriptor.FieldDescriptor(name='target_ref',
                                    full_name='Config.target_ref',
                                    index=11,
                                    number=11,
                                    type=9,
                                    cpp_type=9,
                                    label=1,
                                    has_default_value=False,
                                    default_value=_b("").decode('utf-8'),
                                    message_type=None,
                                    enum_type=None,
                                    containing_type=None,
                                    is_extension=False,
                                    extension_scope=None,
                                    options=None),
        _descriptor.FieldDescriptor(name='svn_repo_url',
                                    full_name='Config.svn_repo_url',
                                    index=12,
                                    number=12,
                                    type=9,
                                    cpp_type=9,
                                    label=1,
                                    has_default_value=False,
                                    default_value=_b("").decode('utf-8'),
                                    message_type=None,
                                    enum_type=None,
                                    containing_type=None,
                                    is_extension=False,
                                    extension_scope=None,
                                    options=None),
    ],
    extensions=[],
    nested_types=[],
    enum_types=[],
    options=None,
    is_extendable=False,
    extension_ranges=[],
    oneofs=[],
    serialized_start=13,
    serialized_end=339,
)
Example #4
0
_CONFIG = _descriptor.Descriptor(
    name='Config',
    full_name='Config',
    filename=None,
    file=DESCRIPTOR,
    containing_type=None,
    fields=[
        _descriptor.FieldDescriptor(name='version',
                                    full_name='Config.version',
                                    index=0,
                                    number=1,
                                    type=5,
                                    cpp_type=1,
                                    label=1,
                                    has_default_value=False,
                                    default_value=0,
                                    message_type=None,
                                    enum_type=None,
                                    containing_type=None,
                                    is_extension=False,
                                    extension_scope=None,
                                    options=None),
        _descriptor.FieldDescriptor(name='cq_name',
                                    full_name='Config.cq_name',
                                    index=1,
                                    number=2,
                                    type=9,
                                    cpp_type=9,
                                    label=1,
                                    has_default_value=False,
                                    default_value=_b("").decode('utf-8'),
                                    message_type=None,
                                    enum_type=None,
                                    containing_type=None,
                                    is_extension=False,
                                    extension_scope=None,
                                    options=None),
        _descriptor.FieldDescriptor(name='verifiers',
                                    full_name='Config.verifiers',
                                    index=2,
                                    number=3,
                                    type=11,
                                    cpp_type=10,
                                    label=1,
                                    has_default_value=False,
                                    default_value=None,
                                    message_type=None,
                                    enum_type=None,
                                    containing_type=None,
                                    is_extension=False,
                                    extension_scope=None,
                                    options=None),
        _descriptor.FieldDescriptor(name='cq_status_url',
                                    full_name='Config.cq_status_url',
                                    index=3,
                                    number=4,
                                    type=9,
                                    cpp_type=9,
                                    label=1,
                                    has_default_value=False,
                                    default_value=_b("").decode('utf-8'),
                                    message_type=None,
                                    enum_type=None,
                                    containing_type=None,
                                    is_extension=False,
                                    extension_scope=None,
                                    options=None),
        _descriptor.FieldDescriptor(
            name='hide_ref_in_committed_msg',
            full_name='Config.hide_ref_in_committed_msg',
            index=4,
            number=5,
            type=8,
            cpp_type=7,
            label=1,
            has_default_value=False,
            default_value=False,
            message_type=None,
            enum_type=None,
            containing_type=None,
            is_extension=False,
            extension_scope=None,
            options=_descriptor._ParseOptions(descriptor_pb2.FieldOptions(),
                                              _b('\030\001'))),
        _descriptor.FieldDescriptor(name='commit_burst_delay',
                                    full_name='Config.commit_burst_delay',
                                    index=5,
                                    number=6,
                                    type=5,
                                    cpp_type=1,
                                    label=1,
                                    has_default_value=False,
                                    default_value=0,
                                    message_type=None,
                                    enum_type=None,
                                    containing_type=None,
                                    is_extension=False,
                                    extension_scope=None,
                                    options=None),
        _descriptor.FieldDescriptor(name='max_commit_burst',
                                    full_name='Config.max_commit_burst',
                                    index=6,
                                    number=7,
                                    type=5,
                                    cpp_type=1,
                                    label=1,
                                    has_default_value=False,
                                    default_value=0,
                                    message_type=None,
                                    enum_type=None,
                                    containing_type=None,
                                    is_extension=False,
                                    extension_scope=None,
                                    options=None),
        _descriptor.FieldDescriptor(name='in_production',
                                    full_name='Config.in_production',
                                    index=7,
                                    number=8,
                                    type=8,
                                    cpp_type=7,
                                    label=1,
                                    has_default_value=False,
                                    default_value=False,
                                    message_type=None,
                                    enum_type=None,
                                    containing_type=None,
                                    is_extension=False,
                                    extension_scope=None,
                                    options=None),
        _descriptor.FieldDescriptor(name='rietveld',
                                    full_name='Config.rietveld',
                                    index=8,
                                    number=9,
                                    type=11,
                                    cpp_type=10,
                                    label=1,
                                    has_default_value=False,
                                    default_value=None,
                                    message_type=None,
                                    enum_type=None,
                                    containing_type=None,
                                    is_extension=False,
                                    extension_scope=None,
                                    options=None),
        _descriptor.FieldDescriptor(name='gerrit',
                                    full_name='Config.gerrit',
                                    index=9,
                                    number=15,
                                    type=11,
                                    cpp_type=10,
                                    label=1,
                                    has_default_value=False,
                                    default_value=None,
                                    message_type=None,
                                    enum_type=None,
                                    containing_type=None,
                                    is_extension=False,
                                    extension_scope=None,
                                    options=None),
        _descriptor.FieldDescriptor(name='git_repo_url',
                                    full_name='Config.git_repo_url',
                                    index=10,
                                    number=10,
                                    type=9,
                                    cpp_type=9,
                                    label=1,
                                    has_default_value=False,
                                    default_value=_b("").decode('utf-8'),
                                    message_type=None,
                                    enum_type=None,
                                    containing_type=None,
                                    is_extension=False,
                                    extension_scope=None,
                                    options=None),
        _descriptor.FieldDescriptor(name='target_ref',
                                    full_name='Config.target_ref',
                                    index=11,
                                    number=11,
                                    type=9,
                                    cpp_type=9,
                                    label=1,
                                    has_default_value=False,
                                    default_value=_b("").decode('utf-8'),
                                    message_type=None,
                                    enum_type=None,
                                    containing_type=None,
                                    is_extension=False,
                                    extension_scope=None,
                                    options=_descriptor._ParseOptions(
                                        descriptor_pb2.FieldOptions(),
                                        _b('\030\001'))),
        _descriptor.FieldDescriptor(name='svn_repo_url',
                                    full_name='Config.svn_repo_url',
                                    index=12,
                                    number=12,
                                    type=9,
                                    cpp_type=9,
                                    label=1,
                                    has_default_value=False,
                                    default_value=_b("").decode('utf-8'),
                                    message_type=None,
                                    enum_type=None,
                                    containing_type=None,
                                    is_extension=False,
                                    extension_scope=None,
                                    options=_descriptor._ParseOptions(
                                        descriptor_pb2.FieldOptions(),
                                        _b('\030\001'))),
        _descriptor.FieldDescriptor(name='draining_start_time',
                                    full_name='Config.draining_start_time',
                                    index=13,
                                    number=13,
                                    type=9,
                                    cpp_type=9,
                                    label=1,
                                    has_default_value=False,
                                    default_value=_b("").decode('utf-8'),
                                    message_type=None,
                                    enum_type=None,
                                    containing_type=None,
                                    is_extension=False,
                                    extension_scope=None,
                                    options=None),
    ],
    extensions=[],
    nested_types=[],
    enum_types=[],
    options=None,
    is_extendable=False,
    extension_ranges=[],
    oneofs=[],
    serialized_start=13,
    serialized_end=380,
)