py2docfx 0.1.20rc2196756__py3-none-any.whl → 0.1.20rc2245107__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- py2docfx/venv/basevenv/Lib/site-packages/charset_normalizer/api.py +3 -2
- py2docfx/venv/basevenv/Lib/site-packages/charset_normalizer/legacy.py +17 -1
- py2docfx/venv/basevenv/Lib/site-packages/charset_normalizer/version.py +1 -1
- py2docfx/venv/basevenv/Lib/site-packages/requests/__version__.py +2 -2
- py2docfx/venv/basevenv/Lib/site-packages/requests/adapters.py +17 -40
- py2docfx/venv/basevenv/Lib/site-packages/requests/sessions.py +1 -1
- py2docfx/venv/venv1/Lib/site-packages/azure/core/_version.py +1 -1
- py2docfx/venv/venv1/Lib/site-packages/azure/core/pipeline/policies/_authentication.py +21 -9
- py2docfx/venv/venv1/Lib/site-packages/azure/core/pipeline/policies/_authentication_async.py +21 -9
- py2docfx/venv/venv1/Lib/site-packages/azure/core/pipeline/policies/_retry.py +1 -1
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/_bearer_token_provider.py +1 -1
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/_credentials/authorization_code.py +1 -1
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/_credentials/azd_cli.py +82 -17
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/_credentials/azure_cli.py +28 -5
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/_credentials/azure_powershell.py +28 -4
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/_credentials/broker.py +79 -0
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/_credentials/chained.py +9 -3
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/_credentials/default.py +153 -53
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/_credentials/imds.py +25 -1
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/_credentials/shared_cache.py +12 -5
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/_credentials/vscode.py +163 -144
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/_credentials/workload_identity.py +23 -12
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/_internal/__init__.py +4 -0
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/_internal/interactive.py +14 -2
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/_internal/pipeline.py +4 -2
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/_internal/utils.py +96 -0
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/_version.py +1 -1
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_bearer_token_provider.py +3 -3
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/authorization_code.py +1 -1
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/azd_cli.py +32 -13
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/azure_cli.py +26 -5
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/azure_powershell.py +13 -2
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/chained.py +1 -1
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/default.py +120 -55
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/imds.py +27 -1
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/on_behalf_of.py +1 -1
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/shared_cache.py +12 -5
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/vscode.py +15 -67
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/workload_identity.py +17 -13
- py2docfx/venv/venv1/Lib/site-packages/cffi/__init__.py +2 -2
- py2docfx/venv/venv1/Lib/site-packages/cffi/cparser.py +1 -1
- py2docfx/venv/venv1/Lib/site-packages/cffi/recompiler.py +5 -5
- py2docfx/venv/venv1/Lib/site-packages/cffi/setuptools_ext.py +13 -0
- py2docfx/venv/venv1/Lib/site-packages/cffi/vengine_cpy.py +3 -0
- py2docfx/venv/venv1/Lib/site-packages/charset_normalizer/api.py +3 -2
- py2docfx/venv/venv1/Lib/site-packages/charset_normalizer/legacy.py +17 -1
- py2docfx/venv/venv1/Lib/site-packages/charset_normalizer/version.py +1 -1
- py2docfx/venv/venv1/Lib/site-packages/cryptography/__about__.py +1 -1
- py2docfx/venv/venv1/Lib/site-packages/cryptography/__init__.py +0 -13
- py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/_oid.py +8 -0
- py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/asn1/__init__.py +10 -0
- py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/asn1/asn1.py +116 -0
- py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/backends/openssl/backend.py +3 -9
- py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/declarative_asn1.pyi +32 -0
- py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/openssl/kdf.pyi +23 -0
- py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/x509.pyi +1 -13
- py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/openssl/_conditional.py +16 -0
- py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/openssl/binding.py +16 -1
- py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/asymmetric/padding.py +0 -2
- py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/asymmetric/rsa.py +8 -0
- py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/ciphers/algorithms.py +0 -47
- py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/kdf/hkdf.py +6 -91
- py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/kdf/kbkdf.py +1 -3
- py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/serialization/ssh.py +1 -1
- py2docfx/venv/venv1/Lib/site-packages/cryptography/utils.py +0 -2
- py2docfx/venv/venv1/Lib/site-packages/cryptography/x509/name.py +2 -3
- py2docfx/venv/venv1/Lib/site-packages/google/protobuf/__init__.py +1 -1
- py2docfx/venv/venv1/Lib/site-packages/google/protobuf/any_pb2.py +2 -2
- py2docfx/venv/venv1/Lib/site-packages/google/protobuf/api_pb2.py +12 -8
- py2docfx/venv/venv1/Lib/site-packages/google/protobuf/compiler/plugin_pb2.py +2 -2
- py2docfx/venv/venv1/Lib/site-packages/google/protobuf/descriptor.py +398 -246
- py2docfx/venv/venv1/Lib/site-packages/google/protobuf/descriptor_pb2.py +74 -72
- py2docfx/venv/venv1/Lib/site-packages/google/protobuf/descriptor_pool.py +5 -4
- py2docfx/venv/venv1/Lib/site-packages/google/protobuf/duration_pb2.py +2 -2
- py2docfx/venv/venv1/Lib/site-packages/google/protobuf/empty_pb2.py +2 -2
- py2docfx/venv/venv1/Lib/site-packages/google/protobuf/field_mask_pb2.py +2 -2
- py2docfx/venv/venv1/Lib/site-packages/google/protobuf/internal/api_implementation.py +0 -6
- py2docfx/venv/venv1/Lib/site-packages/google/protobuf/internal/extension_dict.py +3 -3
- py2docfx/venv/venv1/Lib/site-packages/google/protobuf/internal/field_mask.py +3 -3
- py2docfx/venv/venv1/Lib/site-packages/google/protobuf/internal/python_edition_defaults.py +1 -1
- py2docfx/venv/venv1/Lib/site-packages/google/protobuf/internal/python_message.py +10 -2
- py2docfx/venv/venv1/Lib/site-packages/google/protobuf/internal/type_checkers.py +47 -5
- py2docfx/venv/venv1/Lib/site-packages/google/protobuf/json_format.py +55 -32
- py2docfx/venv/venv1/Lib/site-packages/google/protobuf/runtime_version.py +6 -26
- py2docfx/venv/venv1/Lib/site-packages/google/protobuf/source_context_pb2.py +2 -2
- py2docfx/venv/venv1/Lib/site-packages/google/protobuf/struct_pb2.py +2 -2
- py2docfx/venv/venv1/Lib/site-packages/google/protobuf/text_format.py +30 -19
- py2docfx/venv/venv1/Lib/site-packages/google/protobuf/timestamp_pb2.py +2 -2
- py2docfx/venv/venv1/Lib/site-packages/google/protobuf/type_pb2.py +2 -2
- py2docfx/venv/venv1/Lib/site-packages/google/protobuf/wrappers_pb2.py +2 -2
- py2docfx/venv/venv1/Lib/site-packages/pycparser/__init__.py +1 -1
- py2docfx/venv/venv1/Lib/site-packages/pycparser/c_generator.py +1 -1
- py2docfx/venv/venv1/Lib/site-packages/pycparser/c_lexer.py +14 -0
- py2docfx/venv/venv1/Lib/site-packages/pycparser/c_parser.py +30 -7
- py2docfx/venv/venv1/Lib/site-packages/pycparser/lextab.py +1 -1
- py2docfx/venv/venv1/Lib/site-packages/pycparser/yacctab.py +132 -127
- py2docfx/venv/venv1/Lib/site-packages/requests/__version__.py +2 -2
- py2docfx/venv/venv1/Lib/site-packages/requests/adapters.py +17 -40
- py2docfx/venv/venv1/Lib/site-packages/requests/sessions.py +1 -1
- py2docfx/venv/venv1/Lib/site-packages/typing_extensions.py +91 -18
- {py2docfx-0.1.20rc2196756.dist-info → py2docfx-0.1.20rc2245107.dist-info}/METADATA +1 -1
- {py2docfx-0.1.20rc2196756.dist-info → py2docfx-0.1.20rc2245107.dist-info}/RECORD +104 -103
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/_internal/linux_vscode_adapter.py +0 -100
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/_internal/macos_vscode_adapter.py +0 -34
- py2docfx/venv/venv1/Lib/site-packages/azure/identity/_internal/win_vscode_adapter.py +0 -77
- {py2docfx-0.1.20rc2196756.dist-info → py2docfx-0.1.20rc2245107.dist-info}/WHEEL +0 -0
- {py2docfx-0.1.20rc2196756.dist-info → py2docfx-0.1.20rc2245107.dist-info}/top_level.txt +0 -0
@@ -6,6 +6,7 @@
|
|
6
6
|
# https://developers.google.com/open-source/licenses/bsd
|
7
7
|
|
8
8
|
"""Descriptors essentially contain exactly the information found in a .proto
|
9
|
+
|
9
10
|
file, in types that make this information accessible in Python.
|
10
11
|
"""
|
11
12
|
|
@@ -50,6 +51,7 @@ if _USE_C_DESCRIPTORS:
|
|
50
51
|
if isinstance(obj, cls._C_DESCRIPTOR_CLASS):
|
51
52
|
return True
|
52
53
|
return False
|
54
|
+
|
53
55
|
else:
|
54
56
|
# The standard metaclass; nothing changes.
|
55
57
|
DescriptorMetaclass = abc.ABCMeta
|
@@ -73,15 +75,18 @@ class _Lock(object):
|
|
73
75
|
_lock = threading.Lock()
|
74
76
|
|
75
77
|
|
76
|
-
def _Deprecated(
|
78
|
+
def _Deprecated(
|
79
|
+
name,
|
80
|
+
alternative='get/find descriptors from generated code or query the descriptor_pool',
|
81
|
+
):
|
77
82
|
if _Deprecated.count > 0:
|
78
83
|
_Deprecated.count -= 1
|
79
84
|
warnings.warn(
|
80
|
-
'Call to deprecated
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
+
'Call to deprecated %s, use %s instead.' % (name, alternative),
|
86
|
+
category=DeprecationWarning,
|
87
|
+
stacklevel=3,
|
88
|
+
)
|
89
|
+
|
85
90
|
|
86
91
|
# These must match the values in descriptor.proto, but we can't use them
|
87
92
|
# directly because we sometimes need to reference them in feature helpers
|
@@ -101,7 +106,6 @@ _internal_create_key = object()
|
|
101
106
|
|
102
107
|
|
103
108
|
class DescriptorBase(metaclass=DescriptorMetaclass):
|
104
|
-
|
105
109
|
"""Descriptors base class.
|
106
110
|
|
107
111
|
This class is the base of all descriptor classes. It provides common options
|
@@ -123,18 +127,22 @@ class DescriptorBase(metaclass=DescriptorMetaclass):
|
|
123
127
|
|
124
128
|
def __init__(self, file, options, serialized_options, options_class_name):
|
125
129
|
"""Initialize the descriptor given its options message and the name of the
|
130
|
+
|
126
131
|
class of the options message. The name of the class is required in case
|
127
132
|
the options message is None and has to be created.
|
128
133
|
"""
|
129
134
|
self._features = None
|
130
135
|
self.file = file
|
131
|
-
self.
|
132
|
-
|
136
|
+
self._original_options = options
|
137
|
+
# These two fields are duplicated as a compatibility shim for old gencode
|
138
|
+
# that resets them. In 26.x (cl/580304039) we renamed _options to,
|
139
|
+
# _loaded_options breaking backwards compatibility.
|
140
|
+
self._options = self._loaded_options = None
|
133
141
|
self._options_class_name = options_class_name
|
134
142
|
self._serialized_options = serialized_options
|
135
143
|
|
136
144
|
# Does this descriptor have non-default options?
|
137
|
-
self.has_options = (self.
|
145
|
+
self.has_options = (self._original_options is not None) or (
|
138
146
|
self._serialized_options is not None
|
139
147
|
)
|
140
148
|
|
@@ -186,7 +194,8 @@ class DescriptorBase(metaclass=DescriptorMetaclass):
|
|
186
194
|
|
187
195
|
def _LazyLoadOptions(self):
|
188
196
|
"""Lazily initializes descriptor options towards the end of the build."""
|
189
|
-
if self._loaded_options:
|
197
|
+
if self._options and self._loaded_options == self._options:
|
198
|
+
# If neither has been reset by gencode, use the cache.
|
190
199
|
return
|
191
200
|
|
192
201
|
# pylint: disable=g-import-not-at-top
|
@@ -206,12 +215,12 @@ class DescriptorBase(metaclass=DescriptorMetaclass):
|
|
206
215
|
descriptor_pb2.Edition.Value(edition), options_class()
|
207
216
|
)
|
208
217
|
with _lock:
|
209
|
-
self._loaded_options = options_class()
|
218
|
+
self._options = self._loaded_options = options_class()
|
210
219
|
if not self._features:
|
211
220
|
self._features = features
|
212
221
|
else:
|
213
222
|
if not self._serialized_options:
|
214
|
-
options = self.
|
223
|
+
options = self._original_options
|
215
224
|
else:
|
216
225
|
options = _ParseOptions(options_class(), self._serialized_options)
|
217
226
|
|
@@ -220,13 +229,13 @@ class DescriptorBase(metaclass=DescriptorMetaclass):
|
|
220
229
|
descriptor_pb2.Edition.Value(edition), options
|
221
230
|
)
|
222
231
|
with _lock:
|
223
|
-
self._loaded_options = options
|
232
|
+
self._options = self._loaded_options = options
|
224
233
|
if not self._features:
|
225
234
|
self._features = features
|
226
235
|
if options.HasField('features'):
|
227
236
|
options.ClearField('features')
|
228
237
|
if not options.SerializeToString():
|
229
|
-
self._loaded_options = options_class()
|
238
|
+
self._options = self._loaded_options = options_class()
|
230
239
|
self.has_options = False
|
231
240
|
|
232
241
|
def GetOptions(self):
|
@@ -235,17 +244,27 @@ class DescriptorBase(metaclass=DescriptorMetaclass):
|
|
235
244
|
Returns:
|
236
245
|
The options set on this descriptor.
|
237
246
|
"""
|
238
|
-
|
247
|
+
# If either has been reset by gencode, reload options.
|
248
|
+
if not self._options or not self._loaded_options:
|
239
249
|
self._LazyLoadOptions()
|
240
|
-
return self.
|
250
|
+
return self._options
|
241
251
|
|
242
252
|
|
243
253
|
class _NestedDescriptorBase(DescriptorBase):
|
244
254
|
"""Common class for descriptors that can be nested."""
|
245
255
|
|
246
|
-
def __init__(
|
247
|
-
|
248
|
-
|
256
|
+
def __init__(
|
257
|
+
self,
|
258
|
+
options,
|
259
|
+
options_class_name,
|
260
|
+
name,
|
261
|
+
full_name,
|
262
|
+
file,
|
263
|
+
containing_type,
|
264
|
+
serialized_start=None,
|
265
|
+
serialized_end=None,
|
266
|
+
serialized_options=None,
|
267
|
+
):
|
249
268
|
"""Constructor.
|
250
269
|
|
251
270
|
Args:
|
@@ -286,59 +305,60 @@ class _NestedDescriptorBase(DescriptorBase):
|
|
286
305
|
Error: If self couldn't be serialized, due to to few constructor
|
287
306
|
arguments.
|
288
307
|
"""
|
289
|
-
if (
|
290
|
-
self.
|
291
|
-
self.
|
292
|
-
|
293
|
-
|
308
|
+
if (
|
309
|
+
self.file is not None
|
310
|
+
and self._serialized_start is not None
|
311
|
+
and self._serialized_end is not None
|
312
|
+
):
|
313
|
+
proto.ParseFromString(
|
314
|
+
self.file.serialized_pb[self._serialized_start : self._serialized_end]
|
315
|
+
)
|
294
316
|
else:
|
295
317
|
raise Error('Descriptor does not contain serialization.')
|
296
318
|
|
297
319
|
|
298
320
|
class Descriptor(_NestedDescriptorBase):
|
299
|
-
|
300
321
|
"""Descriptor for a protocol message type.
|
301
322
|
|
302
323
|
Attributes:
|
303
324
|
name (str): Name of this protocol message type.
|
304
|
-
full_name (str): Fully-qualified name of this protocol message type,
|
305
|
-
|
306
|
-
|
325
|
+
full_name (str): Fully-qualified name of this protocol message type, which
|
326
|
+
will include protocol "package" name and the name of any enclosing
|
327
|
+
types.
|
307
328
|
containing_type (Descriptor): Reference to the descriptor of the type
|
308
|
-
|
309
|
-
fields (list[FieldDescriptor]): Field descriptors for all fields in
|
310
|
-
|
329
|
+
containing us, or None if this is top-level.
|
330
|
+
fields (list[FieldDescriptor]): Field descriptors for all fields in this
|
331
|
+
type.
|
311
332
|
fields_by_number (dict(int, FieldDescriptor)): Same
|
312
|
-
|
313
|
-
|
314
|
-
fields_by_name (dict(str, FieldDescriptor)): Same
|
315
|
-
|
316
|
-
|
317
|
-
nested_types (list[Descriptor]): Descriptor references
|
318
|
-
|
319
|
-
nested_types_by_name (dict(str, Descriptor)): Same Descriptor
|
320
|
-
|
321
|
-
|
322
|
-
enum_types (list[EnumDescriptor]): :class:`EnumDescriptor` references
|
323
|
-
|
333
|
+
:class:`FieldDescriptor` objects as in :attr:`fields`, but indexed by
|
334
|
+
"number" attribute in each FieldDescriptor.
|
335
|
+
fields_by_name (dict(str, FieldDescriptor)): Same :class:`FieldDescriptor`
|
336
|
+
objects as in :attr:`fields`, but indexed by "name" attribute in each
|
337
|
+
:class:`FieldDescriptor`.
|
338
|
+
nested_types (list[Descriptor]): Descriptor references for all protocol
|
339
|
+
message types nested within this one.
|
340
|
+
nested_types_by_name (dict(str, Descriptor)): Same Descriptor objects as
|
341
|
+
in :attr:`nested_types`, but indexed by "name" attribute in each
|
342
|
+
Descriptor.
|
343
|
+
enum_types (list[EnumDescriptor]): :class:`EnumDescriptor` references for
|
344
|
+
all enums contained within this type.
|
324
345
|
enum_types_by_name (dict(str, EnumDescriptor)): Same
|
325
|
-
|
326
|
-
|
327
|
-
enum_values_by_name (dict(str, EnumValueDescriptor)): Dict mapping
|
328
|
-
|
329
|
-
extensions (list[FieldDescriptor]): All extensions defined directly
|
330
|
-
|
346
|
+
:class:`EnumDescriptor` objects as in :attr:`enum_types`, but indexed by
|
347
|
+
"name" attribute in each EnumDescriptor.
|
348
|
+
enum_values_by_name (dict(str, EnumValueDescriptor)): Dict mapping from
|
349
|
+
enum value name to :class:`EnumValueDescriptor` for that value.
|
350
|
+
extensions (list[FieldDescriptor]): All extensions defined directly within
|
351
|
+
this message type (NOT within a nested type).
|
331
352
|
extensions_by_name (dict(str, FieldDescriptor)): Same FieldDescriptor
|
332
|
-
|
333
|
-
|
353
|
+
objects as :attr:`extensions`, but indexed by "name" attribute of each
|
354
|
+
FieldDescriptor.
|
334
355
|
is_extendable (bool): Does this type define any extension ranges?
|
335
356
|
oneofs (list[OneofDescriptor]): The list of descriptors for oneof fields
|
336
|
-
|
357
|
+
in this message.
|
337
358
|
oneofs_by_name (dict(str, OneofDescriptor)): Same objects as in
|
338
|
-
|
359
|
+
:attr:`oneofs`, but indexed by "name" attribute.
|
339
360
|
file (FileDescriptor): Reference to file descriptor.
|
340
361
|
is_map_entry: If the message type is a map entry.
|
341
|
-
|
342
362
|
"""
|
343
363
|
|
344
364
|
if _USE_C_DESCRIPTORS:
|
@@ -364,32 +384,57 @@ class Descriptor(_NestedDescriptorBase):
|
|
364
384
|
serialized_end=None,
|
365
385
|
syntax=None,
|
366
386
|
is_map_entry=False,
|
367
|
-
create_key=None
|
387
|
+
create_key=None,
|
388
|
+
):
|
368
389
|
_message.Message._CheckCalledFromGeneratedFile()
|
369
390
|
return _message.default_pool.FindMessageTypeByName(full_name)
|
370
391
|
|
371
392
|
# NOTE: The file argument redefining a builtin is nothing we can
|
372
393
|
# fix right now since we don't know how many clients already rely on the
|
373
394
|
# name of the argument.
|
374
|
-
def __init__(
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
395
|
+
def __init__(
|
396
|
+
self,
|
397
|
+
name,
|
398
|
+
full_name,
|
399
|
+
filename,
|
400
|
+
containing_type,
|
401
|
+
fields,
|
402
|
+
nested_types,
|
403
|
+
enum_types,
|
404
|
+
extensions,
|
405
|
+
options=None,
|
406
|
+
serialized_options=None,
|
407
|
+
is_extendable=True,
|
408
|
+
extension_ranges=None,
|
409
|
+
oneofs=None,
|
410
|
+
file=None,
|
411
|
+
serialized_start=None,
|
412
|
+
serialized_end=None, # pylint: disable=redefined-builtin
|
413
|
+
syntax=None,
|
414
|
+
is_map_entry=False,
|
415
|
+
create_key=None,
|
416
|
+
):
|
380
417
|
"""Arguments to __init__() are as described in the description
|
418
|
+
|
381
419
|
of Descriptor fields above.
|
382
420
|
|
383
421
|
Note that filename is an obsolete argument, that is not used anymore.
|
384
422
|
Please use file.name to access this as an attribute.
|
385
423
|
"""
|
386
424
|
if create_key is not _internal_create_key:
|
387
|
-
_Deprecated('Descriptor')
|
425
|
+
_Deprecated('create function Descriptor()')
|
388
426
|
|
389
427
|
super(Descriptor, self).__init__(
|
390
|
-
options,
|
391
|
-
|
392
|
-
|
428
|
+
options,
|
429
|
+
'MessageOptions',
|
430
|
+
name,
|
431
|
+
full_name,
|
432
|
+
file,
|
433
|
+
containing_type,
|
434
|
+
serialized_start=serialized_start,
|
435
|
+
serialized_end=serialized_end,
|
436
|
+
serialized_options=serialized_options,
|
437
|
+
)
|
393
438
|
|
394
439
|
# We have fields in addition to fields_by_name and fields_by_number,
|
395
440
|
# so that:
|
@@ -414,7 +459,8 @@ class Descriptor(_NestedDescriptorBase):
|
|
414
459
|
enum_type.containing_type = self
|
415
460
|
self.enum_types_by_name = dict((t.name, t) for t in enum_types)
|
416
461
|
self.enum_values_by_name = dict(
|
417
|
-
(v.name, v) for t in enum_types for v in t.values
|
462
|
+
(v.name, v) for t in enum_types for v in t.values
|
463
|
+
)
|
418
464
|
|
419
465
|
self.extensions = extensions
|
420
466
|
for extension in self.extensions:
|
@@ -436,11 +482,13 @@ class Descriptor(_NestedDescriptorBase):
|
|
436
482
|
@property
|
437
483
|
def fields_by_camelcase_name(self):
|
438
484
|
"""Same FieldDescriptor objects as in :attr:`fields`, but indexed by
|
485
|
+
|
439
486
|
:attr:`FieldDescriptor.camelcase_name`.
|
440
487
|
"""
|
441
488
|
if self._fields_by_camelcase_name is None:
|
442
489
|
self._fields_by_camelcase_name = dict(
|
443
|
-
(f.camelcase_name, f) for f in self.fields
|
490
|
+
(f.camelcase_name, f) for f in self.fields
|
491
|
+
)
|
444
492
|
return self._fields_by_camelcase_name
|
445
493
|
|
446
494
|
def EnumValueName(self, enum, value):
|
@@ -483,53 +531,42 @@ class Descriptor(_NestedDescriptorBase):
|
|
483
531
|
# stronger invariants here in general will reduce the number
|
484
532
|
# of runtime checks we must do in reflection.py...
|
485
533
|
class FieldDescriptor(DescriptorBase):
|
486
|
-
|
487
534
|
"""Descriptor for a single field in a .proto file.
|
488
535
|
|
489
536
|
Attributes:
|
490
537
|
name (str): Name of this field, exactly as it appears in .proto.
|
491
538
|
full_name (str): Name of this field, including containing scope. This is
|
492
539
|
particularly relevant for extensions.
|
493
|
-
index (int): Dense, 0-indexed index giving the order that this
|
494
|
-
|
540
|
+
index (int): Dense, 0-indexed index giving the order that this field
|
541
|
+
textually appears within its message in the .proto file.
|
495
542
|
number (int): Tag number declared for this field in the .proto file.
|
496
|
-
|
497
543
|
type (int): (One of the TYPE_* constants below) Declared type.
|
498
544
|
cpp_type (int): (One of the CPPTYPE_* constants below) C++ type used to
|
499
545
|
represent this field.
|
500
|
-
|
501
|
-
|
502
|
-
field is optional, required, or repeated.
|
546
|
+
label (int): (One of the LABEL_* constants below) Tells whether this field
|
547
|
+
is optional, required, or repeated.
|
503
548
|
has_default_value (bool): True if this field has a default value defined,
|
504
549
|
otherwise false.
|
505
|
-
default_value (Varies): Default value of this field. Only
|
506
|
-
|
507
|
-
should always set this to
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
message_type (Descriptor): If a composite field, a descriptor
|
518
|
-
of the message type contained in this field. Otherwise, this is None.
|
519
|
-
enum_type (EnumDescriptor): If this field contains an enum, a
|
520
|
-
descriptor of that enum. Otherwise, this is None.
|
521
|
-
|
550
|
+
default_value (Varies): Default value of this field. Only meaningful for
|
551
|
+
non-repeated scalar fields. Repeated fields should always set this to [],
|
552
|
+
and non-repeated composite fields should always set this to None.
|
553
|
+
containing_type (Descriptor): Descriptor of the protocol message type that
|
554
|
+
contains this field. Set by the Descriptor constructor if we're passed
|
555
|
+
into one. Somewhat confusingly, for extension fields, this is the
|
556
|
+
descriptor of the EXTENDED message, not the descriptor of the message
|
557
|
+
containing this field. (See is_extension and extension_scope below).
|
558
|
+
message_type (Descriptor): If a composite field, a descriptor of the message
|
559
|
+
type contained in this field. Otherwise, this is None.
|
560
|
+
enum_type (EnumDescriptor): If this field contains an enum, a descriptor of
|
561
|
+
that enum. Otherwise, this is None.
|
522
562
|
is_extension: True iff this describes an extension field.
|
523
|
-
extension_scope (Descriptor): Only meaningful if is_extension is True.
|
524
|
-
|
525
|
-
|
526
|
-
|
563
|
+
extension_scope (Descriptor): Only meaningful if is_extension is True. Gives
|
564
|
+
the message that immediately contains this extension field. Will be None
|
565
|
+
iff we're a top-level (file-level) extension field.
|
527
566
|
options (descriptor_pb2.FieldOptions): Protocol message field options or
|
528
567
|
None to use default field options.
|
529
|
-
|
530
568
|
containing_oneof (OneofDescriptor): If the field is a member of a oneof
|
531
569
|
union, contains its descriptor. Otherwise, None.
|
532
|
-
|
533
570
|
file (FileDescriptor): Reference to file descriptor.
|
534
571
|
"""
|
535
572
|
|
@@ -537,41 +574,41 @@ class FieldDescriptor(DescriptorBase):
|
|
537
574
|
# descriptor.h.
|
538
575
|
#
|
539
576
|
# TODO: Find a way to eliminate this repetition.
|
540
|
-
TYPE_DOUBLE
|
541
|
-
TYPE_FLOAT
|
542
|
-
TYPE_INT64
|
543
|
-
TYPE_UINT64
|
544
|
-
TYPE_INT32
|
545
|
-
TYPE_FIXED64
|
546
|
-
TYPE_FIXED32
|
547
|
-
TYPE_BOOL
|
548
|
-
TYPE_STRING
|
549
|
-
TYPE_GROUP
|
550
|
-
TYPE_MESSAGE
|
551
|
-
TYPE_BYTES
|
552
|
-
TYPE_UINT32
|
553
|
-
TYPE_ENUM
|
554
|
-
TYPE_SFIXED32
|
555
|
-
TYPE_SFIXED64
|
556
|
-
TYPE_SINT32
|
557
|
-
TYPE_SINT64
|
558
|
-
MAX_TYPE
|
577
|
+
TYPE_DOUBLE = 1
|
578
|
+
TYPE_FLOAT = 2
|
579
|
+
TYPE_INT64 = 3
|
580
|
+
TYPE_UINT64 = 4
|
581
|
+
TYPE_INT32 = 5
|
582
|
+
TYPE_FIXED64 = 6
|
583
|
+
TYPE_FIXED32 = 7
|
584
|
+
TYPE_BOOL = 8
|
585
|
+
TYPE_STRING = 9
|
586
|
+
TYPE_GROUP = 10
|
587
|
+
TYPE_MESSAGE = 11
|
588
|
+
TYPE_BYTES = 12
|
589
|
+
TYPE_UINT32 = 13
|
590
|
+
TYPE_ENUM = 14
|
591
|
+
TYPE_SFIXED32 = 15
|
592
|
+
TYPE_SFIXED64 = 16
|
593
|
+
TYPE_SINT32 = 17
|
594
|
+
TYPE_SINT64 = 18
|
595
|
+
MAX_TYPE = 18
|
559
596
|
|
560
597
|
# Must be consistent with C++ FieldDescriptor::CppType enum in
|
561
598
|
# descriptor.h.
|
562
599
|
#
|
563
600
|
# TODO: Find a way to eliminate this repetition.
|
564
|
-
CPPTYPE_INT32
|
565
|
-
CPPTYPE_INT64
|
566
|
-
CPPTYPE_UINT32
|
567
|
-
CPPTYPE_UINT64
|
568
|
-
CPPTYPE_DOUBLE
|
569
|
-
CPPTYPE_FLOAT
|
570
|
-
CPPTYPE_BOOL
|
571
|
-
CPPTYPE_ENUM
|
572
|
-
CPPTYPE_STRING
|
573
|
-
CPPTYPE_MESSAGE
|
574
|
-
MAX_CPPTYPE
|
601
|
+
CPPTYPE_INT32 = 1
|
602
|
+
CPPTYPE_INT64 = 2
|
603
|
+
CPPTYPE_UINT32 = 3
|
604
|
+
CPPTYPE_UINT64 = 4
|
605
|
+
CPPTYPE_DOUBLE = 5
|
606
|
+
CPPTYPE_FLOAT = 6
|
607
|
+
CPPTYPE_BOOL = 7
|
608
|
+
CPPTYPE_ENUM = 8
|
609
|
+
CPPTYPE_STRING = 9
|
610
|
+
CPPTYPE_MESSAGE = 10
|
611
|
+
MAX_CPPTYPE = 10
|
575
612
|
|
576
613
|
_PYTHON_TO_CPP_PROTO_TYPE_MAP = {
|
577
614
|
TYPE_DOUBLE: CPPTYPE_DOUBLE,
|
@@ -591,17 +628,17 @@ class FieldDescriptor(DescriptorBase):
|
|
591
628
|
TYPE_STRING: CPPTYPE_STRING,
|
592
629
|
TYPE_BOOL: CPPTYPE_BOOL,
|
593
630
|
TYPE_MESSAGE: CPPTYPE_MESSAGE,
|
594
|
-
TYPE_GROUP: CPPTYPE_MESSAGE
|
595
|
-
|
631
|
+
TYPE_GROUP: CPPTYPE_MESSAGE,
|
632
|
+
}
|
596
633
|
|
597
634
|
# Must be consistent with C++ FieldDescriptor::Label enum in
|
598
635
|
# descriptor.h.
|
599
636
|
#
|
600
637
|
# TODO: Find a way to eliminate this repetition.
|
601
|
-
LABEL_OPTIONAL
|
602
|
-
LABEL_REQUIRED
|
603
|
-
LABEL_REPEATED
|
604
|
-
MAX_LABEL
|
638
|
+
LABEL_OPTIONAL = 1
|
639
|
+
LABEL_REQUIRED = 2
|
640
|
+
LABEL_REPEATED = 3
|
641
|
+
MAX_LABEL = 3
|
605
642
|
|
606
643
|
# Must be consistent with C++ constants kMaxNumber, kFirstReservedNumber,
|
607
644
|
# and kLastReservedNumber in descriptor.h
|
@@ -612,25 +649,60 @@ class FieldDescriptor(DescriptorBase):
|
|
612
649
|
if _USE_C_DESCRIPTORS:
|
613
650
|
_C_DESCRIPTOR_CLASS = _message.FieldDescriptor
|
614
651
|
|
615
|
-
def __new__(
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
652
|
+
def __new__(
|
653
|
+
cls,
|
654
|
+
name,
|
655
|
+
full_name,
|
656
|
+
index,
|
657
|
+
number,
|
658
|
+
type,
|
659
|
+
cpp_type,
|
660
|
+
label,
|
661
|
+
default_value,
|
662
|
+
message_type,
|
663
|
+
enum_type,
|
664
|
+
containing_type,
|
665
|
+
is_extension,
|
666
|
+
extension_scope,
|
667
|
+
options=None,
|
668
|
+
serialized_options=None,
|
669
|
+
has_default_value=True,
|
670
|
+
containing_oneof=None,
|
671
|
+
json_name=None,
|
672
|
+
file=None,
|
673
|
+
create_key=None,
|
674
|
+
): # pylint: disable=redefined-builtin
|
621
675
|
_message.Message._CheckCalledFromGeneratedFile()
|
622
676
|
if is_extension:
|
623
677
|
return _message.default_pool.FindExtensionByName(full_name)
|
624
678
|
else:
|
625
679
|
return _message.default_pool.FindFieldByName(full_name)
|
626
680
|
|
627
|
-
def __init__(
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
681
|
+
def __init__(
|
682
|
+
self,
|
683
|
+
name,
|
684
|
+
full_name,
|
685
|
+
index,
|
686
|
+
number,
|
687
|
+
type,
|
688
|
+
cpp_type,
|
689
|
+
label,
|
690
|
+
default_value,
|
691
|
+
message_type,
|
692
|
+
enum_type,
|
693
|
+
containing_type,
|
694
|
+
is_extension,
|
695
|
+
extension_scope,
|
696
|
+
options=None,
|
697
|
+
serialized_options=None,
|
698
|
+
has_default_value=True,
|
699
|
+
containing_oneof=None,
|
700
|
+
json_name=None,
|
701
|
+
file=None,
|
702
|
+
create_key=None,
|
703
|
+
): # pylint: disable=redefined-builtin
|
633
704
|
"""The arguments are as described in the description of FieldDescriptor
|
705
|
+
|
634
706
|
attributes above.
|
635
707
|
|
636
708
|
Note that containing_type may be None, and may be set later if necessary
|
@@ -638,7 +710,7 @@ class FieldDescriptor(DescriptorBase):
|
|
638
710
|
Likewise for extension_scope.
|
639
711
|
"""
|
640
712
|
if create_key is not _internal_create_key:
|
641
|
-
_Deprecated('FieldDescriptor')
|
713
|
+
_Deprecated('create function FieldDescriptor()')
|
642
714
|
|
643
715
|
super(FieldDescriptor, self).__init__(
|
644
716
|
file, options, serialized_options, 'FieldOptions'
|
@@ -721,6 +793,8 @@ class FieldDescriptor(DescriptorBase):
|
|
721
793
|
|
722
794
|
@property
|
723
795
|
def label(self):
|
796
|
+
_Deprecated('label property', 'is_required or is_repeated properties')
|
797
|
+
|
724
798
|
if (
|
725
799
|
self._GetFeatures().field_presence
|
726
800
|
== _FEATURESET_FIELD_PRESENCE_LEGACY_REQUIRED
|
@@ -779,10 +853,12 @@ class FieldDescriptor(DescriptorBase):
|
|
779
853
|
if not self.is_repeated:
|
780
854
|
return False
|
781
855
|
field_type = self.type
|
782
|
-
if (
|
783
|
-
field_type == FieldDescriptor.
|
784
|
-
field_type == FieldDescriptor.
|
785
|
-
field_type == FieldDescriptor.
|
856
|
+
if (
|
857
|
+
field_type == FieldDescriptor.TYPE_STRING
|
858
|
+
or field_type == FieldDescriptor.TYPE_GROUP
|
859
|
+
or field_type == FieldDescriptor.TYPE_MESSAGE
|
860
|
+
or field_type == FieldDescriptor.TYPE_BYTES
|
861
|
+
):
|
786
862
|
return False
|
787
863
|
|
788
864
|
return (
|
@@ -800,6 +876,7 @@ class FieldDescriptor(DescriptorBase):
|
|
800
876
|
|
801
877
|
Args:
|
802
878
|
proto_type: the Python proto type (descriptor.FieldDescriptor.TYPE_*)
|
879
|
+
|
803
880
|
Returns:
|
804
881
|
int: descriptor.FieldDescriptor.CPPTYPE_*, the C++ type.
|
805
882
|
Raises:
|
@@ -812,55 +889,78 @@ class FieldDescriptor(DescriptorBase):
|
|
812
889
|
|
813
890
|
|
814
891
|
class EnumDescriptor(_NestedDescriptorBase):
|
815
|
-
|
816
892
|
"""Descriptor for an enum defined in a .proto file.
|
817
893
|
|
818
894
|
Attributes:
|
819
895
|
name (str): Name of the enum type.
|
820
|
-
full_name (str): Full name of the type, including package name
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
values_by_name (dict(str, EnumValueDescriptor)): Same as :attr:`values`,
|
826
|
-
but indexed by the "name" field of each EnumValueDescriptor.
|
896
|
+
full_name (str): Full name of the type, including package name and any
|
897
|
+
enclosing type(s).
|
898
|
+
values (list[EnumValueDescriptor]): List of the values in this enum.
|
899
|
+
values_by_name (dict(str, EnumValueDescriptor)): Same as :attr:`values`, but
|
900
|
+
indexed by the "name" field of each EnumValueDescriptor.
|
827
901
|
values_by_number (dict(int, EnumValueDescriptor)): Same as :attr:`values`,
|
828
902
|
but indexed by the "number" field of each EnumValueDescriptor.
|
829
|
-
containing_type (Descriptor): Descriptor of the immediate containing
|
830
|
-
|
831
|
-
|
832
|
-
if we're passed into one.
|
903
|
+
containing_type (Descriptor): Descriptor of the immediate containing type of
|
904
|
+
this enum, or None if this is an enum defined at the top level in a .proto
|
905
|
+
file. Set by Descriptor's constructor if we're passed into one.
|
833
906
|
file (FileDescriptor): Reference to file descriptor.
|
834
|
-
options (descriptor_pb2.EnumOptions): Enum options message or
|
835
|
-
|
907
|
+
options (descriptor_pb2.EnumOptions): Enum options message or None to use
|
908
|
+
default enum options.
|
836
909
|
"""
|
837
910
|
|
838
911
|
if _USE_C_DESCRIPTORS:
|
839
912
|
_C_DESCRIPTOR_CLASS = _message.EnumDescriptor
|
840
913
|
|
841
|
-
def __new__(
|
842
|
-
|
843
|
-
|
844
|
-
|
914
|
+
def __new__(
|
915
|
+
cls,
|
916
|
+
name,
|
917
|
+
full_name,
|
918
|
+
filename,
|
919
|
+
values,
|
920
|
+
containing_type=None,
|
921
|
+
options=None,
|
922
|
+
serialized_options=None,
|
923
|
+
file=None, # pylint: disable=redefined-builtin
|
924
|
+
serialized_start=None,
|
925
|
+
serialized_end=None,
|
926
|
+
create_key=None,
|
927
|
+
):
|
845
928
|
_message.Message._CheckCalledFromGeneratedFile()
|
846
929
|
return _message.default_pool.FindEnumTypeByName(full_name)
|
847
930
|
|
848
|
-
def __init__(
|
849
|
-
|
850
|
-
|
851
|
-
|
931
|
+
def __init__(
|
932
|
+
self,
|
933
|
+
name,
|
934
|
+
full_name,
|
935
|
+
filename,
|
936
|
+
values,
|
937
|
+
containing_type=None,
|
938
|
+
options=None,
|
939
|
+
serialized_options=None,
|
940
|
+
file=None, # pylint: disable=redefined-builtin
|
941
|
+
serialized_start=None,
|
942
|
+
serialized_end=None,
|
943
|
+
create_key=None,
|
944
|
+
):
|
852
945
|
"""Arguments are as described in the attribute description above.
|
853
946
|
|
854
947
|
Note that filename is an obsolete argument, that is not used anymore.
|
855
948
|
Please use file.name to access this as an attribute.
|
856
949
|
"""
|
857
950
|
if create_key is not _internal_create_key:
|
858
|
-
_Deprecated('EnumDescriptor')
|
951
|
+
_Deprecated('create function EnumDescriptor()')
|
859
952
|
|
860
953
|
super(EnumDescriptor, self).__init__(
|
861
|
-
options,
|
862
|
-
|
863
|
-
|
954
|
+
options,
|
955
|
+
'EnumOptions',
|
956
|
+
name,
|
957
|
+
full_name,
|
958
|
+
file,
|
959
|
+
containing_type,
|
960
|
+
serialized_start=serialized_start,
|
961
|
+
serialized_end=serialized_end,
|
962
|
+
serialized_options=serialized_options,
|
963
|
+
)
|
864
964
|
|
865
965
|
self.values = values
|
866
966
|
for value in self.values:
|
@@ -909,17 +1009,15 @@ class EnumDescriptor(_NestedDescriptorBase):
|
|
909
1009
|
|
910
1010
|
|
911
1011
|
class EnumValueDescriptor(DescriptorBase):
|
912
|
-
|
913
1012
|
"""Descriptor for a single value within an enum.
|
914
1013
|
|
915
1014
|
Attributes:
|
916
1015
|
name (str): Name of this value.
|
917
|
-
index (int): Dense, 0-indexed index giving the order that this
|
918
|
-
|
1016
|
+
index (int): Dense, 0-indexed index giving the order that this value appears
|
1017
|
+
textually within its enum in the .proto file.
|
919
1018
|
number (int): Actual number assigned to this enum value.
|
920
|
-
type (EnumDescriptor): :class:`EnumDescriptor` to which this value
|
921
|
-
|
922
|
-
passed into one.
|
1019
|
+
type (EnumDescriptor): :class:`EnumDescriptor` to which this value belongs.
|
1020
|
+
Set by :class:`EnumDescriptor`'s constructor if we're passed into one.
|
923
1021
|
options (descriptor_pb2.EnumValueOptions): Enum value options message or
|
924
1022
|
None to use default enum value options options.
|
925
1023
|
"""
|
@@ -927,9 +1025,16 @@ class EnumValueDescriptor(DescriptorBase):
|
|
927
1025
|
if _USE_C_DESCRIPTORS:
|
928
1026
|
_C_DESCRIPTOR_CLASS = _message.EnumValueDescriptor
|
929
1027
|
|
930
|
-
def __new__(
|
931
|
-
|
932
|
-
|
1028
|
+
def __new__(
|
1029
|
+
cls,
|
1030
|
+
name,
|
1031
|
+
index,
|
1032
|
+
number,
|
1033
|
+
type=None, # pylint: disable=redefined-builtin
|
1034
|
+
options=None,
|
1035
|
+
serialized_options=None,
|
1036
|
+
create_key=None,
|
1037
|
+
):
|
933
1038
|
_message.Message._CheckCalledFromGeneratedFile()
|
934
1039
|
# There is no way we can build a complete EnumValueDescriptor with the
|
935
1040
|
# given parameters (the name of the Enum is not known, for example).
|
@@ -937,12 +1042,19 @@ class EnumValueDescriptor(DescriptorBase):
|
|
937
1042
|
# constructor, which will ignore it, so returning None is good enough.
|
938
1043
|
return None
|
939
1044
|
|
940
|
-
def __init__(
|
941
|
-
|
942
|
-
|
1045
|
+
def __init__(
|
1046
|
+
self,
|
1047
|
+
name,
|
1048
|
+
index,
|
1049
|
+
number,
|
1050
|
+
type=None, # pylint: disable=redefined-builtin
|
1051
|
+
options=None,
|
1052
|
+
serialized_options=None,
|
1053
|
+
create_key=None,
|
1054
|
+
):
|
943
1055
|
"""Arguments are as described in the attribute description above."""
|
944
1056
|
if create_key is not _internal_create_key:
|
945
|
-
_Deprecated('EnumValueDescriptor')
|
1057
|
+
_Deprecated('create function EnumValueDescriptor()')
|
946
1058
|
|
947
1059
|
super(EnumValueDescriptor, self).__init__(
|
948
1060
|
type.file if type else None,
|
@@ -966,30 +1078,46 @@ class OneofDescriptor(DescriptorBase):
|
|
966
1078
|
Attributes:
|
967
1079
|
name (str): Name of the oneof field.
|
968
1080
|
full_name (str): Full name of the oneof field, including package name.
|
969
|
-
index (int): 0-based index giving the order of the oneof field inside
|
970
|
-
|
1081
|
+
index (int): 0-based index giving the order of the oneof field inside its
|
1082
|
+
containing type.
|
971
1083
|
containing_type (Descriptor): :class:`Descriptor` of the protocol message
|
972
1084
|
type that contains this field. Set by the :class:`Descriptor` constructor
|
973
1085
|
if we're passed into one.
|
974
|
-
fields (list[FieldDescriptor]): The list of field descriptors this
|
975
|
-
|
1086
|
+
fields (list[FieldDescriptor]): The list of field descriptors this oneof can
|
1087
|
+
contain.
|
976
1088
|
"""
|
977
1089
|
|
978
1090
|
if _USE_C_DESCRIPTORS:
|
979
1091
|
_C_DESCRIPTOR_CLASS = _message.OneofDescriptor
|
980
1092
|
|
981
1093
|
def __new__(
|
982
|
-
cls,
|
983
|
-
|
1094
|
+
cls,
|
1095
|
+
name,
|
1096
|
+
full_name,
|
1097
|
+
index,
|
1098
|
+
containing_type,
|
1099
|
+
fields,
|
1100
|
+
options=None,
|
1101
|
+
serialized_options=None,
|
1102
|
+
create_key=None,
|
1103
|
+
):
|
984
1104
|
_message.Message._CheckCalledFromGeneratedFile()
|
985
1105
|
return _message.default_pool.FindOneofByName(full_name)
|
986
1106
|
|
987
1107
|
def __init__(
|
988
|
-
self,
|
989
|
-
|
1108
|
+
self,
|
1109
|
+
name,
|
1110
|
+
full_name,
|
1111
|
+
index,
|
1112
|
+
containing_type,
|
1113
|
+
fields,
|
1114
|
+
options=None,
|
1115
|
+
serialized_options=None,
|
1116
|
+
create_key=None,
|
1117
|
+
):
|
990
1118
|
"""Arguments are as described in the attribute description above."""
|
991
1119
|
if create_key is not _internal_create_key:
|
992
|
-
_Deprecated('OneofDescriptor')
|
1120
|
+
_Deprecated('create function OneofDescriptor()')
|
993
1121
|
|
994
1122
|
super(OneofDescriptor, self).__init__(
|
995
1123
|
containing_type.file if containing_type else None,
|
@@ -1009,21 +1137,19 @@ class OneofDescriptor(DescriptorBase):
|
|
1009
1137
|
|
1010
1138
|
|
1011
1139
|
class ServiceDescriptor(_NestedDescriptorBase):
|
1012
|
-
|
1013
1140
|
"""Descriptor for a service.
|
1014
1141
|
|
1015
1142
|
Attributes:
|
1016
1143
|
name (str): Name of the service.
|
1017
1144
|
full_name (str): Full name of the service, including package name.
|
1018
|
-
index (int): 0-indexed index giving the order that this services
|
1019
|
-
|
1020
|
-
methods (list[MethodDescriptor]): List of methods provided by this
|
1021
|
-
service.
|
1145
|
+
index (int): 0-indexed index giving the order that this services definition
|
1146
|
+
appears within the .proto file.
|
1147
|
+
methods (list[MethodDescriptor]): List of methods provided by this service.
|
1022
1148
|
methods_by_name (dict(str, MethodDescriptor)): Same
|
1023
1149
|
:class:`MethodDescriptor` objects as in :attr:`methods_by_name`, but
|
1024
1150
|
indexed by "name" attribute in each :class:`MethodDescriptor`.
|
1025
|
-
options (descriptor_pb2.ServiceOptions): Service options message or
|
1026
|
-
|
1151
|
+
options (descriptor_pb2.ServiceOptions): Service options message or None to
|
1152
|
+
use default service options.
|
1027
1153
|
file (FileDescriptor): Reference to file info.
|
1028
1154
|
"""
|
1029
1155
|
|
@@ -1041,20 +1167,38 @@ class ServiceDescriptor(_NestedDescriptorBase):
|
|
1041
1167
|
file=None, # pylint: disable=redefined-builtin
|
1042
1168
|
serialized_start=None,
|
1043
1169
|
serialized_end=None,
|
1044
|
-
create_key=None
|
1170
|
+
create_key=None,
|
1171
|
+
):
|
1045
1172
|
_message.Message._CheckCalledFromGeneratedFile() # pylint: disable=protected-access
|
1046
1173
|
return _message.default_pool.FindServiceByName(full_name)
|
1047
1174
|
|
1048
|
-
def __init__(
|
1049
|
-
|
1050
|
-
|
1175
|
+
def __init__(
|
1176
|
+
self,
|
1177
|
+
name,
|
1178
|
+
full_name,
|
1179
|
+
index,
|
1180
|
+
methods,
|
1181
|
+
options=None,
|
1182
|
+
serialized_options=None,
|
1183
|
+
file=None, # pylint: disable=redefined-builtin
|
1184
|
+
serialized_start=None,
|
1185
|
+
serialized_end=None,
|
1186
|
+
create_key=None,
|
1187
|
+
):
|
1051
1188
|
if create_key is not _internal_create_key:
|
1052
|
-
_Deprecated('ServiceDescriptor')
|
1189
|
+
_Deprecated('create function ServiceDescriptor()')
|
1053
1190
|
|
1054
1191
|
super(ServiceDescriptor, self).__init__(
|
1055
|
-
options,
|
1056
|
-
|
1057
|
-
|
1192
|
+
options,
|
1193
|
+
'ServiceOptions',
|
1194
|
+
name,
|
1195
|
+
full_name,
|
1196
|
+
file,
|
1197
|
+
None,
|
1198
|
+
serialized_start=serialized_start,
|
1199
|
+
serialized_end=serialized_end,
|
1200
|
+
serialized_options=serialized_options,
|
1201
|
+
)
|
1058
1202
|
self.index = index
|
1059
1203
|
self.methods = methods
|
1060
1204
|
self.methods_by_name = dict((m.name, m) for m in methods)
|
@@ -1092,7 +1236,6 @@ class ServiceDescriptor(_NestedDescriptorBase):
|
|
1092
1236
|
|
1093
1237
|
|
1094
1238
|
class MethodDescriptor(DescriptorBase):
|
1095
|
-
|
1096
1239
|
"""Descriptor for a method in a service.
|
1097
1240
|
|
1098
1241
|
Attributes:
|
@@ -1114,40 +1257,45 @@ class MethodDescriptor(DescriptorBase):
|
|
1114
1257
|
if _USE_C_DESCRIPTORS:
|
1115
1258
|
_C_DESCRIPTOR_CLASS = _message.MethodDescriptor
|
1116
1259
|
|
1117
|
-
def __new__(
|
1118
|
-
|
1119
|
-
|
1120
|
-
|
1121
|
-
|
1122
|
-
|
1123
|
-
|
1124
|
-
|
1125
|
-
|
1126
|
-
|
1127
|
-
|
1128
|
-
|
1260
|
+
def __new__(
|
1261
|
+
cls,
|
1262
|
+
name,
|
1263
|
+
full_name,
|
1264
|
+
index,
|
1265
|
+
containing_service,
|
1266
|
+
input_type,
|
1267
|
+
output_type,
|
1268
|
+
client_streaming=False,
|
1269
|
+
server_streaming=False,
|
1270
|
+
options=None,
|
1271
|
+
serialized_options=None,
|
1272
|
+
create_key=None,
|
1273
|
+
):
|
1129
1274
|
_message.Message._CheckCalledFromGeneratedFile() # pylint: disable=protected-access
|
1130
1275
|
return _message.default_pool.FindMethodByName(full_name)
|
1131
1276
|
|
1132
|
-
def __init__(
|
1133
|
-
|
1134
|
-
|
1135
|
-
|
1136
|
-
|
1137
|
-
|
1138
|
-
|
1139
|
-
|
1140
|
-
|
1141
|
-
|
1142
|
-
|
1143
|
-
|
1277
|
+
def __init__(
|
1278
|
+
self,
|
1279
|
+
name,
|
1280
|
+
full_name,
|
1281
|
+
index,
|
1282
|
+
containing_service,
|
1283
|
+
input_type,
|
1284
|
+
output_type,
|
1285
|
+
client_streaming=False,
|
1286
|
+
server_streaming=False,
|
1287
|
+
options=None,
|
1288
|
+
serialized_options=None,
|
1289
|
+
create_key=None,
|
1290
|
+
):
|
1144
1291
|
"""The arguments are as described in the description of MethodDescriptor
|
1292
|
+
|
1145
1293
|
attributes above.
|
1146
1294
|
|
1147
1295
|
Note that containing_service may be None, and may be set later if necessary.
|
1148
1296
|
"""
|
1149
1297
|
if create_key is not _internal_create_key:
|
1150
|
-
_Deprecated('MethodDescriptor')
|
1298
|
+
_Deprecated('create function MethodDescriptor()')
|
1151
1299
|
|
1152
1300
|
super(MethodDescriptor, self).__init__(
|
1153
1301
|
containing_service.file if containing_service else None,
|
@@ -1180,6 +1328,7 @@ class MethodDescriptor(DescriptorBase):
|
|
1180
1328
|
"""
|
1181
1329
|
if self.containing_service is not None:
|
1182
1330
|
from google.protobuf import descriptor_pb2
|
1331
|
+
|
1183
1332
|
service_proto = descriptor_pb2.ServiceDescriptorProto()
|
1184
1333
|
self.containing_service.CopyToProto(service_proto)
|
1185
1334
|
proto.CopyFrom(service_proto.method[self.index])
|
@@ -1258,7 +1407,7 @@ class FileDescriptor(DescriptorBase):
|
|
1258
1407
|
):
|
1259
1408
|
"""Constructor."""
|
1260
1409
|
if create_key is not _internal_create_key:
|
1261
|
-
_Deprecated('FileDescriptor')
|
1410
|
+
_Deprecated('create function FileDescriptor()')
|
1262
1411
|
|
1263
1412
|
super(FileDescriptor, self).__init__(
|
1264
1413
|
self, options, serialized_options, 'FileOptions'
|
@@ -1273,6 +1422,7 @@ class FileDescriptor(DescriptorBase):
|
|
1273
1422
|
|
1274
1423
|
if pool is None:
|
1275
1424
|
from google.protobuf import descriptor_pool
|
1425
|
+
|
1276
1426
|
pool = descriptor_pool.Default()
|
1277
1427
|
self.pool = pool
|
1278
1428
|
self.message_types_by_name = {}
|
@@ -1283,8 +1433,8 @@ class FileDescriptor(DescriptorBase):
|
|
1283
1433
|
self.enum_types_by_name = {}
|
1284
1434
|
self.extensions_by_name = {}
|
1285
1435
|
self.services_by_name = {}
|
1286
|
-
self.dependencies =
|
1287
|
-
self.public_dependencies =
|
1436
|
+
self.dependencies = dependencies or []
|
1437
|
+
self.public_dependencies = public_dependencies or []
|
1288
1438
|
|
1289
1439
|
def CopyToProto(self, proto):
|
1290
1440
|
"""Copies this to a descriptor_pb2.FileDescriptorProto.
|
@@ -1428,7 +1578,8 @@ def MakeDescriptor(
|
|
1428
1578
|
create_key=_internal_create_key,
|
1429
1579
|
)
|
1430
1580
|
full_message_name = [desc_proto.name]
|
1431
|
-
if package:
|
1581
|
+
if package:
|
1582
|
+
full_message_name.insert(0, package)
|
1432
1583
|
|
1433
1584
|
# Create Descriptors for enum types
|
1434
1585
|
enum_types = {}
|
@@ -1479,8 +1630,9 @@ def MakeDescriptor(
|
|
1479
1630
|
json_name = None
|
1480
1631
|
if field_proto.HasField('type_name'):
|
1481
1632
|
type_name = field_proto.type_name
|
1482
|
-
full_type_name = '.'.join(
|
1483
|
-
|
1633
|
+
full_type_name = '.'.join(
|
1634
|
+
full_message_name + [type_name[type_name.rfind('.') + 1 :]]
|
1635
|
+
)
|
1484
1636
|
if full_type_name in nested_types:
|
1485
1637
|
nested_desc = nested_types[full_type_name]
|
1486
1638
|
elif full_type_name in enum_types:
|