zmc
2023-12-22 9fdbf60165db0400c2e8e6be2dc6e88138ac719a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
U
£ý°d%éã@s”dZdZddlmZddlZddlZddlZddlmZddlm    Z    ddlm
Z
ddlm Z dd    lm Z dd
lm Z dd lmZdd lmZdd lmZddlmZddlmZddlmZddlmZejZdZe jZGdd„deƒZdd„Zdd„Z dd„Z!dd„Z"dd„Z#dd „Z$d!d"„Z%d#d$„Z&d%d&„Z'd'd(„Z(d)d*„Z)d+d,„Z*d-d.„Z+d/d0„Z,d1d2„Z-Gd3d4„d4e.ƒZ/d5d6„Z0d7d8„Z1d9d:„Z2d;d<„Z3d=d>„Z4d?d@„Z5dAdB„Z6dCZ7dDZ8dEdF„Z9dGdH„Z:dIdJ„Z;dKdL„Z<dMdN„Z=dOdP„Z>dQdR„Z?dSdT„Z@dUdV„ZAdWdX„ZBdYdZ„ZCd[d\„ZDd]d^„ZEd_d`„ZFdadb„ZGdcdd„ZHdedf„ZIdgdh„ZJdidj„ZKdkdl„ZLdmdn„ZMdodp„ZNdqdr„ZOdsdt„ZPGdudv„dveQƒZRGdwdx„dxeRƒZSdS)ya Contains a metaclass and helper functions used to create
protocol message classes from Descriptor objects at runtime.
 
Recall that a metaclass is the "type" of a class.
(A class is to a metaclass what an instance is to a class.)
 
In this case, we use the GeneratedProtocolMessageType metaclass
to inject all the useful functionality into the classes
output by the protocol compiler at compile-time.
 
The upshot of all this is that the real implementation
details for ALL pure-Python protocol buffers are *here in
this file*.
z#robinson@google.com (Will Robinson)é)ÚBytesION)Úapi_implementation)Ú
containers)Údecoder)Úencoder)Úenum_type_wrapper)Úextension_dict)Úmessage_listener)Ú type_checkers)Úwell_known_types)Ú wire_format)Ú
descriptor©Úmessage)Ú text_formatzgoogle.protobuf.Anycs0eZdZdZdZ‡fdd„Z‡fdd„Z‡ZS)ÚGeneratedProtocolMessageTypeaQMetaclass for protocol message classes created at runtime from Descriptors.
 
  We add implementations for all methods described in the Message class.  We
  also create properties to allow getting/setting all fields in the protocol
  message.  Finally, we create slots to prevent users from accidentally
  "setting" nonexistent fields in the protocol message, which then wouldn't get
  serialized / deserialized properly.
 
  The protocol compiler currently uses this metaclass to create protocol
  message classes at runtime.  Clients can also manually create their own
  classes at runtime, as in this example:
 
  mydescriptor = Descriptor(.....)
  factory = symbol_database.Default()
  factory.pool.AddDescriptor(mydescriptor)
  MyProtoClass = factory.GetPrototype(mydescriptor)
  myproto_instance = MyProtoClass()
  myproto.foo_field = 23
  ...
  Ú
DESCRIPTORcs€|tj}t|tƒrtdƒ‚t|ddƒ}|r0|S|jtjkrN|tj|jf7}t    ||ƒt
||ƒt t|ƒ}|  ||||¡}|S)akCustom allocation for runtime-generated class types.
 
    We override __new__ because this is apparently the only place
    where we can meaningfully set __slots__ on the class we're creating(?).
    (The interplay between metaclasses and slots is not very well-documented).
 
    Args:
      name: Name of the class (ignored, but required by the
        metaclass protocol).
      bases: Base classes of the class we're constructing.
        (Should be message.Message).  We ignore this field, but
        it's required by the metaclass protocol
      dictionary: The class dictionary of the class we're
        constructing.  dictionary[_DESCRIPTOR_KEY] must contain
        a Descriptor object describing this protocol message
        type.
 
    Returns:
      Newly-allocated class.
 
    Raises:
      RuntimeError: Generated code only work with python cpp extension.
    z\The generated code only work with python cpp extension, but it is using pure python runtime.Ú_concrete_classN) rÚ_DESCRIPTOR_KEYÚ
isinstanceÚstrÚ RuntimeErrorÚgetattrÚ    full_namer ZWKTBASESÚ&_AddClassAttributesForNestedExtensionsÚ    _AddSlotsÚsuperÚ__new__)ÚclsÚnameÚbasesÚ
dictionaryr Ú    new_classÚ
superclass©Ú    __class__©ú^d:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\google/protobuf/internal/python_message.pyrhs
 
 
 
 
z$GeneratedProtocolMessageType.__new__csÜ|tj}t|ddƒ}|r4||ks0td|jƒ‚dSi|_|jr`| ¡jr`t     
|¡df|jt    j <|j D]}t ||ƒqf||_t||ƒt||ƒt||ƒt||ƒt|ƒt||ƒt||ƒtt|ƒ}| |||¡dS)a Here we perform the majority of our work on the class.
    We add enum getters, an __init__ method, implementations
    of all Message methods, and properties for all fields
    in the protocol type.
 
    Args:
      name: Name of the class (ignored, but required by the
        metaclass protocol).
      bases: Base classes of the class we're constructing.
        (Should be message.Message).  We ignore this field, but
        it's required by the metaclass protocol
      dictionary: The class dictionary of the class we're
        constructing.  dictionary[_DESCRIPTOR_KEY] must contain
        a Descriptor object describing this protocol message
        type.
    rNzBDuplicate `GeneratedProtocolMessageType` created for descriptor %r)rrrÚAssertionErrorrÚ_decoders_by_tagÚ has_optionsÚ
GetOptionsÚmessage_set_wire_formatrZMessageSetItemDecoderZMESSAGE_SET_ITEM_TAGÚfieldsÚ_AttachFieldHelpersrÚ_AddEnumValuesÚ_AddInitMethodÚ_AddPropertiesForFieldsÚ_AddPropertiesForExtensionsÚ_AddStaticMethodsÚ_AddMessageMethodsÚ_AddPrivateHelperMethodsrÚ__init__)rrr r!r Zexisting_classÚfieldr#r$r&r'r6s8
 
ÿÿÿÿ 
 
 
 
 
 
 
 
z%GeneratedProtocolMessageType.__init__)Ú__name__Ú
__module__Ú __qualname__Ú__doc__rrr6Ú __classcell__r&r&r$r'rMs 5rcCs|S)aReturns the name of the public property attribute which
  clients can use to get and (in some cases) set the value
  of a protocol message field.
 
  Args:
    proto_field_name: The protocol message field name, exactly
      as it appears (or would appear) in a .proto file.
  r&©Úproto_field_namer&r&r'Ú _PropertyNameØsr?c
Cs ddddddddd    d
g
|d <d S) a Adds a __slots__ entry to dictionary, containing the names of all valid
  attributes for this message type.
 
  Args:
    message_descriptor: A Descriptor instance describing this message type.
    dictionary: Class dictionary to which we'll add a '__slots__' entry.
  Ú_cached_byte_sizeÚ_cached_byte_size_dirtyÚ_fieldsÚ_unknown_fieldsÚ_unknown_field_setÚ_is_present_in_parentÚ    _listenerÚ_listener_for_childrenÚ __weakref__Ú_oneofsÚ    __slots__Nr&)Úmessage_descriptorr!r&r&r'rõs÷rcCs2|jo0|jjo0|j ¡jo0|jtjko0|jtj    kS©N)
Ú is_extensionÚcontaining_typer*r+r,ÚtypeÚ_FieldDescriptorÚ TYPE_MESSAGEÚlabelZLABEL_OPTIONAL©r7r&r&r'Ú_IsMessageSetExtension    sÿ
þ
ý
ürTcCs |jtjko|jjo|j ¡jSrL)rOrPrQÚ message_typer*r+Ú    map_entryrSr&r&r'Ú _IsMapFields
 ÿ
þrWcCs|jjd}|jtjkS)NÚvalue)rUÚfields_by_nameÚcpp_typerPÚCPPTYPE_MESSAGE)r7Z
value_typer&r&r'Ú_IsMessageMapFields r\csNˆjtjk‰ˆot ˆj¡}ˆjjdk‰|s2d}nFˆjjdkrPˆjoLˆ     ¡j
}n(ˆjopˆ     ¡  d¡opˆ     ¡j
dk}| }t ˆƒ‰ˆr t  ˆ¡}t  ˆtˆƒ¡}nNtˆƒrÂt  ˆj¡}t  ˆj¡}n,tjˆjˆjˆ|ƒ}tjˆjˆjˆ|ƒ}|ˆ_|ˆ_tˆƒˆ_‡‡‡‡‡fdd„}|tjˆjdƒˆrJt ˆj¡rJ|tjdƒdS)NÚproto3FZproto2Úpackedcsøt ˆj|¡}ˆj}|tjkr.t ˆ¡r.tj}d}d}ˆj    dk    rFˆ}nˆr^ˆs^ˆj
tj kr^d}ˆr~t ˆƒ}t  ˆtˆƒ|¡}nh|tjkr¢t  ˆjˆ|ˆˆj|¡}nDˆj
tj krÊtj|ˆjˆ|ˆˆjƒ}ntj|ˆjˆ|ˆˆj|ƒ}||fˆj|<dS©NFT)rZTagBytesÚnumberrOrPZ    TYPE_ENUMr
ZSupportsOpenEnumsZ
TYPE_INT32Úcontaining_oneofrZr[r\rZ
MapDecoderÚ_GetInitializeDefaultForMapZ TYPE_STRINGZ StringDecoderÚ_default_constructorZTYPE_TO_DECODERr))ZwiretypeÚ    is_packedÚ    tag_bytesZ decode_typeZoneof_descriptorZclear_if_defaultZis_message_mapÚ field_decoder©rÚfield_descriptorZ is_map_entryÚ    is_proto3Z is_repeatedr&r'Ú
AddDecoder?s^
ÿ
 
ÿþ
ý þüz'_AttachFieldHelpers.<locals>.AddDecoderT)rRrPÚLABEL_REPEATEDr ZIsTypePackablerOrNÚsyntaxr*r+r^ÚHasFieldrWrZ
MapEncoderZMapSizerr\rTZMessageSetItemEncoderr`ZMessageSetItemSizerr
ZTYPE_TO_ENCODERZ TYPE_TO_SIZERÚ_encoderÚ_sizerÚ _DefaultValueConstructorForFieldrcZFIELD_TYPE_TO_WIRE_TYPEZWIRETYPE_LENGTH_DELIMITED)rrhZ is_packablerdZhas_packed_falseZ field_encoderZsizerrjr&rgr'r.s^ 
ÿ  ÿ ÿ þ
ÿ 
ÿ
ÿÿ' ÿr.cCs0|j}| ¡D]\}}||ks"t‚|||<qdSrL)Úextensions_by_nameÚitemsr()r r!Ú
extensionsÚextension_nameÚextension_fieldr&r&r'ros rcCs@|jD]4}t||jt |¡ƒ|jD]}t||j|jƒq$qdS)aSets class-level attributes for all enum fields defined in this message.
 
  Also exporting a class-level object that can name enum values.
 
  Args:
    descriptor: Descriptor object for this message type.
    cls: Class we're constructing for this message type.
  N)Ú
enum_typesÚsetattrrrZEnumTypeWrapperÚvaluesr`)r rÚ    enum_typeZ
enum_valuer&r&r'r/vs    
 
r/csvˆjtjkrtdˆjƒ‚ˆjj}t |d¡‰|d‰t    ˆƒrT‡‡‡fdd„}|St ˆ¡‰‡‡‡fdd„}|SdS)Nz&map_entry set on non-repeated field %sÚkeyrXcst |jˆjˆˆj¡SrL)rZ
MessageMaprGrUr)r7Ú key_checkerÚ value_fieldr&r'ÚMakeMessageMapDefaultŽs þz:_GetInitializeDefaultForMap.<locals>.MakeMessageMapDefaultcst |jˆˆˆj¡SrL)rZ    ScalarMaprGrUr)r7r{Ú value_checkerr&r'ÚMakePrimitiveMapDefault•s þz<_GetInitializeDefaultForMap.<locals>.MakePrimitiveMapDefault)
rRrPrkÚ
ValueErrorrrUrYr
ÚGetTypeCheckerr\)r7rYr}rr&)r7r{r~r|r'rb…s ÿ
rbcsªtˆƒrtˆƒSˆjtjkrvˆjr:ˆjgkr:tdˆjƒ‚ˆjtj    kr\ˆj
‰‡fdd„}|St   ˆ¡‰‡fdd„}|Sˆjtj    kršˆj
‰‡‡fdd„}|S‡fdd    „}|S)
a‡Returns a function which returns a default value for a field.
 
  Args:
    field: FieldDescriptor object for this field.
 
  The returned function has one argument:
    message: Message instance containing this field, or a weakref proxy
      of same.
 
  That function in turn returns a default value for this field.  The default
    value may refer back to |message| via a weak reference.
  z/Repeated field default value not empty list: %scst |jˆj¡SrL)rZRepeatedCompositeFieldContainerrGrUrrSr&r'ÚMakeRepeatedMessageDefault´sÿzD_DefaultValueConstructorForField.<locals>.MakeRepeatedMessageDefaultcst |jˆ¡SrL)rZRepeatedScalarFieldContainerrGr)Ú type_checkerr&r'ÚMakeRepeatedScalarDefaultºsÿzC_DefaultValueConstructorForField.<locals>.MakeRepeatedScalarDefaultcsLtˆddƒs tdˆjˆjfƒ‚ˆ ¡}| ˆjdk    r@t|ˆƒn|j¡|S)NrzAUninitialized concrete class found for field %r (message type %r))rr(rrÚ _SetListenerraÚ_OneofListenerrG)rÚresult)r7rUr&r'ÚMakeSubMessageDefaultÂs
ÿÿÿ ýz?_DefaultValueConstructorForField.<locals>.MakeSubMessageDefaultcsˆjSrL)Ú default_valuerrSr&r'ÚMakeScalarDefaultÎsz;_DefaultValueConstructorForField.<locals>.MakeScalarDefault) rWrbrRrPrkZhas_default_valuer‰r€rZr[rUr
r)r7r‚r„rˆrŠr&)r7rUrƒr'rp›s( ÿ  
 
 rpcCsRt ¡d}t|jƒdkr<t|ƒtkr<tdt|ƒ||fƒ}| t ¡d¡‚dS)zCRe-raise the currently-handled TypeError with the field name added.éz%s for field %s.%séN)ÚsysÚexc_infoÚlenÚargsrOÚ    TypeErrorrÚwith_traceback)Z message_nameÚ
field_nameÚexcr&r&r'Ú_ReraiseTypeErrorWithFieldNameÕs r•cs,dd„‰‡‡fdd„}d|_d|_||_dS)zAdds an __init__ method to cls.cSsDt|tƒr@z|j|jWStk
r>td|j|fƒ‚YnX|S)aConvert a string or integer enum value to an integer.
 
    If the value is a string, it is converted to the enum value in
    enum_type with the same name.  If the value is not a string, it's
    returned as-is.  (No conversion or bounds-checking is done.)
    z Enum type %s: unknown label "%s")rrZvalues_by_namer`ÚKeyErrorr€r)ryrXr&r&r'Ú_GetIntegerEnumValueãs
ÿz,_AddInitMethod.<locals>._GetIntegerEnumValuec    sd|_t|ƒdk|_i|_i|_d|_d|_d|_t     ¡|_
t |ƒ|_ |  ¡D]Ä\}}tˆ|ƒ‰ˆdkr|tdˆj|fƒ‚|dkr†qNˆjtjkrRˆ |¡}ˆjtjkrtˆƒrætˆƒrÚ|D]}|| ||¡qÀn
| |¡n2|D],}t|tƒr|jf|Žqê| ¡ |¡qên,ˆjtjkr<‡‡fdd„|Dƒ}| |¡||jˆ<qNˆjtjkrƈ |¡}|}t|tƒrˆˆj j!f|Ž}z| |¡Wn"tk
r¸t"ˆj|ƒYnX||jˆ<qNˆjtjkràˆˆj#|ƒ}zt$|||ƒWqNtk
rt"ˆj|ƒYqNXqNdS)Nrr&Fz,%s() got an unexpected keyword argument "%s"csg|]}ˆˆj|ƒ‘qSr&)ry)Ú.0Úval)r—r7r&r'Ú
<listcomp>sÿz0_AddInitMethod.<locals>.init.<locals>.<listcomp>)%r@rrArBrIrCrDrEÚmessage_listener_modÚNullMessageListenerrFÚ    _ListenerrGrrÚ_GetFieldByNamer‘rrRrPrkrcrZr[rWr\Ú    MergeFromÚupdaterÚdictÚaddZ CPPTYPE_ENUMÚextendrUrr•ryrw)ÚselfÚkwargsr“Ú field_valueÚcopyrzr™Únew_val©r—rKrSr'Úinitòsf
 
 
ÿ
   ÿ
 
   z_AddInitMethod.<locals>.initN)r9r;r6)rKrrªr&r©r'r0às
@r0cCs8z |j|WStk
r2td|j|fƒ‚YnXdS)zóReturns a field descriptor by field name.
 
  Args:
    message_descriptor: A Descriptor describing all fields in message.
    field_name: The name of the field to retrieve.
  Returns:
    The field descriptor associated with the field name.
  ú&Protocol message %s has no "%s" field.N)rYr–r€r)rKr“r&r&r'rž7s      ÿržcCs.|jD]}t||ƒq|jr*tdd„ƒ|_dS)ú=Adds properties for all fields in this protocol message type.cSst|ƒSrL)Ú_ExtensionDict©r¤r&r&r'Ú<lambda>Oóz)_AddPropertiesForFields.<locals>.<lambda>N)r-Ú_AddPropertiesForFieldÚ is_extendableÚpropertyZ
Extensions)r rr7r&r&r'r1Gs
 r1cCshtjdkst‚|j ¡d}t|||jƒ|jtjkrBt    ||ƒn"|j
tj krZt ||ƒn
t ||ƒdS)a#Adds a public property for a protocol message field.
  Clients can use this property to get and (in the case
  of non-repeated scalar fields) directly set the value
  of a protocol message field.
 
  Args:
    field: A FieldDescriptor for this field.
    cls: The class we're constructing.
  é
Ú _FIELD_NUMBERN)rPZ MAX_CPPTYPEr(rÚupperrwr`rRrkÚ_AddPropertiesForRepeatedFieldrZr[Ú*_AddPropertiesForNonRepeatedCompositeFieldÚ'_AddPropertiesForNonRepeatedScalarField)r7rÚ constant_namer&r&r'r±Rs     r±c@seZdZdZdd„ZdS)Ú_FieldProperty)rcCstj||||d||_dS)N©Údoc)r³r6r)r¤r ÚgetterÚsetterr½r&r&r'r6nsz_FieldProperty.__init__N)r8r9r:rJr6r&r&r&r'r»ksr»c    sZˆj‰tˆƒ}‡fdd„}d|_dˆ|_‡fdd„}dˆ}t||tˆ|||dƒdS)    aAdds a public property for a "repeated" protocol message field.  Clients
  can use this property to get the value of the field, which will be either a
  RepeatedScalarFieldContainer or RepeatedCompositeFieldContainer (see
  below).
 
  Note that when clients add values to these containers, we perform
  type-checking in the case of repeated scalar fields, and we also set any
  necessary "has" bits as a side-effect.
 
  Args:
    field: A FieldDescriptor for this field.
    cls: The class we're constructing.
  cs0|j ˆ¡}|dkr,ˆ |¡}|j ˆ|¡}|SrL©rBÚgetrcÚ
setdefault©r¤r¦rSr&r'r¾„s
 
z._AddPropertiesForRepeatedField.<locals>.getterNúGetter for %s.cstdˆƒ‚dS)NzIAssignment not allowed to repeated field "%s" in protocol message object.©ÚAttributeError©r¤Ú    new_valuer=r&r'r¿—sÿz._AddPropertiesForRepeatedField.<locals>.setterú/Magic attribute generated for "%s" proto field.r¼©rr?r9r;rwr»©r7rÚ property_namer¾r¿r½r&©r7r>r'r·ss 
 r·c    s²ˆj}t|ƒ}t ˆ¡‰ˆj‰ˆjjdk}‡‡fdd„}d|_d||_|oRˆj     ‰‡‡‡fdd„‰ˆj    rz‡‡fdd    „}nˆ}d|_d
||_d |}t
||t ˆ|||d ƒdS) a Adds a public property for a nonrepeated, scalar protocol message field.
  Clients can use this property to get and directly set the value of the field.
  Note that when the client sets the value of a field by using this property,
  all necessary "has" bits are set as a side-effect, and we also perform
  type-checking.
 
  Args:
    field: A FieldDescriptor for this field.
    cls: The class we're constructing.
  r]cs|j ˆˆ¡SrL)rBrÁr®)r‰r7r&r'r¾°sz7_AddPropertiesForNonRepeatedScalarField.<locals>.getterNrÄc
szzˆ |¡}Wn6tk
rD}ztdˆj||fƒ‚W5d}~XYnXˆr^|s^|j ˆd¡n
||jˆ<|jsv| ¡dS)NzCannot set %s to %.1024r: %s)Z
CheckValuer‘rrBÚpoprAÚ    _Modified)r¤rÈÚe)Úclear_when_set_to_defaultr7rƒr&r'Ú field_setter¹sÿ
z=_AddPropertiesForNonRepeatedScalarField.<locals>.field_settercsˆ||ƒ| ˆ¡dSrL)Ú_UpdateOneofStaterÇ)r7rÒr&r'r¿Ìs
z7_AddPropertiesForNonRepeatedScalarField.<locals>.setterzSetter for %s.rÉr¼) rr?r
rr‰rNrlr9r;rarwr»)r7rr>rÌrir¾r¿r½r&)rÑr‰r7rÒrƒr'r¹Ÿs" 
 
 
r¹c    sZˆj‰tˆƒ}‡fdd„}d|_dˆ|_‡fdd„}dˆ}t||tˆ|||dƒdS)    aNAdds a public property for a nonrepeated, composite protocol message field.
  A composite field is a "group" or "message" field.
 
  Clients can use this property to get the value of the field, but cannot
  assign to the property directly.
 
  Args:
    field: A FieldDescriptor for this field.
    cls: The class we're constructing.
  cs0|j ˆ¡}|dkr,ˆ |¡}|j ˆ|¡}|SrLrÀrÃrSr&r'r¾ês
 
z:_AddPropertiesForNonRepeatedCompositeField.<locals>.getterNrÄcstdˆƒ‚dS)NzJAssignment not allowed to composite field "%s" in protocol message object.rÅrÇr=r&r'r¿ýsÿz:_AddPropertiesForNonRepeatedCompositeField.<locals>.setterrÉr¼rÊrËr&rÍr'r¸Ús  
 r¸cCs`|j}| ¡D]"\}}| ¡d}t|||jƒq|jdk    r\|jj}|j||_|j||_dS)r¬rµN)    rqrrr¶rwr`ÚfileÚpoolZ_extensions_by_numberZ_extensions_by_name)r rrsrtrurºrÕr&r&r'r2s 
 r2cs0‡fdd„}t|ƒˆ_‡fdd„}t|ƒˆ_dS)Ncs&ˆj|_ˆjjj |¡tˆ|ƒdSrL)rrNrÔrÕZ_AddExtensionDescriptorr.)Úextension_handle©rr&r'ÚRegisterExtensionsz,_AddStaticMethods.<locals>.RegisterExtensioncsˆƒ}| |¡|SrL)ÚMergeFromString)Úsrr×r&r'Ú
FromStrings
z%_AddStaticMethods.<locals>.FromString)Ú staticmethodrØrÛ)rrØrÛr&r×r'r3s 
 r3cCs>|djtjkrt|dƒS|djtjkr6|djSdSdS)zˆGiven a (FieldDescriptor, value) tuple from _fields, return true if the
  value should be included in the list returned by ListFields().rr‹TN)rRrPrkÚboolrZr[rE©Úitemr&r&r'Ú
_IsPresent&s
 
ràcCsdd„}||_dS)ú Helper for _AddMessageMethods().cSs(dd„|j ¡Dƒ}|jdd„d|S)NcSsg|]}t|ƒr|‘qSr&)rà)r˜rßr&r&r'rš6sz<_AddListFieldsMethod.<locals>.ListFields.<locals>.<listcomp>cSs
|djS)Nr)r`rÞr&r&r'r¯7r°z:_AddListFieldsMethod.<locals>.ListFields.<locals>.<lambda>)rz)rBrrÚsort)r¤Z
all_fieldsr&r&r'Ú
ListFields5sz(_AddListFieldsMethod.<locals>.ListFieldsN)rã)rKrrãr&r&r'Ú_AddListFieldsMethod2sräzTProtocol message %s has no non-repeated submessage field "%s" nor marked as optionalz2Protocol message %s has no non-repeated field "%s"csˆˆjdk}|rtnt‰i‰ˆjD]4}|jtjkr2q |rJ|jtjkrJ|j    sJq |ˆ|j
<q ˆj D]}|ˆ|j
<q\‡‡‡‡fdd„‰ˆ|_ dS)rár]cs¢z ˆ|}Wn&tk
r2tˆˆj|fƒ‚YnXt|tjƒrnzˆ||j|jƒWStk
rjYdSXn0|jt    j
kr”|j   |¡}|dk    o’|j S||j kSdS)NF)r–r€rrÚdescriptor_modZOneofDescriptorrIrrZrPr[rBrÁrE)r¤r“r7rX©rmÚ    error_msgZhassable_fieldsrKr&r'rmUs  
  z$_AddHasFieldMethod.<locals>.HasFieldN) rlÚ_PROTO3_ERROR_TEMPLATEÚ_PROTO2_ERROR_TEMPLATEr-rRrPrkrZr[rarZoneofsrm)rKrrir7Zoneofr&rær'Ú_AddHasFieldMethodAs
 
 ÿ 
 rêcs‡fdd„}||_dS)rác sÒzˆj|}Wnhtk
rvz,ˆj|}||jkr@|j|}nWYdSWn&tk
rptdˆj|fƒ‚YnXYnX||jkrÆt|j|dƒr |j| ¡|j|=|j     |j
d¡|krÆ|j|j
=|  ¡dS)Nr«ÚInvalidateIterators) rYr–Úoneofs_by_namerIr€rrBÚhasattrrërÁrarÏ)r¤r“r7©rKr&r'Ú
ClearFieldls&
 
  ÿ
 
z(_AddClearFieldMethod.<locals>.ClearFieldN)rï)rKrrïr&rîr'Ú_AddClearFieldMethodjs !rðcCsdd„}||_dS)rácSs*t ||¡||jkr|j|=| ¡dSrL)rÚ_VerifyExtensionHandlerBrÏ)r¤rÖr&r&r'ÚClearExtension’s 
z0_AddClearExtensionMethod.<locals>.ClearExtensionN)rò)rròr&r&r'Ú_AddClearExtensionMethodsrócCsdd„}||_dS)rácSsZt ||¡|jtjkr&td|jƒ‚|jtjkrL|j     
|¡}|dk    oJ|j S||j    kSdS)Nz"%s" is repeated.) rrñrRrPrkr–rrZr[rBrÁrE)r¤rÖrXr&r&r'Ú HasExtensionžs    z,_AddHasExtensionMethod.<locals>.HasExtensionN)rô)rrôr&r&r'Ú_AddHasExtensionMethodœs
rõcCshddlm}| ¡}|j}|s"dS| d¡d}|j |¡}|dkrHdS| |¡}|ƒ}| |j    ¡|S)atUnpacks Any message and returns the unpacked message.
 
  This internal method is different from public Any Unpack method which takes
  the target message as argument. _InternalUnpackAny method does not have
  target message type and need to find the message type in descriptor pool.
 
  Args:
    msg: An Any message to be unpacked.
 
  Returns:
    The unpacked message.
  r)Úsymbol_databaseNú/éÿÿÿÿ)
Úgoogle.protobufröZDefaultÚtype_urlÚsplitrÕZFindMessageTypeByNameZ GetPrototypeZParseFromStringrX)ÚmsgröÚfactoryrúZ    type_namer Z message_classrr&r&r'Ú_InternalUnpackAnyªs  
 rþcCsdd„}||_dS)rácSs”t|tjƒr|j|jkrdS||kr(dS|jjtkrTt|ƒ}t|ƒ}|rT|rT||kS| ¡| ¡kshdSt|j    ƒ}| 
¡t|j    ƒ}| 
¡||kSr_) rÚ message_modÚMessagerrÚ_AnyFullTypeNamerþrãÚlistrCrâ)r¤ÚotherZany_aZany_bZunknown_fieldsZother_unknown_fieldsr&r&r'Ú__eq__Ôs$ 
ÿ 
 
z _AddEqualsMethod.<locals>.__eq__N)r)rKrrr&r&r'Ú_AddEqualsMethodÒsrcCsdd„}||_dS)rácSs
t |¡SrL©rÚMessageToStringr®r&r&r'Ú__str__òsz_AddStrMethod.<locals>.__str__N)r)rKrrr&r&r'Ú _AddStrMethodðsr    cCsdd„}||_dS)rácSs
t |¡SrLrr®r&r&r'Ú__repr__ùsz _AddReprMethod.<locals>.__repr__N)r
)rKrr
r&r&r'Ú_AddReprMethod÷sr cCsdd„}||_dS)rácSstj|dd d¡S)NT)Zas_utf8zutf-8)rrÚdecoder®r&r&r'Ú __unicode__sz&_AddUnicodeMethod.<locals>.__unicode__N)r )Zunused_message_descriptorrr r&r&r'Ú_AddUnicodeMethodþsrcCs>ztj|}|||ƒWStk
r8t d|¡‚YnXdS)a Returns the number of bytes needed to serialize a non-repeated element.
  The returned byte count includes space for tag information and any
  other additional space associated with serializing value.
 
  Args:
    value: Value we're serializing.
    field_number: Field number of this value.  (Since the field number
      is stored as part of a varint-encoded tag, this has an impact
      on the total bytes required to serialize the value).
    field_type: The type of the field.  One of the TYPE_* constants
      within FieldDescriptor.
  zUnrecognized field type: %dN)r
ZTYPE_TO_BYTE_SIZE_FNr–rÿÚ EncodeError)rXÚ field_numberZ
field_typeÚfnr&r&r'Ú_BytesForNonRepeatedElements
 
 rcCsdd„}||_dS)rácSs¦|js |jSd}|j}| ¡jrJ|jd |j¡}||jd |j¡7}nD|     ¡D]\}}|| |¡7}qR|j
D]\}}|t |ƒt |ƒ7}qp||_d|_d|j _ |S)NrrzrXF)rAr@rr+rVrYrorzrXrãrCrrGÚdirty)r¤Úsizer rhr¦reÚ value_bytesr&r&r'ÚByteSizes
z$_AddByteSizeMethod.<locals>.ByteSizeN)r)rKrrr&r&r'Ú_AddByteSizeMethodsrcCsdd„}||_dS)rác[s4| ¡s(t d|jjd | ¡¡f¡‚|jf|ŽS)Nz)Message %s is missing required fields: %sú,)Ú IsInitializedrÿrrrÚjoinÚFindInitializationErrorsÚSerializePartialToString)r¤r¥r&r&r'ÚSerializeToString8s ÿÿz6_AddSerializeToStringMethod.<locals>.SerializeToStringN)r)rKrrr&r&r'Ú_AddSerializeToStringMethod5srcCs"dd„}||_ddd„}||_dS)rác[stƒ}|j|jf|Ž| ¡SrL)rÚ_InternalSerializeÚwriteÚgetvalue)r¤r¥Úoutr&r&r'rEszD_AddSerializePartialToStringMethod.<locals>.SerializePartialToStringNcSsœ|dkrt ¡}nt|ƒ}|j}| ¡jrX|jd ||j|¡|jd ||j    |¡n@| 
¡D]\}}| |||¡q`|j D]\}}||ƒ||ƒq~dS)NrzrX) rZ)IsPythonDefaultSerializationDeterministicrÝrr+rVrYrnrzrXrãrC)r¤Ú write_bytesZ deterministicr rhr¦rerr&r&r'ÚInternalSerializeKs*ÿ
 
ÿ
ÿz=_AddSerializePartialToStringMethod.<locals>.InternalSerialize)N)rr)rKrrr$r&r&r'Ú"_AddSerializePartialToStringMethodBs
r%cs:dd„}||_tj‰tj‰|j‰‡‡‡fdd„}||_dS)rác
Ss„t|ƒ}t|ƒ}z | |d|¡|kr.t d¡‚WnNttfk
rRt d¡‚Yn.tjk
r~}zt |¡‚W5d}~XYnX|S)NrzUnexpected end-group tag.zTruncated message.)    Ú
memoryviewrÚ_InternalParserÿÚ DecodeErrorÚ
IndexErrorr‘ÚstructÚerror)r¤Z
serializedÚlengthrÐr&r&r'rÙdsz2_AddMergeFromStringMethod.<locals>.MergeFromStringcs8t|tƒst‚| ¡|j}|j}||kr4ˆ||ƒ\}}ˆ |d¡\}}    |dkr|js`g|_|dkrxt     ¡|_|j}t
  |d¡\}
} t   |
¡\} } | dkr¨t d¡‚|}t
 ||| ¡\}}|dkrÊ|S| | | |¡ˆ||||ƒ}|dkrò|S|j ||||… ¡f¡|}q"||||||ƒ}|    r"| |    ¡q"|S)a6Create a message from serialized bytes.
 
    Args:
      self: Message, instance of the proto message object.
      buffer: memoryview of the serialized data.
      pos: int, position to start in the serialized data.
      end: int, end position of the serialized data.
 
    Returns:
      Message object.
    )NNNrzField number 0 is illegal.rø)rr&r(rÏrBrDrÁrCrÚUnknownFieldSetrZ _DecodeVarintr Z    UnpackTagrÿr(Z_DecodeUnknownFieldZ_addÚappendÚtobytesrÓ)r¤ÚbufferÚposÚendZ
field_dictZunknown_field_setreÚnew_posrfZ
field_descÚtagÚ_rZ    wire_typeZold_posÚdata©Zdecoders_by_tagZ local_ReadTagZlocal_SkipFieldr&r'Ú InternalParsexsJ
 
 
 
ÿÿ z0_AddMergeFromStringMethod.<locals>.InternalParseN)rÙrZReadTagZ    SkipFieldr)r')rKrrÙr8r&r7r'Ú_AddMergeFromStringMethodbs7r9cs:dd„|jDƒ‰d‡fdd„    }||_‡fdd„}||_dS)    z[Adds the IsInitialized and FindInitializationError methods to the
  protocol message class.cSsg|]}|jtjkr|‘qSr&)rRrPZLABEL_REQUIRED)r˜r7r&r&r'rš¶s ÿz+_AddIsInitializedMethod.<locals>.<listcomp>NcsîˆD]B}||jks*|jtjkr|j|js|dk    r@| | ¡¡dSqt|j ¡ƒD]’\}}|jtjkrV|j    tj
kr¾|j j rŒ|j   ¡jrŒqV|D]*}| ¡s|dk    r²| | ¡¡dSqqV|jrV| ¡sV|dk    râ| | ¡¡dSqVdS)aChecks if all required fields of a message are set.
 
    Args:
      errors:  A list which, if provided, will be populated with the field
               paths of all missing required fields.
 
    Returns:
      True iff the specified message has all required fields set.
    NFT)rBrZrPr[rEr£rrrrrRrkrUr*r+rVr)r¤Úerrorsr7rXÚelement©Zrequired_fieldsr&r'r¹s4 
 
ÿ
þ  
ÿ z._AddIsInitializedMethod.<locals>.IsInitializedc    s(g}ˆD]}| |j¡s| |j¡q| ¡D]ô\}}|jtjkr.|jrTd|j}n|j}t    |ƒrªt
|ƒr¨|D]6}||}d||f‰|  ¡}|‡fdd„|Dƒ7}qnnq.|j tj krütt|ƒƒD]6}||}d||f‰|  ¡}|‡fdd„|Dƒ7}qÂq.|d‰|  ¡}|‡fdd„|Dƒ7}q.|S)    zÆFinds required fields which are not initialized.
 
    Returns:
      A list of strings.  Each string is a path to an uninitialized field from
      the top-level message, e.g. "foo.bar[5].baz".
    z(%s)z%s[%s].csg|] }ˆ|‘qSr&r&©r˜r+©Úprefixr&r'ršýszM_AddIsInitializedMethod.<locals>.FindInitializationErrors.<locals>.<listcomp>z%s[%d].csg|] }ˆ|‘qSr&r&r=r>r&r'ršsÚ.csg|] }ˆ|‘qSr&r&r=r>r&r'rš
s)rmrr.rãrZrPr[rMrrWr\rrRrkÚranger)    r¤r:r7rXrrzr;Z
sub_errorsÚir<r>r'râs6      z9_AddIsInitializedMethod.<locals>.FindInitializationErrors)N)r-rr)rKrrrr&r<r'Ú_AddIsInitializedMethod²s
' ,rCcCs,|j}t|d|jƒ}|dkr |S|d|S)Nr:)NÚbuiltinsÚ __builtin__r@)r9rr8)ÚklassÚmodulerr&r&r'Ú_FullyQualifiedClassNames
rHcs&tj‰tj‰‡‡‡fdd„}|ˆ_dS)Ncs0t|ˆƒs$tdtˆƒt|jƒfƒ‚||k    s0t‚| ¡|j}|j ¡D]œ\}}|jˆkrŠ|     |¡}|dkr~| 
|¡}|||<|  |¡qH|j ˆkrÊ|j rä|     |¡}|dkr¾| 
|¡}|||<|  |¡qH||j|<|jrH| |¡qH|jr,|jsúg|_|j |j¡|jdkrt ¡|_|j |j¡dS)NzLParameter to MergeFrom() must be instance of same class: expected %s got %s.)rr‘rHr%r(rÏrBrrrRrÁrcrŸrZrErarÓrCr£rDrr-Z_extend)r¤rür-r7rXr¦©r[rkrr&r'rŸsF
ÿÿÿ 
 
 
 
 
 
 
 
z&_AddMergeFromMethod.<locals>.MergeFrom)rPrkr[rŸ)rrŸr&rIr'Ú_AddMergeFromMethods*rJcs‡fdd„}||_dS)Ncs`zˆj|}Wn tk
r.td|ƒ‚YnX|j |d¡}|dk    rX| |j¡rX|jSdSdS)zDReturns the name of the currently set field inside a oneof, or None.z)Protocol message has no oneof "%s" field.N)rìr–r€rIrÁrmr)r¤Z
oneof_namer7Z nested_fieldrîr&r'Ú
WhichOneofKsÿ
z(_AddWhichOneofMethod.<locals>.WhichOneof)rK)rKrrKr&rîr'Ú_AddWhichOneofMethodJs rLcCs8i|_d|_|jdk    r&|j ¡d|_i|_| ¡dS)Nr&)rBrCrDÚ_clearrIrÏr®r&r&r'Ú_Clear\s
 
rNcCs|jdkrt ¡|_|jSrL)rDrr-r®r&r&r'Ú_UnknownFieldsis
 
rOcCs~g|_d|_| ¡D]d\}}|jtjkrt|ƒrPt|ƒrx|D]}|| ¡q<q|j    tj
krp|D] }| ¡q`q| ¡qdSrL) rCrDrãrZrPr[rWr\ÚDiscardUnknownFieldsrRrk)r¤r7rXrzZ sub_messager&r&r'Ú_DiscardUnknownFieldsps   rQcCs|dkrt ¡|_n||_dSrL)r›rœrF)r¤Zlistenerr&r&r'r…€s r…cCs¼t||ƒt||ƒt||ƒ|jr4t|ƒt|ƒt||ƒt||ƒt||ƒt    ||ƒt
||ƒt ||ƒt ||ƒt ||ƒt||ƒt|ƒt||ƒt|_t|_t|_t|_dS)z3Adds implementations of all Message methods to cls.N)rärêrðr²rórõrr    r rrrr%r9rCrJrLrNZClearrOZ UnknownFieldsrQrPr…)rKrr&r&r'r4‡s*
 
 
 
 
 
 
 
 
 
 
 
 
r4cCs&dd„}dd„}||_||_||_dS)z5Adds implementation of private helper methods to cls.cSs(|js$d|_d|j_d|_|j ¡dS)zwSets the _cached_byte_size_dirty bit to true,
    and propagates this to our listener iff this was a state change.
    TN)rArGrrErFÚModifiedr®r&r&r'rR¤s
    z*_AddPrivateHelperMethods.<locals>.ModifiedcSs0|j |j|¡}||k    r,|j|=||j|j<dS)zÈSets field as the active field in its containing oneof.
 
    Will also delete currently active field in the oneof, if it is different
    from the argument. Does not mark the message as modified.
    N)rIrÂrarB)r¤r7Z other_fieldr&r&r'rÓ³sz3_AddPrivateHelperMethods.<locals>._UpdateOneofStateN)rÏZ SetInParentrÓ)rKrrRrÓr&r&r'r5¡s
 r5c@s eZdZdZdd„Zdd„ZdS)ra0MessageListener implementation that a parent message registers with its
  child message.
 
  In order to support semantics like:
 
    foo.bar.baz.qux = 23
    assert foo.HasField('bar')
 
  ...child objects must have back references to their parents.
  This helper class is at the heart of this support.
  cCs*t|tjƒr||_n t |¡|_d|_dS)zArgs:
      parent_message: The message whose _Modified() method we should call when
        we receive Modified() messages.
    FN)rÚweakrefÚ    ProxyTypeÚ_parent_message_weakrefÚproxyr)r¤Úparent_messager&r&r'r6Ñs      z_Listener.__init__cCs2|jr
dSz|j ¡Wntk
r,YnXdSrL)rrUrÏÚReferenceErrorr®r&r&r'rRäs z_Listener.ModifiedN)r8r9r:r;r6rRr&r&r&r'rÃs rcs,eZdZdZ‡fdd„Z‡fdd„Z‡ZS)r†zCSpecial listener implementation for setting composite oneof fields.cstt|ƒ |¡||_dS)zËArgs:
      parent_message: The message whose _Modified() method we should call when
        we receive Modified() messages.
      field: The descriptor of the field being set in the parent message.
    N)rr†r6Ú_field)r¤rWr7r$r&r'r6ôsz_OneofListener.__init__cs:z |j |j¡tt|ƒ ¡Wntk
r4YnXdS)zEAlso updates the state of the containing oneof in the parent message.N)rUrÓrYrr†rRrXr®r$r&r'rRýs
z_OneofListener.Modified)r8r9r:r;r6rRr<r&r&r$r'r†ñs     r†)Tr;Ú
__author__Úiorr*rrSZgoogle.protobuf.internalrrrrrrr    r›r
r r rùr rårrÿrZFieldDescriptorrPrr­rOrr?rrTrWr\r.rr/rbrpr•r0ržr1r±r³r»r·r¹r¸r2r3ràrärèrérêrðrórõrþrr    r rrrrr%r9rCrHrJrLrNrOrQr…r4r5Úobjectrr†r&r&r&r'Ú<module>$s–               S: W ,;,  ÿ)& (  P_1 ".