protobuf 6.30.0__cp39-cp39-win_amd64.whl → 6.33.2__cp39-cp39-win_amd64.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.
- google/_upb/_message.cp39-win_amd64.pyd +0 -0
- google/protobuf/__init__.py +1 -1
- google/protobuf/any.py +15 -1
- google/protobuf/any_pb2.py +3 -3
- google/protobuf/api_pb2.py +13 -9
- google/protobuf/compiler/plugin_pb2.py +3 -3
- google/protobuf/descriptor.py +413 -248
- google/protobuf/descriptor_pb2.py +273 -120
- google/protobuf/descriptor_pool.py +27 -12
- google/protobuf/duration_pb2.py +3 -3
- google/protobuf/empty_pb2.py +3 -3
- google/protobuf/field_mask_pb2.py +3 -3
- google/protobuf/internal/api_implementation.py +0 -6
- google/protobuf/internal/decoder.py +106 -23
- google/protobuf/internal/extension_dict.py +3 -3
- google/protobuf/internal/field_mask.py +6 -4
- google/protobuf/internal/python_edition_defaults.py +1 -1
- google/protobuf/internal/python_message.py +71 -52
- google/protobuf/internal/testing_refleaks.py +8 -2
- google/protobuf/internal/type_checkers.py +47 -5
- google/protobuf/internal/well_known_types.py +60 -43
- google/protobuf/json_format.py +88 -62
- google/protobuf/message_factory.py +16 -0
- google/protobuf/runtime_version.py +7 -27
- google/protobuf/source_context_pb2.py +3 -3
- google/protobuf/struct_pb2.py +3 -3
- google/protobuf/text_format.py +41 -26
- google/protobuf/timestamp_pb2.py +3 -3
- google/protobuf/type_pb2.py +3 -3
- google/protobuf/wrappers_pb2.py +3 -3
- {protobuf-6.30.0.dist-info → protobuf-6.33.2.dist-info}/METADATA +1 -1
- protobuf-6.33.2.dist-info/RECORD +59 -0
- protobuf-6.30.0.dist-info/RECORD +0 -59
- {protobuf-6.30.0.dist-info → protobuf-6.33.2.dist-info}/LICENSE +0 -0
- {protobuf-6.30.0.dist-info → protobuf-6.33.2.dist-info}/WHEEL +0 -0
google/protobuf/json_format.py
CHANGED
|
@@ -26,6 +26,7 @@ import json
|
|
|
26
26
|
import math
|
|
27
27
|
from operator import methodcaller
|
|
28
28
|
import re
|
|
29
|
+
import warnings
|
|
29
30
|
|
|
30
31
|
from google.protobuf import descriptor
|
|
31
32
|
from google.protobuf import message_factory
|
|
@@ -72,6 +73,7 @@ class ParseError(Error):
|
|
|
72
73
|
|
|
73
74
|
class EnumStringValueParseError(ParseError):
|
|
74
75
|
"""Thrown if unknown string enum value is encountered.
|
|
76
|
+
|
|
75
77
|
This exception is suppressed if ignore_unknown_fields is set.
|
|
76
78
|
"""
|
|
77
79
|
|
|
@@ -91,10 +93,10 @@ def MessageToJson(
|
|
|
91
93
|
|
|
92
94
|
Args:
|
|
93
95
|
message: The protocol buffers message instance to serialize.
|
|
94
|
-
always_print_fields_with_no_presence: If True, fields without
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
always_print_fields_with_no_presence: If True, fields without presence
|
|
97
|
+
(implicit presence scalars, repeated fields, and map fields) will always
|
|
98
|
+
be serialized. Any field that supports presence is not affected by this
|
|
99
|
+
option (including singular message fields and oneof fields).
|
|
98
100
|
preserving_proto_field_name: If True, use the original proto field names as
|
|
99
101
|
defined in the .proto file. If False, convert the field names to
|
|
100
102
|
lowerCamelCase.
|
|
@@ -105,7 +107,8 @@ def MessageToJson(
|
|
|
105
107
|
use_integers_for_enums: If true, print integers instead of enum names.
|
|
106
108
|
descriptor_pool: A Descriptor Pool for resolving types. If None use the
|
|
107
109
|
default.
|
|
108
|
-
float_precision: If set, use this to specify float field valid
|
|
110
|
+
float_precision: Deprecated. If set, use this to specify float field valid
|
|
111
|
+
digits.
|
|
109
112
|
ensure_ascii: If True, strings with non-ASCII characters are escaped. If
|
|
110
113
|
False, Unicode strings are returned unchanged.
|
|
111
114
|
|
|
@@ -117,7 +120,7 @@ def MessageToJson(
|
|
|
117
120
|
use_integers_for_enums,
|
|
118
121
|
descriptor_pool,
|
|
119
122
|
float_precision,
|
|
120
|
-
always_print_fields_with_no_presence
|
|
123
|
+
always_print_fields_with_no_presence,
|
|
121
124
|
)
|
|
122
125
|
return printer.ToJsonString(message, indent, sort_keys, ensure_ascii)
|
|
123
126
|
|
|
@@ -136,17 +139,18 @@ def MessageToDict(
|
|
|
136
139
|
|
|
137
140
|
Args:
|
|
138
141
|
message: The protocol buffers message instance to serialize.
|
|
139
|
-
always_print_fields_with_no_presence: If True, fields without
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
142
|
+
always_print_fields_with_no_presence: If True, fields without presence
|
|
143
|
+
(implicit presence scalars, repeated fields, and map fields) will always
|
|
144
|
+
be serialized. Any field that supports presence is not affected by this
|
|
145
|
+
option (including singular message fields and oneof fields).
|
|
143
146
|
preserving_proto_field_name: If True, use the original proto field names as
|
|
144
147
|
defined in the .proto file. If False, convert the field names to
|
|
145
148
|
lowerCamelCase.
|
|
146
149
|
use_integers_for_enums: If true, print integers instead of enum names.
|
|
147
150
|
descriptor_pool: A Descriptor Pool for resolving types. If None use the
|
|
148
151
|
default.
|
|
149
|
-
float_precision: If set, use this to specify float field valid
|
|
152
|
+
float_precision: Deprecated. If set, use this to specify float field valid
|
|
153
|
+
digits.
|
|
150
154
|
|
|
151
155
|
Returns:
|
|
152
156
|
A dict representation of the protocol buffer message.
|
|
@@ -188,6 +192,11 @@ class _Printer(object):
|
|
|
188
192
|
self.use_integers_for_enums = use_integers_for_enums
|
|
189
193
|
self.descriptor_pool = descriptor_pool
|
|
190
194
|
if float_precision:
|
|
195
|
+
warnings.warn(
|
|
196
|
+
'float_precision option is deprecated for json_format. '
|
|
197
|
+
'This will turn into error in 7.34.0, please remove it '
|
|
198
|
+
'before that.'
|
|
199
|
+
)
|
|
191
200
|
self.float_format = '.{}g'.format(float_precision)
|
|
192
201
|
else:
|
|
193
202
|
self.float_format = None
|
|
@@ -215,10 +224,13 @@ class _Printer(object):
|
|
|
215
224
|
|
|
216
225
|
try:
|
|
217
226
|
for field, value in fields:
|
|
218
|
-
if
|
|
227
|
+
if field.is_extension:
|
|
228
|
+
name = '[%s]' % field.full_name
|
|
229
|
+
elif self.preserving_proto_field_name:
|
|
219
230
|
name = field.name
|
|
220
231
|
else:
|
|
221
232
|
name = field.json_name
|
|
233
|
+
|
|
222
234
|
if _IsMapEntry(field):
|
|
223
235
|
# Convert a map field.
|
|
224
236
|
v_field = field.message_type.fields_by_name['value']
|
|
@@ -233,12 +245,9 @@ class _Printer(object):
|
|
|
233
245
|
recorded_key = str(key)
|
|
234
246
|
js_map[recorded_key] = self._FieldToJsonObject(v_field, value[key])
|
|
235
247
|
js[name] = js_map
|
|
236
|
-
elif field.
|
|
248
|
+
elif field.is_repeated:
|
|
237
249
|
# Convert a repeated field.
|
|
238
250
|
js[name] = [self._FieldToJsonObject(field, k) for k in value]
|
|
239
|
-
elif field.is_extension:
|
|
240
|
-
name = '[%s]' % field.full_name
|
|
241
|
-
js[name] = self._FieldToJsonObject(field, value)
|
|
242
251
|
else:
|
|
243
252
|
js[name] = self._FieldToJsonObject(field, value)
|
|
244
253
|
|
|
@@ -251,10 +260,7 @@ class _Printer(object):
|
|
|
251
260
|
|
|
252
261
|
# always_print_fields_with_no_presence doesn't apply to
|
|
253
262
|
# any field which supports presence.
|
|
254
|
-
if
|
|
255
|
-
self.always_print_fields_with_no_presence
|
|
256
|
-
and field.has_presence
|
|
257
|
-
):
|
|
263
|
+
if self.always_print_fields_with_no_presence and field.has_presence:
|
|
258
264
|
continue
|
|
259
265
|
|
|
260
266
|
if self.preserving_proto_field_name:
|
|
@@ -266,7 +272,7 @@ class _Printer(object):
|
|
|
266
272
|
continue
|
|
267
273
|
if _IsMapEntry(field):
|
|
268
274
|
js[name] = {}
|
|
269
|
-
elif field.
|
|
275
|
+
elif field.is_repeated:
|
|
270
276
|
js[name] = []
|
|
271
277
|
else:
|
|
272
278
|
js[name] = self._FieldToJsonObject(field, field.default_value)
|
|
@@ -316,11 +322,10 @@ class _Printer(object):
|
|
|
316
322
|
return _INFINITY
|
|
317
323
|
if math.isnan(value):
|
|
318
324
|
return _NAN
|
|
319
|
-
if
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
return type_checkers.ToShortestFloat(value)
|
|
325
|
+
if self.float_format:
|
|
326
|
+
return float(format(value, self.float_format))
|
|
327
|
+
elif field.cpp_type == descriptor.FieldDescriptor.CPPTYPE_FLOAT:
|
|
328
|
+
return type_checkers.ToShortestFloat(value)
|
|
324
329
|
|
|
325
330
|
return value
|
|
326
331
|
|
|
@@ -557,6 +562,25 @@ class _Parser(object):
|
|
|
557
562
|
fields_by_json_name = dict(
|
|
558
563
|
(f.json_name, f) for f in message_descriptor.fields
|
|
559
564
|
)
|
|
565
|
+
|
|
566
|
+
def _ClearFieldOrExtension(message, field):
|
|
567
|
+
if field.is_extension:
|
|
568
|
+
message.ClearExtension(field)
|
|
569
|
+
else:
|
|
570
|
+
message.ClearField(field.name)
|
|
571
|
+
|
|
572
|
+
def _GetFieldOrExtension(message, field):
|
|
573
|
+
if field.is_extension:
|
|
574
|
+
return message.Extensions[field]
|
|
575
|
+
else:
|
|
576
|
+
return getattr(message, field.name)
|
|
577
|
+
|
|
578
|
+
def _SetFieldOrExtension(message, field, value):
|
|
579
|
+
if field.is_extension:
|
|
580
|
+
message.Extensions[field] = value
|
|
581
|
+
else:
|
|
582
|
+
setattr(message, field.name, value)
|
|
583
|
+
|
|
560
584
|
for name in js:
|
|
561
585
|
try:
|
|
562
586
|
field = fields_by_json_name.get(name, None)
|
|
@@ -620,25 +644,25 @@ class _Parser(object):
|
|
|
620
644
|
field.cpp_type == descriptor.FieldDescriptor.CPPTYPE_MESSAGE
|
|
621
645
|
and field.message_type.full_name == 'google.protobuf.Value'
|
|
622
646
|
):
|
|
623
|
-
sub_message =
|
|
647
|
+
sub_message = _GetFieldOrExtension(message, field)
|
|
624
648
|
sub_message.null_value = 0
|
|
625
649
|
elif (
|
|
626
650
|
field.cpp_type == descriptor.FieldDescriptor.CPPTYPE_ENUM
|
|
627
651
|
and field.enum_type.full_name == 'google.protobuf.NullValue'
|
|
628
652
|
):
|
|
629
|
-
|
|
653
|
+
_SetFieldOrExtension(message, field, 0)
|
|
630
654
|
else:
|
|
631
|
-
message
|
|
655
|
+
_ClearFieldOrExtension(message, field)
|
|
632
656
|
continue
|
|
633
657
|
|
|
634
658
|
# Parse field value.
|
|
635
659
|
if _IsMapEntry(field):
|
|
636
|
-
message
|
|
660
|
+
_ClearFieldOrExtension(message, field)
|
|
637
661
|
self._ConvertMapFieldValue(
|
|
638
662
|
value, message, field, '{0}.{1}'.format(path, name)
|
|
639
663
|
)
|
|
640
|
-
elif field.
|
|
641
|
-
message
|
|
664
|
+
elif field.is_repeated:
|
|
665
|
+
_ClearFieldOrExtension(message, field)
|
|
642
666
|
if not isinstance(value, _LIST_LIKE):
|
|
643
667
|
raise ParseError(
|
|
644
668
|
'repeated field {0} must be in [] which is {1} at {2}'.format(
|
|
@@ -648,7 +672,7 @@ class _Parser(object):
|
|
|
648
672
|
if field.cpp_type == descriptor.FieldDescriptor.CPPTYPE_MESSAGE:
|
|
649
673
|
# Repeated message field.
|
|
650
674
|
for index, item in enumerate(value):
|
|
651
|
-
sub_message =
|
|
675
|
+
sub_message = _GetFieldOrExtension(message, field).add()
|
|
652
676
|
# None is a null_value in Value.
|
|
653
677
|
if (
|
|
654
678
|
item is None
|
|
@@ -675,19 +699,16 @@ class _Parser(object):
|
|
|
675
699
|
)
|
|
676
700
|
)
|
|
677
701
|
self._ConvertAndAppendScalar(
|
|
678
|
-
|
|
702
|
+
message, field, item, '{0}.{1}[{2}]'.format(path, name, index)
|
|
703
|
+
)
|
|
679
704
|
elif field.cpp_type == descriptor.FieldDescriptor.CPPTYPE_MESSAGE:
|
|
680
|
-
|
|
681
|
-
sub_message = message.Extensions[field]
|
|
682
|
-
else:
|
|
683
|
-
sub_message = getattr(message, field.name)
|
|
705
|
+
sub_message = _GetFieldOrExtension(message, field)
|
|
684
706
|
sub_message.SetInParent()
|
|
685
707
|
self.ConvertMessage(value, sub_message, '{0}.{1}'.format(path, name))
|
|
686
708
|
else:
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
self._ConvertAndSetScalar(message, field, value, '{0}.{1}'.format(path, name))
|
|
709
|
+
self._ConvertAndSetScalar(
|
|
710
|
+
message, field, value, '{0}.{1}'.format(path, name)
|
|
711
|
+
)
|
|
691
712
|
except ParseError as e:
|
|
692
713
|
if field and field.containing_oneof is None:
|
|
693
714
|
raise ParseError(
|
|
@@ -802,7 +823,9 @@ class _Parser(object):
|
|
|
802
823
|
def _ConvertWrapperMessage(self, value, message, path):
|
|
803
824
|
"""Convert a JSON representation into Wrapper message."""
|
|
804
825
|
field = message.DESCRIPTOR.fields_by_name['value']
|
|
805
|
-
self._ConvertAndSetScalar(
|
|
826
|
+
self._ConvertAndSetScalar(
|
|
827
|
+
message, field, value, path='{0}.value'.format(path)
|
|
828
|
+
)
|
|
806
829
|
|
|
807
830
|
def _ConvertMapFieldValue(self, value, message, field, path):
|
|
808
831
|
"""Convert map field value for a message map field.
|
|
@@ -840,24 +863,17 @@ class _Parser(object):
|
|
|
840
863
|
field,
|
|
841
864
|
key_value,
|
|
842
865
|
value[key],
|
|
843
|
-
path='{0}[{1}]'.format(path, key_value)
|
|
844
|
-
|
|
845
|
-
def _ConvertAndSetScalarExtension(self, message, extension_field, js_value, path):
|
|
846
|
-
"""Convert scalar from js_value and assign it to message.Extensions[extension_field]."""
|
|
847
|
-
try:
|
|
848
|
-
message.Extensions[extension_field] = _ConvertScalarFieldValue(
|
|
849
|
-
js_value, extension_field, path)
|
|
850
|
-
except EnumStringValueParseError:
|
|
851
|
-
if not self.ignore_unknown_fields:
|
|
852
|
-
raise
|
|
866
|
+
path='{0}[{1}]'.format(path, key_value),
|
|
867
|
+
)
|
|
853
868
|
|
|
854
869
|
def _ConvertAndSetScalar(self, message, field, js_value, path):
|
|
855
870
|
"""Convert scalar from js_value and assign it to message.field."""
|
|
856
871
|
try:
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
872
|
+
value = _ConvertScalarFieldValue(js_value, field, path)
|
|
873
|
+
if field.is_extension:
|
|
874
|
+
message.Extensions[field] = value
|
|
875
|
+
else:
|
|
876
|
+
setattr(message, field.name, value)
|
|
861
877
|
except EnumStringValueParseError:
|
|
862
878
|
if not self.ignore_unknown_fields:
|
|
863
879
|
raise
|
|
@@ -865,17 +881,27 @@ class _Parser(object):
|
|
|
865
881
|
def _ConvertAndAppendScalar(self, message, repeated_field, js_value, path):
|
|
866
882
|
"""Convert scalar from js_value and append it to message.repeated_field."""
|
|
867
883
|
try:
|
|
868
|
-
|
|
869
|
-
|
|
884
|
+
if repeated_field.is_extension:
|
|
885
|
+
repeated = message.Extensions[repeated_field]
|
|
886
|
+
else:
|
|
887
|
+
repeated = getattr(message, repeated_field.name)
|
|
888
|
+
value = _ConvertScalarFieldValue(js_value, repeated_field, path)
|
|
889
|
+
repeated.append(value)
|
|
870
890
|
except EnumStringValueParseError:
|
|
871
891
|
if not self.ignore_unknown_fields:
|
|
872
892
|
raise
|
|
873
893
|
|
|
874
|
-
def _ConvertAndSetScalarToMapKey(
|
|
894
|
+
def _ConvertAndSetScalarToMapKey(
|
|
895
|
+
self, message, map_field, converted_key, js_value, path
|
|
896
|
+
):
|
|
875
897
|
"""Convert scalar from 'js_value' and add it to message.map_field[converted_key]."""
|
|
876
898
|
try:
|
|
877
|
-
getattr(message, map_field.name)[converted_key] =
|
|
878
|
-
|
|
899
|
+
getattr(message, map_field.name)[converted_key] = (
|
|
900
|
+
_ConvertScalarFieldValue(
|
|
901
|
+
js_value,
|
|
902
|
+
map_field.message_type.fields_by_name['value'],
|
|
903
|
+
path,
|
|
904
|
+
)
|
|
879
905
|
)
|
|
880
906
|
except EnumStringValueParseError:
|
|
881
907
|
if not self.ignore_unknown_fields:
|
|
@@ -56,6 +56,22 @@ def GetMessageClassesForFiles(files, pool):
|
|
|
56
56
|
This will find and resolve dependencies, failing if the descriptor
|
|
57
57
|
pool cannot satisfy them.
|
|
58
58
|
|
|
59
|
+
This will not return the classes for nested types within those classes, for
|
|
60
|
+
those, use GetMessageClass() on the nested types within their containing
|
|
61
|
+
messages.
|
|
62
|
+
|
|
63
|
+
For example, for the message:
|
|
64
|
+
|
|
65
|
+
message NestedTypeMessage {
|
|
66
|
+
message NestedType {
|
|
67
|
+
string data = 1;
|
|
68
|
+
}
|
|
69
|
+
NestedType nested = 1;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
NestedTypeMessage will be in the result, but not
|
|
73
|
+
NestedTypeMessage.NestedType.
|
|
74
|
+
|
|
59
75
|
Args:
|
|
60
76
|
files: The file names to extract messages from.
|
|
61
77
|
pool: The descriptor pool to find the files including the dependent files.
|
|
@@ -28,8 +28,8 @@ class Domain(Enum):
|
|
|
28
28
|
# These OSS versions are not stripped to avoid merging conflicts.
|
|
29
29
|
OSS_DOMAIN = Domain.PUBLIC
|
|
30
30
|
OSS_MAJOR = 6
|
|
31
|
-
OSS_MINOR =
|
|
32
|
-
OSS_PATCH =
|
|
31
|
+
OSS_MINOR = 33
|
|
32
|
+
OSS_PATCH = 2
|
|
33
33
|
OSS_SUFFIX = ''
|
|
34
34
|
|
|
35
35
|
DOMAIN = OSS_DOMAIN
|
|
@@ -92,33 +92,13 @@ def ValidateProtobufRuntimeVersion(
|
|
|
92
92
|
' Cross-domain usage of Protobuf is not supported.'
|
|
93
93
|
)
|
|
94
94
|
|
|
95
|
-
if
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
' than the runtime version %s at %s. Please update the gencode to'
|
|
101
|
-
' avoid compatibility violations in the next runtime release.'
|
|
102
|
-
% (gen_version, version, location)
|
|
103
|
-
)
|
|
104
|
-
_warning_count += 1
|
|
105
|
-
else:
|
|
106
|
-
_ReportVersionError(
|
|
107
|
-
'Detected mismatched Protobuf Gencode/Runtime major versions when'
|
|
108
|
-
f' loading {location}: gencode {gen_version} runtime {version}.'
|
|
109
|
-
f' Same major version is required. {error_prompt}'
|
|
110
|
-
)
|
|
111
|
-
|
|
112
|
-
if MINOR < gen_minor or (MINOR == gen_minor and PATCH < gen_patch):
|
|
95
|
+
if (
|
|
96
|
+
MAJOR < gen_major
|
|
97
|
+
or (MAJOR == gen_major and MINOR < gen_minor)
|
|
98
|
+
or (MAJOR == gen_major and MINOR == gen_minor and PATCH < gen_patch)
|
|
99
|
+
):
|
|
113
100
|
_ReportVersionError(
|
|
114
101
|
'Detected incompatible Protobuf Gencode/Runtime versions when loading'
|
|
115
102
|
f' {location}: gencode {gen_version} runtime {version}. Runtime version'
|
|
116
103
|
f' cannot be older than the linked gencode version. {error_prompt}'
|
|
117
104
|
)
|
|
118
|
-
|
|
119
|
-
if gen_suffix != SUFFIX:
|
|
120
|
-
_ReportVersionError(
|
|
121
|
-
'Detected mismatched Protobuf Gencode/Runtime version suffixes when'
|
|
122
|
-
f' loading {location}: gencode {gen_version} runtime {version}.'
|
|
123
|
-
f' Version suffixes must be the same. {error_prompt}'
|
|
124
|
-
)
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
3
3
|
# NO CHECKED-IN PROTOBUF GENCODE
|
|
4
4
|
# source: google/protobuf/source_context.proto
|
|
5
|
-
# Protobuf Python Version: 6.
|
|
5
|
+
# Protobuf Python Version: 6.33.2
|
|
6
6
|
"""Generated protocol buffer code."""
|
|
7
7
|
from google.protobuf import descriptor as _descriptor
|
|
8
8
|
from google.protobuf import descriptor_pool as _descriptor_pool
|
|
@@ -12,8 +12,8 @@ from google.protobuf.internal import builder as _builder
|
|
|
12
12
|
_runtime_version.ValidateProtobufRuntimeVersion(
|
|
13
13
|
_runtime_version.Domain.PUBLIC,
|
|
14
14
|
6,
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
33,
|
|
16
|
+
2,
|
|
17
17
|
'',
|
|
18
18
|
'google/protobuf/source_context.proto'
|
|
19
19
|
)
|
google/protobuf/struct_pb2.py
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
3
3
|
# NO CHECKED-IN PROTOBUF GENCODE
|
|
4
4
|
# source: google/protobuf/struct.proto
|
|
5
|
-
# Protobuf Python Version: 6.
|
|
5
|
+
# Protobuf Python Version: 6.33.2
|
|
6
6
|
"""Generated protocol buffer code."""
|
|
7
7
|
from google.protobuf import descriptor as _descriptor
|
|
8
8
|
from google.protobuf import descriptor_pool as _descriptor_pool
|
|
@@ -12,8 +12,8 @@ from google.protobuf.internal import builder as _builder
|
|
|
12
12
|
_runtime_version.ValidateProtobufRuntimeVersion(
|
|
13
13
|
_runtime_version.Domain.PUBLIC,
|
|
14
14
|
6,
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
33,
|
|
16
|
+
2,
|
|
17
17
|
'',
|
|
18
18
|
'google/protobuf/struct.proto'
|
|
19
19
|
)
|
google/protobuf/text_format.py
CHANGED
|
@@ -25,6 +25,7 @@ import encodings.unicode_escape # pylint: disable=unused-import
|
|
|
25
25
|
import io
|
|
26
26
|
import math
|
|
27
27
|
import re
|
|
28
|
+
import warnings
|
|
28
29
|
|
|
29
30
|
from google.protobuf.internal import decoder
|
|
30
31
|
from google.protobuf.internal import type_checkers
|
|
@@ -126,13 +127,13 @@ def MessageToString(
|
|
|
126
127
|
will be printed at the end of the message and their relative order is
|
|
127
128
|
determined by the extension number. By default, use the field number
|
|
128
129
|
order.
|
|
129
|
-
float_format (str): If set, use this to specify float field
|
|
130
|
-
(per the "Format Specification Mini-Language"); otherwise,
|
|
131
|
-
that has same value in wire will be printed. Also affect
|
|
132
|
-
if double_format is not set but float_format is set.
|
|
133
|
-
double_format (str): If set, use this to specify double field
|
|
134
|
-
(per the "Format Specification Mini-Language"); if it is not
|
|
135
|
-
float_format is set, use float_format. Otherwise, use ``str()``
|
|
130
|
+
float_format (str): Deprecated. If set, use this to specify float field
|
|
131
|
+
formatting (per the "Format Specification Mini-Language"); otherwise,
|
|
132
|
+
shortest float that has same value in wire will be printed. Also affect
|
|
133
|
+
double field if double_format is not set but float_format is set.
|
|
134
|
+
double_format (str): Deprecated. If set, use this to specify double field
|
|
135
|
+
formatting (per the "Format Specification Mini-Language"); if it is not
|
|
136
|
+
set but float_format is set, use float_format. Otherwise, use ``str()``
|
|
136
137
|
use_field_number: If True, print field numbers instead of names.
|
|
137
138
|
descriptor_pool (DescriptorPool): Descriptor pool used to resolve Any types.
|
|
138
139
|
indent (int): The initial indent level, in terms of spaces, for pretty
|
|
@@ -391,13 +392,13 @@ class _Printer(object):
|
|
|
391
392
|
use_index_order: If True, print fields of a proto message using the order
|
|
392
393
|
defined in source code instead of the field number. By default, use the
|
|
393
394
|
field number order.
|
|
394
|
-
float_format: If set, use this to specify float field
|
|
395
|
-
(per the "Format Specification Mini-Language"); otherwise,
|
|
396
|
-
float that has same value in wire will be printed. Also affect
|
|
397
|
-
field if double_format is not set but float_format is set.
|
|
398
|
-
double_format: If set, use this to specify double field
|
|
399
|
-
(per the "Format Specification Mini-Language"); if it is not
|
|
400
|
-
float_format is set, use float_format. Otherwise, str() is used.
|
|
395
|
+
float_format: Deprecated. If set, use this to specify float field
|
|
396
|
+
formatting (per the "Format Specification Mini-Language"); otherwise,
|
|
397
|
+
shortest float that has same value in wire will be printed. Also affect
|
|
398
|
+
double field if double_format is not set but float_format is set.
|
|
399
|
+
double_format: Deprecated. If set, use this to specify double field
|
|
400
|
+
formatting (per the "Format Specification Mini-Language"); if it is not
|
|
401
|
+
set but float_format is set, use float_format. Otherwise, str() is used.
|
|
401
402
|
use_field_number: If True, print field numbers instead of names.
|
|
402
403
|
descriptor_pool: A DescriptorPool used to resolve Any types.
|
|
403
404
|
message_formatter: A function(message, indent, as_one_line): unicode|None
|
|
@@ -416,6 +417,10 @@ class _Printer(object):
|
|
|
416
417
|
self.use_index_order = use_index_order
|
|
417
418
|
self.float_format = float_format
|
|
418
419
|
if double_format is not None:
|
|
420
|
+
warnings.warn(
|
|
421
|
+
'double_format is deprecated for text_format. This will '
|
|
422
|
+
'turn into error in 7.34.0, please remove it before that.'
|
|
423
|
+
)
|
|
419
424
|
self.double_format = double_format
|
|
420
425
|
else:
|
|
421
426
|
self.double_format = float_format
|
|
@@ -477,7 +482,7 @@ class _Printer(object):
|
|
|
477
482
|
# TODO: refactor and optimize if this becomes an issue.
|
|
478
483
|
entry_submsg = value.GetEntryClass()(key=key, value=value[key])
|
|
479
484
|
self.PrintField(field, entry_submsg)
|
|
480
|
-
elif field.
|
|
485
|
+
elif field.is_repeated:
|
|
481
486
|
if (self.use_short_repeated_primitives
|
|
482
487
|
and field.cpp_type != descriptor.FieldDescriptor.CPPTYPE_MESSAGE
|
|
483
488
|
and field.cpp_type != descriptor.FieldDescriptor.CPPTYPE_STRING):
|
|
@@ -557,7 +562,8 @@ class _Printer(object):
|
|
|
557
562
|
out.write('[')
|
|
558
563
|
if (field.containing_type.GetOptions().message_set_wire_format and
|
|
559
564
|
field.type == descriptor.FieldDescriptor.TYPE_MESSAGE and
|
|
560
|
-
field.
|
|
565
|
+
not field.is_required and
|
|
566
|
+
not field.is_repeated):
|
|
561
567
|
out.write(field.message_type.full_name)
|
|
562
568
|
else:
|
|
563
569
|
out.write(field.full_name)
|
|
@@ -651,6 +657,11 @@ class _Printer(object):
|
|
|
651
657
|
out.write('false')
|
|
652
658
|
elif field.cpp_type == descriptor.FieldDescriptor.CPPTYPE_FLOAT:
|
|
653
659
|
if self.float_format is not None:
|
|
660
|
+
warnings.warn(
|
|
661
|
+
'float_format is deprecated for text_format. This '
|
|
662
|
+
'will turn into error in 7.34.0, please remove it '
|
|
663
|
+
'before that.'
|
|
664
|
+
)
|
|
654
665
|
out.write('{1:{0}}'.format(self.float_format, value))
|
|
655
666
|
else:
|
|
656
667
|
if math.isnan(value):
|
|
@@ -998,7 +1009,7 @@ class _Parser(object):
|
|
|
998
1009
|
field.full_name)
|
|
999
1010
|
merger = self._MergeScalarField
|
|
1000
1011
|
|
|
1001
|
-
if (field.
|
|
1012
|
+
if (field.is_repeated and
|
|
1002
1013
|
tokenizer.TryConsume('[')):
|
|
1003
1014
|
# Short repeated format, e.g. "foo: [1, 2, 3]"
|
|
1004
1015
|
if not tokenizer.TryConsume(']'):
|
|
@@ -1061,7 +1072,7 @@ class _Parser(object):
|
|
|
1061
1072
|
tokenizer.Consume('{')
|
|
1062
1073
|
end_token = '}'
|
|
1063
1074
|
|
|
1064
|
-
if field.
|
|
1075
|
+
if field.is_repeated:
|
|
1065
1076
|
if field.is_extension:
|
|
1066
1077
|
sub_message = message.Extensions[field].add()
|
|
1067
1078
|
elif is_map_entry:
|
|
@@ -1143,7 +1154,7 @@ class _Parser(object):
|
|
|
1143
1154
|
else:
|
|
1144
1155
|
raise RuntimeError('Unknown field type %d' % field.type)
|
|
1145
1156
|
|
|
1146
|
-
if field.
|
|
1157
|
+
if field.is_repeated:
|
|
1147
1158
|
if field.is_extension:
|
|
1148
1159
|
message.Extensions[field].append(value)
|
|
1149
1160
|
else:
|
|
@@ -1196,7 +1207,7 @@ class _Parser(object):
|
|
|
1196
1207
|
':') and not tokenizer.LookingAt('{') and not tokenizer.LookingAt('<'):
|
|
1197
1208
|
self._DetectSilentMarker(tokenizer, immediate_message_type, field_name)
|
|
1198
1209
|
if tokenizer.LookingAt('['):
|
|
1199
|
-
self._SkipRepeatedFieldValue(tokenizer)
|
|
1210
|
+
self._SkipRepeatedFieldValue(tokenizer, immediate_message_type)
|
|
1200
1211
|
else:
|
|
1201
1212
|
self._SkipFieldValue(tokenizer)
|
|
1202
1213
|
else:
|
|
@@ -1271,18 +1282,22 @@ class _Parser(object):
|
|
|
1271
1282
|
not tokenizer.TryConsumeFloat()):
|
|
1272
1283
|
raise ParseError('Invalid field value: ' + tokenizer.token)
|
|
1273
1284
|
|
|
1274
|
-
def _SkipRepeatedFieldValue(self, tokenizer):
|
|
1285
|
+
def _SkipRepeatedFieldValue(self, tokenizer, immediate_message_type):
|
|
1275
1286
|
"""Skips over a repeated field value.
|
|
1276
1287
|
|
|
1277
1288
|
Args:
|
|
1278
1289
|
tokenizer: A tokenizer to parse the field value.
|
|
1279
1290
|
"""
|
|
1280
1291
|
tokenizer.Consume('[')
|
|
1281
|
-
if not tokenizer.
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1292
|
+
if not tokenizer.TryConsume(']'):
|
|
1293
|
+
while True:
|
|
1294
|
+
if tokenizer.LookingAt('<') or tokenizer.LookingAt('{'):
|
|
1295
|
+
self._SkipFieldMessage(tokenizer, immediate_message_type)
|
|
1296
|
+
else:
|
|
1297
|
+
self._SkipFieldValue(tokenizer)
|
|
1298
|
+
if tokenizer.TryConsume(']'):
|
|
1299
|
+
break
|
|
1300
|
+
tokenizer.Consume(',')
|
|
1286
1301
|
|
|
1287
1302
|
|
|
1288
1303
|
class Tokenizer(object):
|
google/protobuf/timestamp_pb2.py
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
3
3
|
# NO CHECKED-IN PROTOBUF GENCODE
|
|
4
4
|
# source: google/protobuf/timestamp.proto
|
|
5
|
-
# Protobuf Python Version: 6.
|
|
5
|
+
# Protobuf Python Version: 6.33.2
|
|
6
6
|
"""Generated protocol buffer code."""
|
|
7
7
|
from google.protobuf import descriptor as _descriptor
|
|
8
8
|
from google.protobuf import descriptor_pool as _descriptor_pool
|
|
@@ -12,8 +12,8 @@ from google.protobuf.internal import builder as _builder
|
|
|
12
12
|
_runtime_version.ValidateProtobufRuntimeVersion(
|
|
13
13
|
_runtime_version.Domain.PUBLIC,
|
|
14
14
|
6,
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
33,
|
|
16
|
+
2,
|
|
17
17
|
'',
|
|
18
18
|
'google/protobuf/timestamp.proto'
|
|
19
19
|
)
|
google/protobuf/type_pb2.py
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
3
3
|
# NO CHECKED-IN PROTOBUF GENCODE
|
|
4
4
|
# source: google/protobuf/type.proto
|
|
5
|
-
# Protobuf Python Version: 6.
|
|
5
|
+
# Protobuf Python Version: 6.33.2
|
|
6
6
|
"""Generated protocol buffer code."""
|
|
7
7
|
from google.protobuf import descriptor as _descriptor
|
|
8
8
|
from google.protobuf import descriptor_pool as _descriptor_pool
|
|
@@ -12,8 +12,8 @@ from google.protobuf.internal import builder as _builder
|
|
|
12
12
|
_runtime_version.ValidateProtobufRuntimeVersion(
|
|
13
13
|
_runtime_version.Domain.PUBLIC,
|
|
14
14
|
6,
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
33,
|
|
16
|
+
2,
|
|
17
17
|
'',
|
|
18
18
|
'google/protobuf/type.proto'
|
|
19
19
|
)
|
google/protobuf/wrappers_pb2.py
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
3
3
|
# NO CHECKED-IN PROTOBUF GENCODE
|
|
4
4
|
# source: google/protobuf/wrappers.proto
|
|
5
|
-
# Protobuf Python Version: 6.
|
|
5
|
+
# Protobuf Python Version: 6.33.2
|
|
6
6
|
"""Generated protocol buffer code."""
|
|
7
7
|
from google.protobuf import descriptor as _descriptor
|
|
8
8
|
from google.protobuf import descriptor_pool as _descriptor_pool
|
|
@@ -12,8 +12,8 @@ from google.protobuf.internal import builder as _builder
|
|
|
12
12
|
_runtime_version.ValidateProtobufRuntimeVersion(
|
|
13
13
|
_runtime_version.Domain.PUBLIC,
|
|
14
14
|
6,
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
33,
|
|
16
|
+
2,
|
|
17
17
|
'',
|
|
18
18
|
'google/protobuf/wrappers.proto'
|
|
19
19
|
)
|