protobuf/python/google/protobuf/descriptor.py
Go to the documentation of this file.
1 # Protocol Buffers - Google's data interchange format
2 # Copyright 2008 Google Inc. All rights reserved.
3 # https://developers.google.com/protocol-buffers/
4 #
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are
7 # met:
8 #
9 # * Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 # * Redistributions in binary form must reproduce the above
12 # copyright notice, this list of conditions and the following disclaimer
13 # in the documentation and/or other materials provided with the
14 # distribution.
15 # * Neither the name of Google Inc. nor the names of its
16 # contributors may be used to endorse or promote products derived from
17 # this software without specific prior written permission.
18 #
19 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 
31 """Descriptors essentially contain exactly the information found in a .proto
32 file, in types that make this information accessible in Python.
33 """
34 
35 __author__ = 'robinson@google.com (Will Robinson)'
36 
37 import threading
38 import warnings
39 
40 from google.protobuf.internal import api_implementation
41 
42 _USE_C_DESCRIPTORS = False
43 if api_implementation.Type() == 'cpp':
44  # Used by MakeDescriptor in cpp mode
45  import binascii
46  import os
47  from google.protobuf.pyext import _message
48  _USE_C_DESCRIPTORS = True
49 
50 
51 class Error(Exception):
52  """Base error for this module."""
53 
54 
55 class TypeTransformationError(Error):
56  """Error transforming between python proto type and corresponding C++ type."""
57 
58 
59 if _USE_C_DESCRIPTORS:
60  # This metaclass allows to override the behavior of code like
61  # isinstance(my_descriptor, FieldDescriptor)
62  # and make it return True when the descriptor is an instance of the extension
63  # type written in C++.
65  def __instancecheck__(cls, obj):
66  if super(DescriptorMetaclass, cls).__instancecheck__(obj):
67  return True
68  if isinstance(obj, cls._C_DESCRIPTOR_CLASS):
69  return True
70  return False
71 else:
72  # The standard metaclass; nothing changes.
73  DescriptorMetaclass = type
74 
75 
76 class _Lock(object):
77  """Wrapper class of threading.Lock(), which is allowed by 'with'."""
78 
79  def __new__(cls):
80  self = object.__new__(cls)
81  self._lock = threading.Lock() # pylint: disable=protected-access
82  return self
83 
84  def __enter__(self):
85  self._lock.acquire()
86 
87  def __exit__(self, exc_type, exc_value, exc_tb):
88  self._lock.release()
89 
90 
91 _lock = threading.Lock()
92 
93 
94 def _Deprecated(name):
95  if _Deprecated.count > 0:
96  _Deprecated.count -= 1
97  warnings.warn(
98  'Call to deprecated create function %s(). Note: Create unlinked '
99  'descriptors is going to go away. Please use get/find descriptors from '
100  'generated code or query the descriptor_pool.'
101  % name,
102  category=DeprecationWarning, stacklevel=3)
103 
104 
105 # Deprecated warnings will print 100 times at most which should be enough for
106 # users to notice and do not cause timeout.
107 _Deprecated.count = 100
108 
109 
110 _internal_create_key = object()
111 
112 
113 class DescriptorBase(metaclass=DescriptorMetaclass):
114 
115  """Descriptors base class.
116 
117  This class is the base of all descriptor classes. It provides common options
118  related functionality.
119 
120  Attributes:
121  has_options: True if the descriptor has non-default options. Usually it
122  is not necessary to read this -- just call GetOptions() which will
123  happily return the default instance. However, it's sometimes useful
124  for efficiency, and also useful inside the protobuf implementation to
125  avoid some bootstrapping issues.
126  """
127 
128  if _USE_C_DESCRIPTORS:
129  # The class, or tuple of classes, that are considered as "virtual
130  # subclasses" of this descriptor class.
131  _C_DESCRIPTOR_CLASS = ()
132 
133  def __init__(self, options, serialized_options, options_class_name):
134  """Initialize the descriptor given its options message and the name of the
135  class of the options message. The name of the class is required in case
136  the options message is None and has to be created.
137  """
138  self._options = options
139  self._options_class_name = options_class_name
140  self._serialized_options = serialized_options
141 
142  # Does this descriptor have non-default options?
143  self.has_options = (options is not None) or (serialized_options is not None)
144 
145  def _SetOptions(self, options, options_class_name):
146  """Sets the descriptor's options
147 
148  This function is used in generated proto2 files to update descriptor
149  options. It must not be used outside proto2.
150  """
151  self._options = options
152  self._options_class_name = options_class_name
153 
154  # Does this descriptor have non-default options?
155  self.has_options = options is not None
156 
157  def GetOptions(self):
158  """Retrieves descriptor options.
159 
160  This method returns the options set or creates the default options for the
161  descriptor.
162  """
163  if self._options:
164  return self._options
165 
166  from google.protobuf import descriptor_pb2
167  try:
168  options_class = getattr(descriptor_pb2,
169  self._options_class_name)
170  except AttributeError:
171  raise RuntimeError('Unknown options class name %s!' %
172  (self._options_class_name))
173 
174  with _lock:
175  if self._serialized_options is None:
176  self._options = options_class()
177  else:
178  self._options = _ParseOptions(options_class(),
179  self._serialized_options)
180 
181  return self._options
182 
183 
185  """Common class for descriptors that can be nested."""
186 
187  def __init__(self, options, options_class_name, name, full_name,
188  file, containing_type, serialized_start=None,
189  serialized_end=None, serialized_options=None):
190  """Constructor.
191 
192  Args:
193  options: Protocol message options or None
194  to use default message options.
195  options_class_name (str): The class name of the above options.
196  name (str): Name of this protocol message type.
197  full_name (str): Fully-qualified name of this protocol message type,
198  which will include protocol "package" name and the name of any
199  enclosing types.
200  file (FileDescriptor): Reference to file info.
201  containing_type: if provided, this is a nested descriptor, with this
202  descriptor as parent, otherwise None.
203  serialized_start: The start index (inclusive) in block in the
204  file.serialized_pb that describes this descriptor.
205  serialized_end: The end index (exclusive) in block in the
206  file.serialized_pb that describes this descriptor.
207  serialized_options: Protocol message serialized options or None.
208  """
209  super(_NestedDescriptorBase, self).__init__(
210  options, serialized_options, options_class_name)
211 
212  self.name = name
213  # TODO(falk): Add function to calculate full_name instead of having it in
214  # memory?
215  self.full_name = full_name
216  self.file = file
217  self.containing_type = containing_type
218 
219  self._serialized_start = serialized_start
220  self._serialized_end = serialized_end
221 
222  def CopyToProto(self, proto):
223  """Copies this to the matching proto in descriptor_pb2.
224 
225  Args:
226  proto: An empty proto instance from descriptor_pb2.
227 
228  Raises:
229  Error: If self couldn't be serialized, due to to few constructor
230  arguments.
231  """
232  if (self.file is not None and
233  self._serialized_start is not None and
234  self._serialized_end is not None):
235  proto.ParseFromString(self.file.serialized_pb[
237  else:
238  raise Error('Descriptor does not contain serialization.')
239 
240 
242 
243  """Descriptor for a protocol message type.
244 
245  Attributes:
246  name (str): Name of this protocol message type.
247  full_name (str): Fully-qualified name of this protocol message type,
248  which will include protocol "package" name and the name of any
249  enclosing types.
250  containing_type (Descriptor): Reference to the descriptor of the type
251  containing us, or None if this is top-level.
252  fields (list[FieldDescriptor]): Field descriptors for all fields in
253  this type.
254  fields_by_number (dict(int, FieldDescriptor)): Same
255  :class:`FieldDescriptor` objects as in :attr:`fields`, but indexed
256  by "number" attribute in each FieldDescriptor.
257  fields_by_name (dict(str, FieldDescriptor)): Same
258  :class:`FieldDescriptor` objects as in :attr:`fields`, but indexed by
259  "name" attribute in each :class:`FieldDescriptor`.
260  nested_types (list[Descriptor]): Descriptor references
261  for all protocol message types nested within this one.
262  nested_types_by_name (dict(str, Descriptor)): Same Descriptor
263  objects as in :attr:`nested_types`, but indexed by "name" attribute
264  in each Descriptor.
265  enum_types (list[EnumDescriptor]): :class:`EnumDescriptor` references
266  for all enums contained within this type.
267  enum_types_by_name (dict(str, EnumDescriptor)): Same
268  :class:`EnumDescriptor` objects as in :attr:`enum_types`, but
269  indexed by "name" attribute in each EnumDescriptor.
270  enum_values_by_name (dict(str, EnumValueDescriptor)): Dict mapping
271  from enum value name to :class:`EnumValueDescriptor` for that value.
272  extensions (list[FieldDescriptor]): All extensions defined directly
273  within this message type (NOT within a nested type).
274  extensions_by_name (dict(str, FieldDescriptor)): Same FieldDescriptor
275  objects as :attr:`extensions`, but indexed by "name" attribute of each
276  FieldDescriptor.
277  is_extendable (bool): Does this type define any extension ranges?
278  oneofs (list[OneofDescriptor]): The list of descriptors for oneof fields
279  in this message.
280  oneofs_by_name (dict(str, OneofDescriptor)): Same objects as in
281  :attr:`oneofs`, but indexed by "name" attribute.
282  file (FileDescriptor): Reference to file descriptor.
283 
284  """
285 
286  if _USE_C_DESCRIPTORS:
287  _C_DESCRIPTOR_CLASS = _message.Descriptor
288 
289  def __new__(
290  cls,
291  name=None,
292  full_name=None,
293  filename=None,
294  containing_type=None,
295  fields=None,
296  nested_types=None,
297  enum_types=None,
298  extensions=None,
299  options=None,
300  serialized_options=None,
301  is_extendable=True,
302  extension_ranges=None,
303  oneofs=None,
304  file=None, # pylint: disable=redefined-builtin
305  serialized_start=None,
306  serialized_end=None,
307  syntax=None,
308  create_key=None):
309  _message.Message._CheckCalledFromGeneratedFile()
310  return _message.default_pool.FindMessageTypeByName(full_name)
311 
312  # NOTE(tmarek): The file argument redefining a builtin is nothing we can
313  # fix right now since we don't know how many clients already rely on the
314  # name of the argument.
315  def __init__(self, name, full_name, filename, containing_type, fields,
316  nested_types, enum_types, extensions, options=None,
317  serialized_options=None,
318  is_extendable=True, extension_ranges=None, oneofs=None,
319  file=None, serialized_start=None, serialized_end=None, # pylint: disable=redefined-builtin
320  syntax=None, create_key=None):
321  """Arguments to __init__() are as described in the description
322  of Descriptor fields above.
323 
324  Note that filename is an obsolete argument, that is not used anymore.
325  Please use file.name to access this as an attribute.
326  """
327  if create_key is not _internal_create_key:
328  _Deprecated('Descriptor')
329 
330  super(Descriptor, self).__init__(
331  options, 'MessageOptions', name, full_name, file,
332  containing_type, serialized_start=serialized_start,
333  serialized_end=serialized_end, serialized_options=serialized_options)
334 
335  # We have fields in addition to fields_by_name and fields_by_number,
336  # so that:
337  # 1. Clients can index fields by "order in which they're listed."
338  # 2. Clients can easily iterate over all fields with the terse
339  # syntax: for f in descriptor.fields: ...
340  self.fields = fields
341  for field in self.fields:
342  field.containing_type = self
343  self.fields_by_number = dict((f.number, f) for f in fields)
344  self.fields_by_name = dict((f.name, f) for f in fields)
345  self._fields_by_camelcase_name = None
346 
347  self.nested_types = nested_types
348  for nested_type in nested_types:
349  nested_type.containing_type = self
350  self.nested_types_by_name = dict((t.name, t) for t in nested_types)
351 
352  self.enum_types = enum_types
353  for enum_type in self.enum_types:
354  enum_type.containing_type = self
355  self.enum_types_by_name = dict((t.name, t) for t in enum_types)
356  self.enum_values_by_name = dict(
357  (v.name, v) for t in enum_types for v in t.values)
358 
359  self.extensions = extensions
360  for extension in self.extensions:
361  extension.extension_scope = self
362  self.extensions_by_name = dict((f.name, f) for f in extensions)
363  self.is_extendable = is_extendable
364  self.extension_ranges = extension_ranges
365  self.oneofs = oneofs if oneofs is not None else []
366  self.oneofs_by_name = dict((o.name, o) for o in self.oneofs)
367  for oneof in self.oneofs:
368  oneof.containing_type = self
369  self.syntax = syntax or "proto2"
370 
371  @property
373  """Same FieldDescriptor objects as in :attr:`fields`, but indexed by
374  :attr:`FieldDescriptor.camelcase_name`.
375  """
376  if self._fields_by_camelcase_name is None:
377  self._fields_by_camelcase_name = dict(
378  (f.camelcase_name, f) for f in self.fields)
379  return self._fields_by_camelcase_name
380 
381  def EnumValueName(self, enum, value):
382  """Returns the string name of an enum value.
383 
384  This is just a small helper method to simplify a common operation.
385 
386  Args:
387  enum: string name of the Enum.
388  value: int, value of the enum.
389 
390  Returns:
391  string name of the enum value.
392 
393  Raises:
394  KeyError if either the Enum doesn't exist or the value is not a valid
395  value for the enum.
396  """
397  return self.enum_types_by_name[enum].values_by_number[value].name
398 
399  def CopyToProto(self, proto):
400  """Copies this to a descriptor_pb2.DescriptorProto.
401 
402  Args:
403  proto: An empty descriptor_pb2.DescriptorProto.
404  """
405  # This function is overridden to give a better doc comment.
406  super(Descriptor, self).CopyToProto(proto)
407 
408 
409 # TODO(robinson): We should have aggressive checking here,
410 # for example:
411 # * If you specify a repeated field, you should not be allowed
412 # to specify a default value.
413 # * [Other examples here as needed].
414 #
415 # TODO(robinson): for this and other *Descriptor classes, we
416 # might also want to lock things down aggressively (e.g.,
417 # prevent clients from setting the attributes). Having
418 # stronger invariants here in general will reduce the number
419 # of runtime checks we must do in reflection.py...
421 
422  """Descriptor for a single field in a .proto file.
423 
424  Attributes:
425  name (str): Name of this field, exactly as it appears in .proto.
426  full_name (str): Name of this field, including containing scope. This is
427  particularly relevant for extensions.
428  index (int): Dense, 0-indexed index giving the order that this
429  field textually appears within its message in the .proto file.
430  number (int): Tag number declared for this field in the .proto file.
431 
432  type (int): (One of the TYPE_* constants below) Declared type.
433  cpp_type (int): (One of the CPPTYPE_* constants below) C++ type used to
434  represent this field.
435 
436  label (int): (One of the LABEL_* constants below) Tells whether this
437  field is optional, required, or repeated.
438  has_default_value (bool): True if this field has a default value defined,
439  otherwise false.
440  default_value (Varies): Default value of this field. Only
441  meaningful for non-repeated scalar fields. Repeated fields
442  should always set this to [], and non-repeated composite
443  fields should always set this to None.
444 
445  containing_type (Descriptor): Descriptor of the protocol message
446  type that contains this field. Set by the Descriptor constructor
447  if we're passed into one.
448  Somewhat confusingly, for extension fields, this is the
449  descriptor of the EXTENDED message, not the descriptor
450  of the message containing this field. (See is_extension and
451  extension_scope below).
452  message_type (Descriptor): If a composite field, a descriptor
453  of the message type contained in this field. Otherwise, this is None.
454  enum_type (EnumDescriptor): If this field contains an enum, a
455  descriptor of that enum. Otherwise, this is None.
456 
457  is_extension: True iff this describes an extension field.
458  extension_scope (Descriptor): Only meaningful if is_extension is True.
459  Gives the message that immediately contains this extension field.
460  Will be None iff we're a top-level (file-level) extension field.
461 
462  options (descriptor_pb2.FieldOptions): Protocol message field options or
463  None to use default field options.
464 
465  containing_oneof (OneofDescriptor): If the field is a member of a oneof
466  union, contains its descriptor. Otherwise, None.
467 
468  file (FileDescriptor): Reference to file descriptor.
469  """
470 
471  # Must be consistent with C++ FieldDescriptor::Type enum in
472  # descriptor.h.
473  #
474  # TODO(robinson): Find a way to eliminate this repetition.
475  TYPE_DOUBLE = 1
476  TYPE_FLOAT = 2
477  TYPE_INT64 = 3
478  TYPE_UINT64 = 4
479  TYPE_INT32 = 5
480  TYPE_FIXED64 = 6
481  TYPE_FIXED32 = 7
482  TYPE_BOOL = 8
483  TYPE_STRING = 9
484  TYPE_GROUP = 10
485  TYPE_MESSAGE = 11
486  TYPE_BYTES = 12
487  TYPE_UINT32 = 13
488  TYPE_ENUM = 14
489  TYPE_SFIXED32 = 15
490  TYPE_SFIXED64 = 16
491  TYPE_SINT32 = 17
492  TYPE_SINT64 = 18
493  MAX_TYPE = 18
494 
495  # Must be consistent with C++ FieldDescriptor::CppType enum in
496  # descriptor.h.
497  #
498  # TODO(robinson): Find a way to eliminate this repetition.
499  CPPTYPE_INT32 = 1
500  CPPTYPE_INT64 = 2
501  CPPTYPE_UINT32 = 3
502  CPPTYPE_UINT64 = 4
503  CPPTYPE_DOUBLE = 5
504  CPPTYPE_FLOAT = 6
505  CPPTYPE_BOOL = 7
506  CPPTYPE_ENUM = 8
507  CPPTYPE_STRING = 9
508  CPPTYPE_MESSAGE = 10
509  MAX_CPPTYPE = 10
510 
511  _PYTHON_TO_CPP_PROTO_TYPE_MAP = {
512  TYPE_DOUBLE: CPPTYPE_DOUBLE,
513  TYPE_FLOAT: CPPTYPE_FLOAT,
514  TYPE_ENUM: CPPTYPE_ENUM,
515  TYPE_INT64: CPPTYPE_INT64,
516  TYPE_SINT64: CPPTYPE_INT64,
517  TYPE_SFIXED64: CPPTYPE_INT64,
518  TYPE_UINT64: CPPTYPE_UINT64,
519  TYPE_FIXED64: CPPTYPE_UINT64,
520  TYPE_INT32: CPPTYPE_INT32,
521  TYPE_SFIXED32: CPPTYPE_INT32,
522  TYPE_SINT32: CPPTYPE_INT32,
523  TYPE_UINT32: CPPTYPE_UINT32,
524  TYPE_FIXED32: CPPTYPE_UINT32,
525  TYPE_BYTES: CPPTYPE_STRING,
526  TYPE_STRING: CPPTYPE_STRING,
527  TYPE_BOOL: CPPTYPE_BOOL,
528  TYPE_MESSAGE: CPPTYPE_MESSAGE,
529  TYPE_GROUP: CPPTYPE_MESSAGE
530  }
531 
532  # Must be consistent with C++ FieldDescriptor::Label enum in
533  # descriptor.h.
534  #
535  # TODO(robinson): Find a way to eliminate this repetition.
536  LABEL_OPTIONAL = 1
537  LABEL_REQUIRED = 2
538  LABEL_REPEATED = 3
539  MAX_LABEL = 3
540 
541  # Must be consistent with C++ constants kMaxNumber, kFirstReservedNumber,
542  # and kLastReservedNumber in descriptor.h
543  MAX_FIELD_NUMBER = (1 << 29) - 1
544  FIRST_RESERVED_FIELD_NUMBER = 19000
545  LAST_RESERVED_FIELD_NUMBER = 19999
546 
547  if _USE_C_DESCRIPTORS:
548  _C_DESCRIPTOR_CLASS = _message.FieldDescriptor
549 
550  def __new__(cls, name, full_name, index, number, type, cpp_type, label,
551  default_value, message_type, enum_type, containing_type,
552  is_extension, extension_scope, options=None,
553  serialized_options=None,
554  has_default_value=True, containing_oneof=None, json_name=None,
555  file=None, create_key=None): # pylint: disable=redefined-builtin
556  _message.Message._CheckCalledFromGeneratedFile()
557  if is_extension:
558  return _message.default_pool.FindExtensionByName(full_name)
559  else:
560  return _message.default_pool.FindFieldByName(full_name)
561 
562  def __init__(self, name, full_name, index, number, type, cpp_type, label,
563  default_value, message_type, enum_type, containing_type,
564  is_extension, extension_scope, options=None,
565  serialized_options=None,
566  has_default_value=True, containing_oneof=None, json_name=None,
567  file=None, create_key=None): # pylint: disable=redefined-builtin
568  """The arguments are as described in the description of FieldDescriptor
569  attributes above.
570 
571  Note that containing_type may be None, and may be set later if necessary
572  (to deal with circular references between message types, for example).
573  Likewise for extension_scope.
574  """
575  if create_key is not _internal_create_key:
576  _Deprecated('FieldDescriptor')
577 
578  super(FieldDescriptor, self).__init__(
579  options, serialized_options, 'FieldOptions')
580  self.name = name
581  self.full_name = full_name
582  self.file = file
583  self._camelcase_name = None
584  if json_name is None:
585  self.json_name = _ToJsonName(name)
586  else:
587  self.json_name = json_name
588  self.index = index
589  self.number = number
590  self.type = type
591  self.cpp_type = cpp_type
592  self.label = label
593  self.has_default_value = has_default_value
594  self.default_value = default_value
595  self.containing_type = containing_type
596  self.message_type = message_type
597  self.enum_type = enum_type
598  self.is_extension = is_extension
599  self.extension_scope = extension_scope
600  self.containing_oneof = containing_oneof
601  if api_implementation.Type() == 'cpp':
602  if is_extension:
603  self._cdescriptor = _message.default_pool.FindExtensionByName(full_name)
604  else:
605  self._cdescriptor = _message.default_pool.FindFieldByName(full_name)
606  else:
607  self._cdescriptor = None
608 
609  @property
610  def camelcase_name(self):
611  """Camelcase name of this field.
612 
613  Returns:
614  str: the name in CamelCase.
615  """
616  if self._camelcase_name is None:
617  self._camelcase_name = _ToCamelCase(self.name)
618  return self._camelcase_name
619 
620  @staticmethod
621  def ProtoTypeToCppProtoType(proto_type):
622  """Converts from a Python proto type to a C++ Proto Type.
623 
624  The Python ProtocolBuffer classes specify both the 'Python' datatype and the
625  'C++' datatype - and they're not the same. This helper method should
626  translate from one to another.
627 
628  Args:
629  proto_type: the Python proto type (descriptor.FieldDescriptor.TYPE_*)
630  Returns:
631  int: descriptor.FieldDescriptor.CPPTYPE_*, the C++ type.
632  Raises:
633  TypeTransformationError: when the Python proto type isn't known.
634  """
635  try:
636  return FieldDescriptor._PYTHON_TO_CPP_PROTO_TYPE_MAP[proto_type]
637  except KeyError:
638  raise TypeTransformationError('Unknown proto_type: %s' % proto_type)
639 
640 
642 
643  """Descriptor for an enum defined in a .proto file.
644 
645  Attributes:
646  name (str): Name of the enum type.
647  full_name (str): Full name of the type, including package name
648  and any enclosing type(s).
649 
650  values (list[EnumValueDescriptors]): List of the values
651  in this enum.
652  values_by_name (dict(str, EnumValueDescriptor)): Same as :attr:`values`,
653  but indexed by the "name" field of each EnumValueDescriptor.
654  values_by_number (dict(int, EnumValueDescriptor)): Same as :attr:`values`,
655  but indexed by the "number" field of each EnumValueDescriptor.
656  containing_type (Descriptor): Descriptor of the immediate containing
657  type of this enum, or None if this is an enum defined at the
658  top level in a .proto file. Set by Descriptor's constructor
659  if we're passed into one.
660  file (FileDescriptor): Reference to file descriptor.
661  options (descriptor_pb2.EnumOptions): Enum options message or
662  None to use default enum options.
663  """
664 
665  if _USE_C_DESCRIPTORS:
666  _C_DESCRIPTOR_CLASS = _message.EnumDescriptor
667 
668  def __new__(cls, name, full_name, filename, values,
669  containing_type=None, options=None,
670  serialized_options=None, file=None, # pylint: disable=redefined-builtin
671  serialized_start=None, serialized_end=None, create_key=None):
672  _message.Message._CheckCalledFromGeneratedFile()
673  return _message.default_pool.FindEnumTypeByName(full_name)
674 
675  def __init__(self, name, full_name, filename, values,
676  containing_type=None, options=None,
677  serialized_options=None, file=None, # pylint: disable=redefined-builtin
678  serialized_start=None, serialized_end=None, create_key=None):
679  """Arguments are as described in the attribute description above.
680 
681  Note that filename is an obsolete argument, that is not used anymore.
682  Please use file.name to access this as an attribute.
683  """
684  if create_key is not _internal_create_key:
685  _Deprecated('EnumDescriptor')
686 
687  super(EnumDescriptor, self).__init__(
688  options, 'EnumOptions', name, full_name, file,
689  containing_type, serialized_start=serialized_start,
690  serialized_end=serialized_end, serialized_options=serialized_options)
691 
692  self.values = values
693  for value in self.values:
694  value.type = self
695  self.values_by_name = dict((v.name, v) for v in values)
696  # Values are reversed to ensure that the first alias is retained.
697  self.values_by_number = dict((v.number, v) for v in reversed(values))
698 
699  def CopyToProto(self, proto):
700  """Copies this to a descriptor_pb2.EnumDescriptorProto.
701 
702  Args:
703  proto (descriptor_pb2.EnumDescriptorProto): An empty descriptor proto.
704  """
705  # This function is overridden to give a better doc comment.
706  super(EnumDescriptor, self).CopyToProto(proto)
707 
708 
710 
711  """Descriptor for a single value within an enum.
712 
713  Attributes:
714  name (str): Name of this value.
715  index (int): Dense, 0-indexed index giving the order that this
716  value appears textually within its enum in the .proto file.
717  number (int): Actual number assigned to this enum value.
718  type (EnumDescriptor): :class:`EnumDescriptor` to which this value
719  belongs. Set by :class:`EnumDescriptor`'s constructor if we're
720  passed into one.
721  options (descriptor_pb2.EnumValueOptions): Enum value options message or
722  None to use default enum value options options.
723  """
724 
725  if _USE_C_DESCRIPTORS:
726  _C_DESCRIPTOR_CLASS = _message.EnumValueDescriptor
727 
728  def __new__(cls, name, index, number,
729  type=None, # pylint: disable=redefined-builtin
730  options=None, serialized_options=None, create_key=None):
731  _message.Message._CheckCalledFromGeneratedFile()
732  # There is no way we can build a complete EnumValueDescriptor with the
733  # given parameters (the name of the Enum is not known, for example).
734  # Fortunately generated files just pass it to the EnumDescriptor()
735  # constructor, which will ignore it, so returning None is good enough.
736  return None
737 
738  def __init__(self, name, index, number,
739  type=None, # pylint: disable=redefined-builtin
740  options=None, serialized_options=None, create_key=None):
741  """Arguments are as described in the attribute description above."""
742  if create_key is not _internal_create_key:
743  _Deprecated('EnumValueDescriptor')
744 
745  super(EnumValueDescriptor, self).__init__(
746  options, serialized_options, 'EnumValueOptions')
747  self.name = name
748  self.index = index
749  self.number = number
750  self.type = type
751 
752 
754  """Descriptor for a oneof field.
755 
756  Attributes:
757  name (str): Name of the oneof field.
758  full_name (str): Full name of the oneof field, including package name.
759  index (int): 0-based index giving the order of the oneof field inside
760  its containing type.
761  containing_type (Descriptor): :class:`Descriptor` of the protocol message
762  type that contains this field. Set by the :class:`Descriptor` constructor
763  if we're passed into one.
764  fields (list[FieldDescriptor]): The list of field descriptors this
765  oneof can contain.
766  """
767 
768  if _USE_C_DESCRIPTORS:
769  _C_DESCRIPTOR_CLASS = _message.OneofDescriptor
770 
771  def __new__(
772  cls, name, full_name, index, containing_type, fields, options=None,
773  serialized_options=None, create_key=None):
774  _message.Message._CheckCalledFromGeneratedFile()
775  return _message.default_pool.FindOneofByName(full_name)
776 
777  def __init__(
778  self, name, full_name, index, containing_type, fields, options=None,
779  serialized_options=None, create_key=None):
780  """Arguments are as described in the attribute description above."""
781  if create_key is not _internal_create_key:
782  _Deprecated('OneofDescriptor')
783 
784  super(OneofDescriptor, self).__init__(
785  options, serialized_options, 'OneofOptions')
786  self.name = name
787  self.full_name = full_name
788  self.index = index
789  self.containing_type = containing_type
790  self.fields = fields
791 
792 
794 
795  """Descriptor for a service.
796 
797  Attributes:
798  name (str): Name of the service.
799  full_name (str): Full name of the service, including package name.
800  index (int): 0-indexed index giving the order that this services
801  definition appears within the .proto file.
802  methods (list[MethodDescriptor]): List of methods provided by this
803  service.
804  methods_by_name (dict(str, MethodDescriptor)): Same
805  :class:`MethodDescriptor` objects as in :attr:`methods_by_name`, but
806  indexed by "name" attribute in each :class:`MethodDescriptor`.
807  options (descriptor_pb2.ServiceOptions): Service options message or
808  None to use default service options.
809  file (FileDescriptor): Reference to file info.
810  """
811 
812  if _USE_C_DESCRIPTORS:
813  _C_DESCRIPTOR_CLASS = _message.ServiceDescriptor
814 
815  def __new__(
816  cls,
817  name=None,
818  full_name=None,
819  index=None,
820  methods=None,
821  options=None,
822  serialized_options=None,
823  file=None, # pylint: disable=redefined-builtin
824  serialized_start=None,
825  serialized_end=None,
826  create_key=None):
827  _message.Message._CheckCalledFromGeneratedFile() # pylint: disable=protected-access
828  return _message.default_pool.FindServiceByName(full_name)
829 
830  def __init__(self, name, full_name, index, methods, options=None,
831  serialized_options=None, file=None, # pylint: disable=redefined-builtin
832  serialized_start=None, serialized_end=None, create_key=None):
833  if create_key is not _internal_create_key:
834  _Deprecated('ServiceDescriptor')
835 
836  super(ServiceDescriptor, self).__init__(
837  options, 'ServiceOptions', name, full_name, file,
838  None, serialized_start=serialized_start,
839  serialized_end=serialized_end, serialized_options=serialized_options)
840  self.index = index
841  self.methods = methods
842  self.methods_by_name = dict((m.name, m) for m in methods)
843  # Set the containing service for each method in this service.
844  for method in self.methods:
845  method.containing_service = self
846 
847  def FindMethodByName(self, name):
848  """Searches for the specified method, and returns its descriptor.
849 
850  Args:
851  name (str): Name of the method.
852  Returns:
853  MethodDescriptor or None: the descriptor for the requested method, if
854  found.
855  """
856  return self.methods_by_name.get(name, None)
857 
858  def CopyToProto(self, proto):
859  """Copies this to a descriptor_pb2.ServiceDescriptorProto.
860 
861  Args:
862  proto (descriptor_pb2.ServiceDescriptorProto): An empty descriptor proto.
863  """
864  # This function is overridden to give a better doc comment.
865  super(ServiceDescriptor, self).CopyToProto(proto)
866 
867 
869 
870  """Descriptor for a method in a service.
871 
872  Attributes:
873  name (str): Name of the method within the service.
874  full_name (str): Full name of method.
875  index (int): 0-indexed index of the method inside the service.
876  containing_service (ServiceDescriptor): The service that contains this
877  method.
878  input_type (Descriptor): The descriptor of the message that this method
879  accepts.
880  output_type (Descriptor): The descriptor of the message that this method
881  returns.
882  options (descriptor_pb2.MethodOptions or None): Method options message, or
883  None to use default method options.
884  """
885 
886  if _USE_C_DESCRIPTORS:
887  _C_DESCRIPTOR_CLASS = _message.MethodDescriptor
888 
889  def __new__(cls, name, full_name, index, containing_service,
890  input_type, output_type, options=None, serialized_options=None,
891  create_key=None):
892  _message.Message._CheckCalledFromGeneratedFile() # pylint: disable=protected-access
893  return _message.default_pool.FindMethodByName(full_name)
894 
895  def __init__(self, name, full_name, index, containing_service,
896  input_type, output_type, options=None, serialized_options=None,
897  create_key=None):
898  """The arguments are as described in the description of MethodDescriptor
899  attributes above.
900 
901  Note that containing_service may be None, and may be set later if necessary.
902  """
903  if create_key is not _internal_create_key:
904  _Deprecated('MethodDescriptor')
905 
906  super(MethodDescriptor, self).__init__(
907  options, serialized_options, 'MethodOptions')
908  self.name = name
909  self.full_name = full_name
910  self.index = index
911  self.containing_service = containing_service
912  self.input_type = input_type
913  self.output_type = output_type
914 
915  def CopyToProto(self, proto):
916  """Copies this to a descriptor_pb2.MethodDescriptorProto.
917 
918  Args:
919  proto (descriptor_pb2.MethodDescriptorProto): An empty descriptor proto.
920 
921  Raises:
922  Error: If self couldn't be serialized, due to too few constructor
923  arguments.
924  """
925  if self.containing_service is not None:
926  from google.protobuf import descriptor_pb2
927  service_proto = descriptor_pb2.ServiceDescriptorProto()
928  self.containing_service.CopyToProto(service_proto)
929  proto.CopyFrom(service_proto.method[self.index])
930  else:
931  raise Error('Descriptor does not contain a service.')
932 
933 
935  """Descriptor for a file. Mimics the descriptor_pb2.FileDescriptorProto.
936 
937  Note that :attr:`enum_types_by_name`, :attr:`extensions_by_name`, and
938  :attr:`dependencies` fields are only set by the
939  :py:mod:`google.protobuf.message_factory` module, and not by the generated
940  proto code.
941 
942  Attributes:
943  name (str): Name of file, relative to root of source tree.
944  package (str): Name of the package
945  syntax (str): string indicating syntax of the file (can be "proto2" or
946  "proto3")
947  serialized_pb (bytes): Byte string of serialized
948  :class:`descriptor_pb2.FileDescriptorProto`.
949  dependencies (list[FileDescriptor]): List of other :class:`FileDescriptor`
950  objects this :class:`FileDescriptor` depends on.
951  public_dependencies (list[FileDescriptor]): A subset of
952  :attr:`dependencies`, which were declared as "public".
953  message_types_by_name (dict(str, Descriptor)): Mapping from message names
954  to their :class:`Descriptor`.
955  enum_types_by_name (dict(str, EnumDescriptor)): Mapping from enum names to
956  their :class:`EnumDescriptor`.
957  extensions_by_name (dict(str, FieldDescriptor)): Mapping from extension
958  names declared at file scope to their :class:`FieldDescriptor`.
959  services_by_name (dict(str, ServiceDescriptor)): Mapping from services'
960  names to their :class:`ServiceDescriptor`.
961  pool (DescriptorPool): The pool this descriptor belongs to. When not
962  passed to the constructor, the global default pool is used.
963  """
964 
965  if _USE_C_DESCRIPTORS:
966  _C_DESCRIPTOR_CLASS = _message.FileDescriptor
967 
968  def __new__(cls, name, package, options=None,
969  serialized_options=None, serialized_pb=None,
970  dependencies=None, public_dependencies=None,
971  syntax=None, pool=None, create_key=None):
972  # FileDescriptor() is called from various places, not only from generated
973  # files, to register dynamic proto files and messages.
974  # pylint: disable=g-explicit-bool-comparison
975  if serialized_pb == b'':
976  # Cpp generated code must be linked in if serialized_pb is ''
977  try:
978  return _message.default_pool.FindFileByName(name)
979  except KeyError:
980  raise RuntimeError('Please link in cpp generated lib for %s' % (name))
981  elif serialized_pb:
982  return _message.default_pool.AddSerializedFile(serialized_pb)
983  else:
984  return super(FileDescriptor, cls).__new__(cls)
985 
986  def __init__(self, name, package, options=None,
987  serialized_options=None, serialized_pb=None,
988  dependencies=None, public_dependencies=None,
989  syntax=None, pool=None, create_key=None):
990  """Constructor."""
991  if create_key is not _internal_create_key:
992  _Deprecated('FileDescriptor')
993 
994  super(FileDescriptor, self).__init__(
995  options, serialized_options, 'FileOptions')
996 
997  if pool is None:
998  from google.protobuf import descriptor_pool
999  pool = descriptor_pool.Default()
1000  self.pool = pool
1001  self.message_types_by_name = {}
1002  self.name = name
1003  self.package = package
1004  self.syntax = syntax or "proto2"
1005  self.serialized_pb = serialized_pb
1006 
1007  self.enum_types_by_name = {}
1008  self.extensions_by_name = {}
1009  self.services_by_name = {}
1010  self.dependencies = (dependencies or [])
1011  self.public_dependencies = (public_dependencies or [])
1012 
1013  def CopyToProto(self, proto):
1014  """Copies this to a descriptor_pb2.FileDescriptorProto.
1015 
1016  Args:
1017  proto: An empty descriptor_pb2.FileDescriptorProto.
1018  """
1019  proto.ParseFromString(self.serialized_pb)
1020 
1021 
1022 def _ParseOptions(message, string):
1023  """Parses serialized options.
1024 
1025  This helper function is used to parse serialized options in generated
1026  proto2 files. It must not be used outside proto2.
1027  """
1028  message.ParseFromString(string)
1029  return message
1030 
1031 
1032 def _ToCamelCase(name):
1033  """Converts name to camel-case and returns it."""
1034  capitalize_next = False
1035  result = []
1036 
1037  for c in name:
1038  if c == '_':
1039  if result:
1040  capitalize_next = True
1041  elif capitalize_next:
1042  result.append(c.upper())
1043  capitalize_next = False
1044  else:
1045  result += c
1046 
1047  # Lower-case the first letter.
1048  if result and result[0].isupper():
1049  result[0] = result[0].lower()
1050  return ''.join(result)
1051 
1052 
1053 def _OptionsOrNone(descriptor_proto):
1054  """Returns the value of the field `options`, or None if it is not set."""
1055  if descriptor_proto.HasField('options'):
1056  return descriptor_proto.options
1057  else:
1058  return None
1059 
1060 
1061 def _ToJsonName(name):
1062  """Converts name to Json name and returns it."""
1063  capitalize_next = False
1064  result = []
1065 
1066  for c in name:
1067  if c == '_':
1068  capitalize_next = True
1069  elif capitalize_next:
1070  result.append(c.upper())
1071  capitalize_next = False
1072  else:
1073  result += c
1074 
1075  return ''.join(result)
1076 
1077 
1078 def MakeDescriptor(desc_proto, package='', build_file_if_cpp=True,
1079  syntax=None):
1080  """Make a protobuf Descriptor given a DescriptorProto protobuf.
1081 
1082  Handles nested descriptors. Note that this is limited to the scope of defining
1083  a message inside of another message. Composite fields can currently only be
1084  resolved if the message is defined in the same scope as the field.
1085 
1086  Args:
1087  desc_proto: The descriptor_pb2.DescriptorProto protobuf message.
1088  package: Optional package name for the new message Descriptor (string).
1089  build_file_if_cpp: Update the C++ descriptor pool if api matches.
1090  Set to False on recursion, so no duplicates are created.
1091  syntax: The syntax/semantics that should be used. Set to "proto3" to get
1092  proto3 field presence semantics.
1093  Returns:
1094  A Descriptor for protobuf messages.
1095  """
1096  if api_implementation.Type() == 'cpp' and build_file_if_cpp:
1097  # The C++ implementation requires all descriptors to be backed by the same
1098  # definition in the C++ descriptor pool. To do this, we build a
1099  # FileDescriptorProto with the same definition as this descriptor and build
1100  # it into the pool.
1101  from google.protobuf import descriptor_pb2
1102  file_descriptor_proto = descriptor_pb2.FileDescriptorProto()
1103  file_descriptor_proto.message_type.add().MergeFrom(desc_proto)
1104 
1105  # Generate a random name for this proto file to prevent conflicts with any
1106  # imported ones. We need to specify a file name so the descriptor pool
1107  # accepts our FileDescriptorProto, but it is not important what that file
1108  # name is actually set to.
1109  proto_name = binascii.hexlify(os.urandom(16)).decode('ascii')
1110 
1111  if package:
1112  file_descriptor_proto.name = os.path.join(package.replace('.', '/'),
1113  proto_name + '.proto')
1114  file_descriptor_proto.package = package
1115  else:
1116  file_descriptor_proto.name = proto_name + '.proto'
1117 
1118  _message.default_pool.Add(file_descriptor_proto)
1119  result = _message.default_pool.FindFileByName(file_descriptor_proto.name)
1120 
1121  if _USE_C_DESCRIPTORS:
1122  return result.message_types_by_name[desc_proto.name]
1123 
1124  full_message_name = [desc_proto.name]
1125  if package: full_message_name.insert(0, package)
1126 
1127  # Create Descriptors for enum types
1128  enum_types = {}
1129  for enum_proto in desc_proto.enum_type:
1130  full_name = '.'.join(full_message_name + [enum_proto.name])
1131  enum_desc = EnumDescriptor(
1132  enum_proto.name, full_name, None, [
1133  EnumValueDescriptor(enum_val.name, ii, enum_val.number,
1134  create_key=_internal_create_key)
1135  for ii, enum_val in enumerate(enum_proto.value)],
1136  create_key=_internal_create_key)
1137  enum_types[full_name] = enum_desc
1138 
1139  # Create Descriptors for nested types
1140  nested_types = {}
1141  for nested_proto in desc_proto.nested_type:
1142  full_name = '.'.join(full_message_name + [nested_proto.name])
1143  # Nested types are just those defined inside of the message, not all types
1144  # used by fields in the message, so no loops are possible here.
1145  nested_desc = MakeDescriptor(nested_proto,
1146  package='.'.join(full_message_name),
1147  build_file_if_cpp=False,
1148  syntax=syntax)
1149  nested_types[full_name] = nested_desc
1150 
1151  fields = []
1152  for field_proto in desc_proto.field:
1153  full_name = '.'.join(full_message_name + [field_proto.name])
1154  enum_desc = None
1155  nested_desc = None
1156  if field_proto.json_name:
1157  json_name = field_proto.json_name
1158  else:
1159  json_name = None
1160  if field_proto.HasField('type_name'):
1161  type_name = field_proto.type_name
1162  full_type_name = '.'.join(full_message_name +
1163  [type_name[type_name.rfind('.')+1:]])
1164  if full_type_name in nested_types:
1165  nested_desc = nested_types[full_type_name]
1166  elif full_type_name in enum_types:
1167  enum_desc = enum_types[full_type_name]
1168  # Else type_name references a non-local type, which isn't implemented
1169  field = FieldDescriptor(
1170  field_proto.name, full_name, field_proto.number - 1,
1171  field_proto.number, field_proto.type,
1172  FieldDescriptor.ProtoTypeToCppProtoType(field_proto.type),
1173  field_proto.label, None, nested_desc, enum_desc, None, False, None,
1174  options=_OptionsOrNone(field_proto), has_default_value=False,
1175  json_name=json_name, create_key=_internal_create_key)
1176  fields.append(field)
1177 
1178  desc_name = '.'.join(full_message_name)
1179  return Descriptor(desc_proto.name, desc_name, None, None, fields,
1180  list(nested_types.values()), list(enum_types.values()), [],
1181  options=_OptionsOrNone(desc_proto),
1182  create_key=_internal_create_key)
google::protobuf.descriptor._ParseOptions
def _ParseOptions(message, string)
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:920
google::protobuf.descriptor._NestedDescriptorBase
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:165
google::protobuf.descriptor.OneofDescriptor
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:713
google::protobuf.descriptor.OneofDescriptor.__init__
def __init__(self, name, full_name, index, containing_type, fields, options=None, serialized_options=None)
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:736
google::protobuf.descriptor.Descriptor.extensions
extensions
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:329
google::protobuf.descriptor.FileDescriptor.dependencies
dependencies
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:901
google::protobuf.descriptor.Descriptor.EnumValueName
def EnumValueName(self, enum, value)
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:353
get
absl::string_view get(const Cont &c)
Definition: abseil-cpp/absl/strings/str_replace_test.cc:185
google::protobuf.descriptor.ServiceDescriptor
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:749
google::protobuf.descriptor.ServiceDescriptor.methods
methods
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:782
google::protobuf.descriptor._ToCamelCase
def _ToCamelCase(name)
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:930
google::protobuf.descriptor._Lock
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:76
google::protobuf.descriptor.FileDescriptor
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:844
google::protobuf.descriptor.DescriptorBase.GetOptions
def GetOptions(self)
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:138
google::protobuf.internal.python_message.MergeFrom
MergeFrom
Definition: bloaty/third_party/protobuf/python/google/protobuf/internal/python_message.py:1339
google::protobuf.descriptor.Descriptor.nested_types_by_name
nested_types_by_name
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:320
google::protobuf.descriptor.DescriptorMetaclass
DescriptorMetaclass
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:73
google::protobuf.descriptor.FieldDescriptor.index
index
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:554
google::protobuf.descriptor._NestedDescriptorBase.__init__
def __init__(self, options, options_class_name, name, full_name, file, containing_type, serialized_start=None, serialized_end=None, serialized_options=None)
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:168
google::protobuf.descriptor.FieldDescriptor.camelcase_name
def camelcase_name(self)
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:581
google::protobuf.pyext
Definition: third_party/bloaty/third_party/protobuf/python/google/protobuf/pyext/__init__.py:1
google::protobuf.descriptor.MethodDescriptor.index
index
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:837
google::protobuf.descriptor.MethodDescriptor
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:804
google::protobuf.descriptor.EnumValueDescriptor.__init__
def __init__(self, name, index, number, type=None, options=None, serialized_options=None)
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:701
google::protobuf
Definition: bloaty/third_party/protobuf/benchmarks/util/data_proto2_to_proto3_util.h:12
google::protobuf.descriptor.DescriptorBase.__init__
def __init__(self, options, serialized_options, options_class_name)
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:114
google::protobuf.descriptor.Descriptor.enum_types_by_name
enum_types_by_name
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:325
cpp.ast.reversed
def reversed(seq)
Definition: bloaty/third_party/googletest/googlemock/scripts/generator/cpp/ast.py:52
google::protobuf.descriptor.OneofDescriptor.fields
fields
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:744
google::protobuf.descriptor.MakeDescriptor
def MakeDescriptor(desc_proto, package='', build_file_if_cpp=True, syntax=None)
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:976
google::protobuf.descriptor.FileDescriptor.message_types_by_name
message_types_by_name
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:892
google::protobuf.descriptor.FieldDescriptor.type
type
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:556
google::protobuf.descriptor.DescriptorBase._serialized_options
_serialized_options
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:121
google::protobuf.descriptor.Descriptor.fields
fields
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:310
google::protobuf.descriptor.Descriptor.extensions_by_name
extensions_by_name
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:332
google::protobuf.descriptor.Descriptor
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:222
google::protobuf.descriptor.ServiceDescriptor.index
index
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:781
google::protobuf.descriptor.Descriptor.nested_types
nested_types
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:317
google::protobuf.descriptor._NestedDescriptorBase.containing_type
containing_type
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:197
google::protobuf.descriptor.DescriptorBase._SetOptions
def _SetOptions(self, options, options_class_name)
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:126
google::protobuf.descriptor.DescriptorMetaclass.__instancecheck__
def __instancecheck__(cls, obj)
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:65
google::protobuf.descriptor.Descriptor.is_extendable
is_extendable
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:333
google::protobuf.descriptor.EnumDescriptor.values
values
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:653
google::protobuf.descriptor.FieldDescriptor.is_extension
is_extension
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:564
google::protobuf.descriptor.MethodDescriptor.name
name
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:835
google::protobuf.descriptor.ServiceDescriptor.__new__
def __new__(cls, name, full_name, index, methods, options=None, serialized_options=None, file=None, serialized_start=None, serialized_end=None)
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:770
google::protobuf.descriptor.FieldDescriptor.default_value
default_value
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:560
google::protobuf.descriptor.FieldDescriptor.json_name
json_name
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:551
google::protobuf.internal
Definition: third_party/bloaty/third_party/protobuf/python/google/protobuf/internal/__init__.py:1
google::protobuf.descriptor.FieldDescriptor.cpp_type
cpp_type
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:557
google::protobuf.descriptor._NestedDescriptorBase._serialized_start
_serialized_start
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:199
google::protobuf.descriptor.ServiceDescriptor.FindMethodByName
def FindMethodByName(self, name)
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:790
google::protobuf.descriptor.DescriptorBase.has_options
has_options
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:124
google::protobuf.descriptor.EnumDescriptor.__init__
def __init__(self, name, full_name, filename, values, containing_type=None, options=None, serialized_options=None, file=None, serialized_start=None, serialized_end=None)
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:642
google::protobuf.descriptor.Descriptor.CopyToProto
def CopyToProto(self, proto)
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:371
google::protobuf.descriptor.EnumValueDescriptor.number
number
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:707
google::protobuf.descriptor.FieldDescriptor.__new__
def __new__(cls, name, full_name, index, number, type, cpp_type, label, default_value, message_type, enum_type, containing_type, is_extension, extension_scope, options=None, serialized_options=None, has_default_value=True, containing_oneof=None, json_name=None, file=None)
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:524
google::protobuf.descriptor.Descriptor.enum_values_by_name
enum_values_by_name
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:326
google::protobuf.descriptor.FileDescriptor.extensions_by_name
extensions_by_name
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:899
google::protobuf.descriptor.FileDescriptor.pool
pool
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:891
google::protobuf.descriptor.EnumDescriptor.CopyToProto
def CopyToProto(self, proto)
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:663
google::protobuf.descriptor.FieldDescriptor._camelcase_name
_camelcase_name
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:549
google::protobuf.descriptor.FileDescriptor.__init__
def __init__(self, name, package, options=None, serialized_options=None, serialized_pb=None, dependencies=None, public_dependencies=None, syntax=None, pool=None)
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:883
google::protobuf.descriptor.MethodDescriptor.__new__
def __new__(cls, name, full_name, index, containing_service, input_type, output_type, options=None, serialized_options=None)
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:822
google::protobuf.descriptor._Deprecated
def _Deprecated(name)
Definition: protobuf/python/google/protobuf/descriptor.py:94
google::protobuf.descriptor.Descriptor.oneofs
oneofs
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:335
google::protobuf.descriptor.MethodDescriptor.output_type
output_type
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:840
google::protobuf.descriptor.FieldDescriptor.containing_type
containing_type
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:561
google::protobuf.descriptor.EnumDescriptor.values_by_number
values_by_number
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:658
google::protobuf.descriptor.FieldDescriptor.containing_oneof
containing_oneof
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:566
google::protobuf.descriptor.Descriptor.oneofs_by_name
oneofs_by_name
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:336
google::protobuf.descriptor.FileDescriptor.serialized_pb
serialized_pb
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:896
google::protobuf.descriptor.OneofDescriptor.name
name
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:740
google::protobuf.descriptor.EnumDescriptor.__new__
def __new__(cls, name, full_name, filename, values, containing_type=None, options=None, serialized_options=None, file=None, serialized_start=None, serialized_end=None)
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:635
google::protobuf.descriptor.Descriptor.enum_types
enum_types
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:322
google::protobuf.descriptor._NestedDescriptorBase.full_name
full_name
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:195
google::protobuf.descriptor.Error
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:51
google::protobuf.descriptor._Lock.__enter__
def __enter__(self)
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:84
google::protobuf.descriptor._Lock._lock
_lock
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:81
google::protobuf.descriptor.FieldDescriptor.full_name
full_name
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:547
google::protobuf.descriptor.EnumValueDescriptor
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:673
google::protobuf.descriptor._NestedDescriptorBase._serialized_end
_serialized_end
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:200
google::protobuf.descriptor.Descriptor.extension_ranges
extension_ranges
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:334
google::protobuf.descriptor.FileDescriptor.CopyToProto
def CopyToProto(self, proto)
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:911
google::protobuf.descriptor.OneofDescriptor.containing_type
containing_type
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:743
google::protobuf.descriptor.FieldDescriptor
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:392
google::protobuf.descriptor.FileDescriptor.services_by_name
services_by_name
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:900
google::protobuf.descriptor.Descriptor.fields_by_name
fields_by_name
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:314
google::protobuf.descriptor.FileDescriptor.package
package
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:894
google::protobuf.descriptor.FieldDescriptor.message_type
message_type
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:562
google::protobuf.descriptor.EnumValueDescriptor.index
index
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:706
google::protobuf.descriptor.FileDescriptor.enum_types_by_name
enum_types_by_name
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:898
google::protobuf.descriptor.FileDescriptor.public_dependencies
public_dependencies
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:902
google::protobuf.descriptor.Descriptor.__init__
def __init__(self, name, full_name, filename, containing_type, fields, nested_types, enum_types, extensions, options=None, serialized_options=None, is_extendable=True, extension_ranges=None, oneofs=None, file=None, serialized_start=None, serialized_end=None, syntax=None)
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:293
google::protobuf.descriptor.FieldDescriptor.ProtoTypeToCppProtoType
def ProtoTypeToCppProtoType(proto_type)
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:587
google::protobuf.descriptor.Descriptor.fields_by_number
fields_by_number
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:313
google::protobuf.descriptor.MethodDescriptor.input_type
input_type
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:839
google::protobuf.descriptor.TypeTransformationError
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:55
google::protobuf.descriptor.EnumDescriptor.values_by_name
values_by_name
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:656
google::protobuf.descriptor.MethodDescriptor.CopyToProto
def CopyToProto(self, proto)
Definition: protobuf/python/google/protobuf/descriptor.py:915
google::protobuf.descriptor.Descriptor.fields_by_camelcase_name
def fields_by_camelcase_name(self)
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:347
google::protobuf.descriptor._Lock.__new__
def __new__(cls)
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:79
google::protobuf.descriptor.FieldDescriptor.enum_type
enum_type
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:563
google::protobuf.descriptor.FieldDescriptor.name
name
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:546
google::protobuf.descriptor.FieldDescriptor.extension_scope
extension_scope
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:565
grpc._common.decode
def decode(b)
Definition: grpc/_common.py:75
google::protobuf.descriptor.MethodDescriptor.containing_service
containing_service
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:838
google::protobuf.descriptor.EnumValueDescriptor.type
type
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:708
google::protobuf.descriptor.MethodDescriptor.__init__
def __init__(self, name, full_name, index, containing_service, input_type, output_type, options=None, serialized_options=None)
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:827
google::protobuf.descriptor.DescriptorBase
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:94
google::protobuf.descriptor.Descriptor.syntax
syntax
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:339
google::protobuf.descriptor._NestedDescriptorBase.file
file
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:196
release
return ret release()
Definition: doc/python/sphinx/conf.py:37
google::protobuf.descriptor.FieldDescriptor.file
file
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:548
google::protobuf.descriptor.FileDescriptor.name
name
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:893
google::protobuf.descriptor._Lock.__exit__
def __exit__(self, exc_type, exc_value, exc_tb)
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:87
google::protobuf.descriptor.OneofDescriptor.__new__
def __new__(cls, name, full_name, index, containing_type, fields, options=None, serialized_options=None)
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:730
google::protobuf.descriptor.Descriptor.__new__
def __new__(cls, name, full_name, filename, containing_type, fields, nested_types, enum_types, extensions, options=None, serialized_options=None, is_extendable=True, extension_ranges=None, oneofs=None, file=None, serialized_start=None, serialized_end=None, syntax=None)
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:281
google::protobuf.descriptor.FieldDescriptor.label
label
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:558
google::protobuf.descriptor.OneofDescriptor.index
index
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:742
google::protobuf.descriptor.Descriptor._fields_by_camelcase_name
_fields_by_camelcase_name
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:315
google::protobuf.descriptor.EnumValueDescriptor.name
name
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:705
google::protobuf.descriptor.FileDescriptor.__new__
def __new__(cls, name, package, options=None, serialized_options=None, serialized_pb=None, dependencies=None, public_dependencies=None, syntax=None, pool=None)
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:870
google::protobuf.descriptor.EnumValueDescriptor.__new__
def __new__(cls, name, index, number, type=None, options=None, serialized_options=None)
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:691
google::protobuf.descriptor.DescriptorBase._options
_options
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:119
google::protobuf.descriptor._ToJsonName
def _ToJsonName(name)
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:959
google::protobuf.descriptor.FieldDescriptor.has_default_value
has_default_value
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:559
asyncio_get_stats.type
type
Definition: asyncio_get_stats.py:37
google::protobuf.descriptor.OneofDescriptor.full_name
full_name
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:741
google::protobuf.descriptor.ServiceDescriptor.methods_by_name
methods_by_name
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:783
google::protobuf.descriptor.FieldDescriptor._cdescriptor
_cdescriptor
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:569
google::protobuf.descriptor.FieldDescriptor.__init__
def __init__(self, name, full_name, index, number, type, cpp_type, label, default_value, message_type, enum_type, containing_type, is_extension, extension_scope, options=None, serialized_options=None, has_default_value=True, containing_oneof=None, json_name=None, file=None)
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:536
google::protobuf.descriptor._OptionsOrNone
def _OptionsOrNone(descriptor_proto)
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:951
google::protobuf.descriptor.MethodDescriptor.full_name
full_name
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:836
google::protobuf.descriptor._NestedDescriptorBase.CopyToProto
def CopyToProto(self, proto)
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:204
google::protobuf.descriptor.ServiceDescriptor.__init__
def __init__(self, name, full_name, index, methods, options=None, serialized_options=None, file=None, serialized_start=None, serialized_end=None)
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:776
google::protobuf.descriptor.ServiceDescriptor.CopyToProto
def CopyToProto(self, proto)
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:794
google::protobuf.descriptor.EnumDescriptor
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:607
google::protobuf.descriptor.DescriptorBase._options_class_name
_options_class_name
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:120
google::protobuf.descriptor.FieldDescriptor.number
number
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:555
google::protobuf.descriptor.FileDescriptor.syntax
syntax
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:895
google::protobuf.descriptor._NestedDescriptorBase.name
name
Definition: bloaty/third_party/protobuf/python/google/protobuf/descriptor.py:192


grpc
Author(s):
autogenerated on Fri May 16 2025 02:58:14