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
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
U
£ý°diñã @sdZdZddlZddlZddlZddlZddlZddlm    Z    ddlm
Z
ddl m Z ddl m Z dd    d
d d d dgZe
 ¡e
 ¡e
 ¡e
 ¡fZe dej¡Ze dej¡ZedƒZdZGdd„deƒZGdd„deƒZGdd„deƒZdQdd„Z dd„Z!dd„Z"dRdd
„Z#dSdd „Z$dTd d „Z%d!d"„Z&d#Z'd$Z(Gd%d&„d&eƒZ)dUd'd    „Z*dVd(d „Z+dWd)d*„Z,dXd+d,„Z-Gd-d.„d.eƒZ.d/d0„Z/d1d2„Z0d3d4„Z1d5d6„Z2Gd7d8„d8eƒZ3e3Z4d9d:„Z5d;d<„Z6d=d>„Z7d?d@„Z8dAdB„Z9dCdD„Z:dYdEdF„Z;dZdGdH„Z<dIdJ„Z=dKdL„Z>dMdN„Z?dOdP„Z@dS)[acContains routines for printing protocol messages in text format.
 
Simple usage example::
 
  # Create a proto object and serialize it to a text proto string.
  message = my_proto_pb2.MyMessage(foo='bar')
  text_proto = text_format.MessageToString(message)
 
  # Parse a text proto string.
  message = text_format.Parse(text_proto, my_proto_pb2.MyMessage())
z kenton@google.com (Kenton Varda)éN)Údecoder)Ú type_checkers)Ú
descriptor)Ú text_encodingÚMessageToStringÚParseÚ PrintMessageÚ
PrintFieldÚPrintFieldValueÚMergeÚMessageToBytesz-?inf(?:inity)?f?$znanf?$)ú'ú"zgoogle.protobuf.Anyc@seZdZdZdS)ÚErrorz'Top-level module error for text_format.N)Ú__name__Ú
__module__Ú __qualname__Ú__doc__©rrúRd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\google/protobuf/text_format.pyrGsrcs2eZdZdZd    ‡fdd„    Zdd„Zdd„Z‡ZS)
Ú
ParseErrorz3Thrown in case of text parsing or tokenizing error.Ncsr|dk    r:|dk    r:t|ƒ}|dk    r.|d |¡7}d ||¡}|dk    rTtt|ƒ |¡ntt|ƒ ¡||_||_dS)Nz:{0}z    {0} : {1})ÚstrÚformatÚsuperrÚ__init__Ú_lineÚ_column)ÚselfÚmessageÚlineÚcolumnÚloc©Ú    __class__rrrNs zParseError.__init__cCs|jS©N)r©rrrrÚGetLine[szParseError.GetLinecCs|jSr$)rr%rrrÚ    GetColumn^szParseError.GetColumn)NNN)rrrrrr&r'Ú __classcell__rrr"rrKs rc@s,eZdZdd„Zdd„Zdd„Zdd„Zd    S)
Ú
TextWritercCst ¡|_dSr$)ÚioÚStringIOÚ_writer)rÚas_utf8rrrrdszTextWriter.__init__cCs |j |¡Sr$)r,Úwrite)rÚvalrrrr.gszTextWriter.writecCs
|j ¡Sr$)r,Úcloser%rrrr0jszTextWriter.closecCs
|j ¡Sr$)r,Úgetvaluer%rrrr1mszTextWriter.getvalueN)rrrrr.r0r1rrrrr)bsr)FcCsVt|ƒ}t||
|||||||||    | | | d}| |¡| ¡}| ¡|rR| ¡S|S)aT    Convert protobuf message to text format.
 
  Double values can be formatted compactly with 15 digits of
  precision (which is the most that IEEE 754 "double" can guarantee)
  using double_format='.15g'. To ensure that converting to text and back to a
  proto will result in an identical value, double_format='.17g' should be used.
 
  Args:
    message: The protocol buffers message.
    as_utf8: Return unescaped Unicode for non-ASCII characters.
        In Python 3 actual Unicode characters may appear as is in strings.
        In Python 2 the return value will be valid UTF-8 rather than only ASCII.
    as_one_line: Don't introduce newlines between fields.
    use_short_repeated_primitives: Use short repeated format for primitives.
    pointy_brackets: If True, use angle brackets instead of curly braces for
      nesting.
    use_index_order: If True, fields of a proto message will be printed using
      the order defined in source code instead of the field number, extensions
      will be printed at the end of the message and their relative order is
      determined by the extension number. By default, use the field number
      order.
    float_format (str): If set, use this to specify float field formatting
      (per the "Format Specification Mini-Language"); otherwise, shortest float
      that has same value in wire will be printed. Also affect double field
      if double_format is not set but float_format is set.
    double_format (str): If set, use this to specify double field formatting
      (per the "Format Specification Mini-Language"); if it is not set but
      float_format is set, use float_format. Otherwise, use ``str()``
    use_field_number: If True, print field numbers instead of names.
    descriptor_pool (DescriptorPool): Descriptor pool used to resolve Any types.
    indent (int): The initial indent level, in terms of spaces, for pretty
      print.
    message_formatter (function(message, indent, as_one_line) -> unicode|None):
      Custom formatter for selected sub-messages (usually based on message
      type). Use to pretty print parts of the protobuf for easier diffing.
    print_unknown_fields: If True, unknown fields will be printed.
    force_colon: If set, a colon will be added after the field name even if the
      field is a proto message.
 
  Returns:
    str: A string of the text formatted protocol buffer message.
  )Úprint_unknown_fieldsÚ force_colon)r)Ú_Printerrr1r0Úrstrip)rr-Ú as_one_lineÚuse_short_repeated_primitivesÚpointy_bracketsÚuse_index_orderÚ float_formatÚ double_formatÚuse_field_numberÚdescriptor_poolÚindentÚmessage_formatterr2r3ÚoutÚprinterÚresultrrrrqs.:ò
cKs6t|f|Ž}t|tƒr|S| d¡r(dnd}| |¡S)zFConvert protobuf message to encoded text format.  See MessageToString.r-úutf-8Úascii)rÚ
isinstanceÚbytesÚgetÚencode)rÚkwargsÚtextÚcodecrrrr Ãs
 
cCs"|jtjjko |jjo |j ¡jSr$)ÚtyperÚFieldDescriptorÚ TYPE_MESSAGEÚ message_typeZ has_optionsÚ
GetOptionsZ    map_entry)ÚfieldrrrÚ _IsMapEntryÍs
ÿ
þrRcCs2t|||||||||    |
| | | |d}| |¡dS)N©r@r>r-r6r7r8r9r:r;r<r=r?r2r3)r4r)rr@r>r-r6r7r8r9r:r;r<r=r?r2r3rArrrrÓs"ô cCs0t||||||||    |
| | | d }| ||¡dS)ú%Print a single field name/value pair.©r?r2r3N)r4r    ©rQÚvaluer@r>r-r6r7r8r9r:r;r?r2r3rArrrr    òs
ûcCs0t||||||||    |
| | | d }| ||¡dS)z0Print a single field value (not including name).rUN)r4r
rVrrrr
 
s
ûcCsf|dkrddlm}| ¡}ddlm}| ¡}z| |¡}Wntk
rTYdSX| |¡}|ƒS)a!Returns a protobuf message instance.
 
  Args:
    type_name: Fully-qualified protobuf  message type name string.
    descriptor_pool: DescriptorPool instance.
 
  Returns:
    A Message instance of type matching type_name, or None if the a Descriptor
    wasn't found matching type_name.
  Nr)r=)Úsymbol_database)Úgoogle.protobufr=ZDefaultrXZFindMessageTypeByNameÚKeyErrorZ GetPrototype)Z    type_namer=Zpool_modrXZdatabaseÚmessage_descriptorrOrrrÚ_BuildMessageFromTypeName"s   
r\ééc @sbeZdZdZddd„Zdd„Zd    d
„Zd d „Zd d„Zdd„Z    dd„Z
dd„Z dd„Z dd„Z dS)r4z)Text format printer for protocol message.rFNcCsh||_||_||_||_||_||_||_||_|    dk    r@|    |_n||_|
|_    | |_
| |_ | |_ ||_ dS)afInitialize the Printer.
 
    Double values can be formatted compactly with 15 digits of precision
    (which is the most that IEEE 754 "double" can guarantee) using
    double_format='.15g'. To ensure that converting to text and back to a proto
    will result in an identical value, double_format='.17g' should be used.
 
    Args:
      out: To record the text format result.
      indent: The initial indent level for pretty print.
      as_utf8: Return unescaped Unicode for non-ASCII characters.
          In Python 3 actual Unicode characters may appear as is in strings.
          In Python 2 the return value will be valid UTF-8 rather than ASCII.
      as_one_line: Don't introduce newlines between fields.
      use_short_repeated_primitives: Use short repeated format for primitives.
      pointy_brackets: If True, use angle brackets instead of curly braces for
        nesting.
      use_index_order: If True, print fields of a proto message using the order
        defined in source code instead of the field number. By default, use the
        field number order.
      float_format: If set, use this to specify float field formatting
        (per the "Format Specification Mini-Language"); otherwise, shortest
        float that has same value in wire will be printed. Also affect double
        field if double_format is not set but float_format is set.
      double_format: If set, use this to specify double field formatting
        (per the "Format Specification Mini-Language"); if it is not set but
        float_format is set, use float_format. Otherwise, str() is used.
      use_field_number: If True, print field numbers instead of names.
      descriptor_pool: A DescriptorPool used to resolve Any types.
      message_formatter: A function(message, indent, as_one_line): unicode|None
        to custom format selected sub-messages (usually based on message type).
        Use to pretty print parts of the protobuf for easier diffing.
      print_unknown_fields: If True, unknown fields will be printed.
      force_colon: If set, a colon will be added after the field name even if
        the field is a proto message.
    NrS)rr@r>r-r6r7r8r9r:r;r<r=r?r2r3rrrrCs 4z_Printer.__init__cCs†d|jkrdSt| ¡|jƒ}|r~| |j¡|jr8dnd}|j d|j    d|j|f¡| 
|¡|j |j rtdnd¡dSdSd    S)
z5Serializes if message is a google.protobuf.Any field.ú/Fú:Úz    %s[%s]%s ú Ú
TN) Ztype_urlr\ZTypeNamer=ZMergeFromStringrWr3r@r.r>Ú_PrintMessageFieldValuer6)rrZpacked_messageÚcolonrrrÚ_TryPrintAsAnyMessage‰s
ÿ 
z_Printer._TryPrintAsAnyMessagecCsV| ||j|j¡}|dkrdS|j}| d|j¡| |¡| |jrLdnd¡dS)NFrbrcT)r?r>r6r@r.)rrÚ    formattedr@rrrÚ_TryCustomFormatMessage™s
z _Printer._TryCustomFormatMessagecCs|jr| |¡rdS|jjtkr.| |¡r.dS| ¡}|jrL|jdd„d|D]¢\}}t    |ƒrt
|ƒD]$}|  ¡|||d}|  ||¡qhqP|j tjjkræ|jrÎ|jtjjkrÎ|jtjjkrÎ| ||¡qò|D]}|  ||¡qÒqP|  ||¡qP|jr
| | ¡¡dS)zeConvert protobuf message to text format.
 
    Args:
      message: The protocol buffers message.
    NcSs|djr|djS|djS©Nr)Ú is_extensionÚnumberÚindex)ÚxrrrÚ<lambda>²óz'_Printer.PrintMessage.<locals>.<lambda>)Úkey)rprW)r?rhÚ
DESCRIPTORÚ    full_nameÚ_ANY_FULL_TYPE_NAMErfZ
ListFieldsr9ÚsortrRÚsortedÚ GetEntryClassr    ÚlabelrrMÚLABEL_REPEATEDr7Úcpp_typeÚCPPTYPE_MESSAGEÚCPPTYPE_STRINGÚ"_PrintShortRepeatedPrimitivesValuer2Ú_PrintUnknownFieldsZ UnknownFields)rrÚfieldsrQrWrpZ entry_submsgÚelementrrrr¤s8 ÿÿ   ÿ þz_Printer.PrintMessagec    CsØ|j}|D]Æ}| d|j¡| t|jƒ¡|jtkr¦|jrL| d¡n| d¡|jd7_| |j    ¡|jr‚| d¡n"|jd8_| d|jd¡q
|jt
kr¢z"t   t |j    ƒdt|j    ƒ¡\}}Wntk
rìd}YnX|t|j    ƒkrl|jr| d¡n| d¡|jd7_| |¡|jrH| d¡n"|jd8_| d|jd¡n4| d¡| t |j    d    ¡¡| |jršd
nd ¡q
| d ¡| t|j    ƒ¡| |jrÌdnd ¡q
dS)zPrint unknown fields.rbz { z {
r]z} z}
rz: "Fz" z"
z: rcN)r@r.r>rZ field_numberZ    wire_typeÚWIRETYPE_START_GROUPr6r}ÚdataÚWIRETYPE_LENGTH_DELIMITEDrZ_DecodeUnknownFieldSetÚ
memoryviewÚlenÚ    ExceptionrÚCEscape)rZunknown_fieldsr@rQZembedded_unknown_messageÚposrrrr}ËsN
 
 
   ÿ 
 
 
 
 
z_Printer._PrintUnknownFieldscCsÚ|j}| d|j¡|jr.| t|jƒ¡nŠ|jrŽ| d¡|j ¡j    rv|j
t j j krv|jt j jkrv| |jj¡n | |j¡| d¡n*|j
t j jkr¬| |jj¡n | |j¡|jsÌ|jt j jkrÖ| d¡dS)zPrint field name.rbú[ú]r`N)r@r.r>r<rrkrjÚcontaining_typerPZmessage_set_wire_formatrLrrMrNrwZLABEL_OPTIONALrOrrÚ
TYPE_GROUPÚnamer3ryrz)rrQr@rrrÚ_PrintFieldNames*
  ÿ þ    ÿz_Printer._PrintFieldNamecCs<| |¡|j d¡| ||¡|j |jr2dnd¡dS)rTrbrcN)rr@r.r
r6)rrQrWrrrr    s
  z_Printer.PrintFieldcCs~| |¡|j d¡tt|ƒdƒD] }| |||¡|j d¡q&| ||d¡|j d¡|j |jrtdnd¡dS)    z("Prints short repeated primitives value.z [éz, éÿÿÿÿr‰rbrcN)rr@r.Úranger„r
r6)rrQrWÚirrrr|&s
  z+_Printer._PrintShortRepeatedPrimitivesValuecCs–|jrd}d}nd}d}|jrF|j d|¡| |¡|j |¡nL|j d|¡|jd7_| |¡|jd8_|j d|j|¡dS)    Nú<ú>Ú{Ú}z%s z%s
r]rb)r8r6r@r.rr>)rrWZopenbZclosebrrrrd2s
 
z _Printer._PrintMessageFieldValuecCs¬|j}|jtjjkr"| |¡n†|jtjjkrh|jj     |d¡}|dk    rV| 
|j ¡n| 
t |ƒ¡n@|jtjj krØ| 
d¡t|t ƒrœ|jsœ| d¡}n|}|jtjjkr´d}n|j}| 
t ||¡¡| 
d¡nÐ|jtjjkr|rø| 
d¡n
| 
d¡n¤|jtjjkrh|jdk    r6| 
d |j|¡¡n0t |¡rR| 
t |ƒ¡n| 
t t |¡ƒ¡n@|jtjjkrš|jdk    rš| 
d |j|¡¡n| 
t |ƒ¡dS)zÝPrint a single field value (not including name).
 
    For repeated fields, the value should be a single element.
 
    Args:
      field: The descriptor of the field to be printed.
      value: The value of the field.
    NrrCFÚtrueÚfalsez{1:{0}})r@ryrrMrzrdZ CPPTYPE_ENUMÚ    enum_typeÚvalues_by_numberrGr.rŒrr{rEr-rHrLÚ
TYPE_BYTESrr†Z CPPTYPE_BOOLZ CPPTYPE_FLOATr:rÚmathÚisnanrZToShortestFloatZCPPTYPE_DOUBLEr;)rrQrWr@Ú
enum_valueZ    out_valueZ out_as_utf8rrrr
EsB    
      ÿz_Printer.PrintFieldValue) rFFFFFNNFNNFF)rrrrrrfrhrr}rr    r|rdr
rrrrr4@s0ñ
F '7 r4cCs(t| t|tƒrdnd¡|||||dS)aParses a text representation of a protocol message into a message.
 
  NOTE: for historical reasons this function does not clear the input
  message. This is different from what the binary msg.ParseFrom(...) does.
  If text contains a field already set in message, the value is appended if the
  field is repeated. Otherwise, an error is raised.
 
  Example::
 
    a = MyProto()
    a.repeated_field.append('test')
    b = MyProto()
 
    # Repeated fields are combined
    text_format.Parse(repr(a), b)
    text_format.Parse(repr(a), b) # repeated_field contains ["test", "test"]
 
    # Non-repeated fields cannot be overwritten
    a.singular_field = 1
    b.singular_field = 2
    text_format.Parse(repr(a), b) # ParseError
 
    # Binary version:
    b.ParseFromString(a.SerializeToString()) # repeated_field is now "test"
 
  Caller is responsible for clearing the message as needed.
 
  Args:
    text (str): Message text representation.
    message (Message): A protocol buffer message to merge into.
    allow_unknown_extension: if True, skip over missing extensions and keep
      parsing
    allow_field_number: if True, both field number and field name are allowed.
    descriptor_pool (DescriptorPool): Descriptor pool used to resolve Any types.
    allow_unknown_field: if True, skip over unknown field and keep
      parsing. Avoid to use this option if possible. It may hide some
      errors (e.g. spelling error on field name)
 
  Returns:
    Message: The same message passed as argument.
 
  Raises:
    ParseError: On text parsing problems.
  ó
rc©r=Úallow_unknown_field)Ú
ParseLinesÚsplitrErF©rJrÚallow_unknown_extensionÚallow_field_numberr=r rrrrxs2ûcCs(t| t|tƒrdnd¡|||||dS)a¡Parses a text representation of a protocol message into a message.
 
  Like Parse(), but allows repeated values for a non-repeated field, and uses
  the last one. This means any non-repeated, top-level fields specified in text
  replace those in the message.
 
  Args:
    text (str): Message text representation.
    message (Message): A protocol buffer message to merge into.
    allow_unknown_extension: if True, skip over missing extensions and keep
      parsing
    allow_field_number: if True, both field number and field name are allowed.
    descriptor_pool (DescriptorPool): Descriptor pool used to resolve Any types.
    allow_unknown_field: if True, skip over unknown field and keep
      parsing. Avoid to use this option if possible. It may hide some
      errors (e.g. spelling error on field name)
 
  Returns:
    Message: The same message passed as argument.
 
  Raises:
    ParseError: On text parsing problems.
  ržrcrŸ)Ú
MergeLinesr¢rErFr£rrrr ²súcCst||||d}| ||¡S)aòParses a text representation of a protocol message into a message.
 
  See Parse() for caveats.
 
  Args:
    lines: An iterable of lines of a message's text representation.
    message: A protocol buffer message to merge into.
    allow_unknown_extension: if True, skip over missing extensions and keep
      parsing
    allow_field_number: if True, both field number and field name are allowed.
    descriptor_pool: A DescriptorPool used to resolve Any types.
    allow_unknown_field: if True, skip over unknown field and keep
      parsing. Avoid to use this option if possible. It may hide some
      errors (e.g. spelling error on field name)
 
  Returns:
    The same message passed as argument.
 
  Raises:
    ParseError: On text parsing problems.
  rŸ)Ú_Parserr¡©Úlinesrr¤r¥r=r Úparserrrrr¡Øs ýr¡cCst||||d}| ||¡S)a÷Parses a text representation of a protocol message into a message.
 
  See Merge() for more details.
 
  Args:
    lines: An iterable of lines of a message's text representation.
    message: A protocol buffer message to merge into.
    allow_unknown_extension: if True, skip over missing extensions and keep
      parsing
    allow_field_number: if True, both field number and field name are allowed.
    descriptor_pool: A DescriptorPool used to resolve Any types.
    allow_unknown_field: if True, skip over unknown field and keep
      parsing. Avoid to use this option if possible. It may hide some
      errors (e.g. spelling error on field name)
 
  Returns:
    The same message passed as argument.
 
  Raises:
    ParseError: On text parsing problems.
  rŸ)r§r¦r¨rrrr¦ús ýr¦c@s^eZdZdZddd„Zdd„Zdd    „Zd
d „Zd d „Zdd„Z    dd„Z
e dd„ƒZ dd„Z dS)r§z(Text format parser for protocol message.FNcCs||_||_||_||_dSr$)r¤r¥r=r )rr¤r¥r=r rrrrsz_Parser.__init__cCsd|_| ||¡|S)zBParses a text representation of a protocol message into a message.F©Ú_allow_multiple_scalarsÚ _ParseOrMerge©rr©rrrrr¡)s z_Parser.ParseLinescCsd|_| ||¡|S)zBMerges a text representation of a protocol message into a message.Tr«r®rrrr¦/s z_Parser.MergeLinescCs0dd„|Dƒ}t|ƒ}| ¡s,| ||¡qdS)züConverts a text representation of a protocol message into a message.
 
    Args:
      lines: Lines of a message's text representation.
      message: A protocol buffer message to merge into.
 
    Raises:
      ParseError: On text parsing problems.
    css&|]}t|tƒr|n| d¡VqdS)rCN)rErÚdecode)Ú.0rrrrÚ    <genexpr>@sÿz(_Parser._ParseOrMerge.<locals>.<genexpr>N)Ú    TokenizerÚAtEndÚ _MergeField)rr©rZ    str_linesÚ    tokenizerrrrr­5s þz_Parser._ParseOrMergecCsh|j}|jtkr¾| d¡r¾| |¡\}}| d¡| d¡| d¡rLd}n| d¡d}t||jƒ}|svtd|ƒ‚| |¡s¦|     ¡r˜| 
d    |f¡‚|  ||¡qvd
}|j |||d d S| d¡rl|  ¡g}    | d ¡rî|     |  ¡¡qÔd  |    ¡}    |js| 
d|j¡‚|j |    ¡}
|
s@|jr0d }
n| 
d|    ¡‚n ||
jkr`| 
d|    |jf¡‚| d¡nÚ| ¡}    |jr¼|     ¡r¼t|    ddƒ} |j | d ¡}
|
s$|jr$|j | ¡}
nh|j |    d ¡}
|
sü|j |     ¡d ¡}
|
rü|
jtj j!krüd }
|
r$|
jtj j!kr$|
j"j#|    kr$d }
|
sF|j$sF| 
d|j|    f¡‚|
r2|j%sž|
j&rž| '|
j&j#¡} | d k    rž| |
j#krž| 
d|
j#| |
j&j#|jf¡‚|
j(tj j)krÀ| d¡|j*} n| d¡|j+} |
j,tj j-kr$| d¡r$| d¡s0| |||
ƒ| d¡rq0| d¡qøn | |||
ƒn|jsF|j$sFt.‚t/|ƒ| d¡sd| d¡d S)zþMerges a single protocol message field into a message.
 
    Args:
      tokenizer: A tokenizer to parse the field name and values.
      message: A protocol message to record the data.
 
    Raises:
      ParseError: In case of text parsing problems.
    rˆr‰r`r’r“r”r•z$Type %s not found in descriptor poolúExpected "%s".F)Útype_url_prefixÚ deterministicNÚ.z+Message type "%s" does not have extensions.zþExtension "%s" not registered. Did you import the _pb2 module which defines it? If you are trying to place the extension in the MessageSet field of another message that is in an Any or MessageSet field, that message's _pb2 module must be imported as wellz1Extension "%s" does not extend message type "%s".Tz*Message type "%s" has no field named "%s".zbField "%s" is specified along with field "%s", another member of oneof "%s" for message type "%s".ú,ú;)0rqrrrsÚ
TryConsumeÚ_ConsumeAnyTypeUrlÚConsumer\r=rr³ÚParseErrorPreviousTokenr´ZPackÚConsumeIdentifierÚappendÚjoinZ is_extendableÚ
ExtensionsZ_FindExtensionByNamer¤rŠÚConsumeIdentifierOrNumberr¥ÚisdigitÚ ParseIntegerZfields_by_numberrGZ_FindExtensionByNumberÚfields_by_nameÚlowerrLrrMr‹rOrŒr r¬Zcontaining_oneofZ
WhichOneofryrzÚ_MergeMessageFieldÚ_MergeScalarFieldrwrxÚAssertionErrorÚ_SkipFieldContents)rrµrr[r·Zpacked_type_nameZexpanded_any_end_tokenZexpanded_any_sub_messager¸rŒrQrkZ which_oneofZmergerrrrr´GsÖ
 
ÿ
 
 
 
ÿÿ
ÿþ 
 
 
ÿÿ üÿ ÿÿ  
ÿÿÿ ÿþÿ
 
ÿ    z_Parser._MergeFieldcCs|| ¡g}| d¡| | ¡¡| d¡| | ¡¡| d¡| ¡g}| d¡rh| | ¡¡qNd |¡d |¡fS)zBConsumes a google.protobuf.Any type URL and returns the type name.r¹r_)rÀr¾rÁr¼rÂ)rrµÚprefixrŒrrrr½Ós
 
 
 
 
 
z_Parser._ConsumeAnyTypeUrlc    Cszt|ƒ}| d¡rd}n| d¡d}|jtjjkrt|jrJ|j|     ¡}qì|rbt
||j ƒ  ¡ƒ}qìt
||j ƒ     ¡}nx|jr®|j s¢| |¡r¢| d|jj|jf¡‚|j|}n6|j sØ| |j ¡rØ| d|jj|j f¡‚t
||j ƒ}| ¡| |¡s | ¡r| d|f¡‚| ||¡qì|rv|jjdj}|tjjkrbt
||j ƒ|j}| |j¡n|jt
||j ƒ|j<d    S)
a"Merges a single scalar field into a message.
 
    Args:
      tokenizer: A tokenizer to parse the field value.
      message: The message of which field is a member.
      field: The descriptor of the field to be merged.
 
    Raises:
      ParseError: In case of text parsing problems.
    r’r“r”r•ú;Message type "%s" should not have multiple "%s" extensions.ú7Message type "%s" should not have multiple "%s" fields.r¶rWN)rRr¼r¾rwrrMrxrjrÃÚaddÚgetattrrŒrvr¬Ú HasExtensionr¿rqrrÚHasFieldZ SetInParentr³r´rOrÇryrzrpZCopyFromrW)    rrµrrQZ is_map_entryZ    end_tokenZ sub_messageZ value_cpptyperWrrrrÉâsR 
 
ÿ ÿÿ 
ÿ ÿÿ  
z_Parser._MergeMessageFieldcCs|j}t|dƒo|jdkS)NÚsyntaxÚproto3)rqÚhasattrrÔ)rr[rrrÚ_IsProto3Syntaxs
ÿz_Parser._IsProto3SyntaxcCs|j}d}|jtjjtjjtjjfkr0t|ƒ}nø|jtjjtjj    tjj
fkrVt |ƒ}nÒ|jtjj tjj fkrvt|ƒ}n²|jtjjtjjfkr–t|ƒ}n’|jtjjtjjfkr¶| ¡}nr|jtjjkrÎ| ¡}nZ|jtjjkræ| ¡}nB|jtjjkrþ| ¡}n*|jtjjkr| |¡}ntd|jƒ‚|jtjjkrf|j rR|j!| "|¡nt#||j$ƒ "|¡n²|j r´|j%s¨| &|¡s¨| '|¡r¨| (d|j)j*|j*f¡‚n
||j!|<ndd}|j%sê| &|¡rÞt+t#||j$ƒƒ}n | ,|j$¡}|r
| (d|j)j*|j$f¡‚nt-||j$|ƒdS)aHMerges a single scalar field into a message.
 
    Args:
      tokenizer: A tokenizer to parse the field value.
      message: A protocol message to record the data.
      field: The descriptor of the field to be merged.
 
    Raises:
      ParseError: In case of text parsing problems.
      RuntimeError: On runtime errors.
    NzUnknown field type %drÎFrÏ).r¤rLrrMZ
TYPE_INT32Z TYPE_SINT32Z TYPE_SFIXED32Ú _ConsumeInt32Z
TYPE_INT64Z TYPE_SINT64Z TYPE_SFIXED64Ú _ConsumeInt64Z TYPE_UINT32Z TYPE_FIXED32Ú_ConsumeUint32Z TYPE_UINT64Z TYPE_FIXED64Ú_ConsumeUint64Z
TYPE_FLOATZ TYPE_DOUBLEÚ ConsumeFloatZ    TYPE_BOOLÚ ConsumeBoolZ TYPE_STRINGÚ ConsumeStringršÚConsumeByteStringZ    TYPE_ENUMÚ ConsumeEnumÚ RuntimeErrorrwrxrjrÃrÁrÑrŒr¬r×rÒr¿rqrrÚboolrÓÚsetattr)rrµrrQÚ_rWZduplicate_errorrrrrÊ"sz 
þ
 
þ
 
ÿ
 
ÿ
 
ÿ
 
 
 
 ÿþ ÿÿ    ÿÿz_Parser._MergeScalarField)FFNF)rrrrrr¡r¦r­r´r½rÉÚ staticmethodr×rÊrrrrr§s ü
 
 :
r§cCs4| d¡r(| d¡s(| d¡s(t|ƒnt|ƒdS)z}Skips over contents (value or message) of a field.
 
  Args:
    tokenizer: A tokenizer to parse the field name and values.
  r`r”r’N)r¼Ú    LookingAtÚ_SkipFieldValueÚ_SkipFieldMessage©rµrrrrÌns ÿÿ
rÌcCsZ| d¡r2| ¡| d¡r&| ¡q| d¡n| ¡t|ƒ| d¡sV| d¡dS)z€Skips over a complete field (name and value/message).
 
  Args:
    tokenizer: A tokenizer to parse the field name and values.
  rˆr¹r‰rºr»N)r¼rÀr¾rÄrÌrérrrÚ
_SkipFields
 
 
 
rêcCsJ| d¡rd}n| d¡d}| d¡s<| d¡s<t|ƒq| |¡dS)zfSkips over a field message.
 
  Args:
    tokenizer: A tokenizer to parse the field name and values.
  r’r“r”r•N)r¼r¾rærê)rµÚ    delimiterrrrrè˜s
 
 
rècCsH| ¡r| ¡rqdS| ¡sDt|ƒsDt|ƒsD| ¡sDtd|jƒ‚dS)z¨Skips over a field value.
 
  Args:
    tokenizer: A tokenizer to parse the field name and values.
 
  Raises:
    ParseError: In case an invalid field value is found.
  NzInvalid field value: )ÚTryConsumeByteStringÚTryConsumeIdentifierÚ_TryConsumeInt64Ú_TryConsumeUint64ÚTryConsumeFloatrÚtokenrérrrrç«s ÿÿþrçc@sFeZdZdZe d¡Ze dej¡Ze dej¡Z    e d 
ddgdd    „e Dƒ¡¡Z e d
¡Z e d ¡ZdDd d„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd „Zd!d"„Zd#d$„Zd%d&„Zd'd(„Zd)d*„Zd+d,„Zd-d.„Zd/d0„Z d1d2„Z!d3d4„Z"d5d6„Z#d7d8„Z$d9d:„Z%d;d<„Z&d=d>„Z'd?d@„Z(dAdB„Z)dCS)Er²zÍProtocol buffer text representation tokenizer.
 
  This class handles the lower level string parsing by splitting it into
  meaningful tokens.
 
  It was directly ported from the Java protocol buffer API.
  z\s+z    (\s*#.*$)z (\s|(#.*$))+ú|z[a-zA-Z_][0-9a-zA-Z_+-]*z#([0-9+-]|(\.[0-9]))[0-9a-zA-Z_.+-]*cCsg|]}dj|d‘qS)z0{qt}[^{qt}\n\\]*((\\.)+[^{qt}\n\\]*)*({qt}|\\?$))Zqt)r)r°ÚmarkrrrÚ
<listcomp>ÐsÿzTokenizer.<listcomp>z
[^\d\W]\w*z\w+TcCsld|_d|_d|_d|_d|_t|ƒ|_d|_d|_d|_    d|_
||_ |rP|j pT|j |_| ¡| ¡dS)NrrraT)Ú    _positionrrZ _token_startrñÚiterÚ_linesÚ _current_lineÚ_previous_lineÚ_previous_columnÚ _more_linesÚ_skip_commentsÚ_WHITESPACE_OR_COMMENTÚ _WHITESPACEÚ_whitespace_patternÚ_SkipWhitespaceÚ    NextToken)rr©Z skip_commentsrrrrÙs 
 
ÿzTokenizer.__init__cCs
|j|kSr$©rñ©rrñrrrræêszTokenizer.LookingAtcCs|j S)z^Checks the end of the text was reached.
 
    Returns:
      True iff the end was reached.
    rr%rrrr³íszTokenizer.AtEndcCs^t|jƒ|jkrZzt|jƒ|_Wn"tk
rBd|_d|_YdSX|jd7_d|_qdS)NraFrŽr)r„rørÚnextr÷Ú StopIterationrûrr%rrrÚ_PopLineõszTokenizer._PopLinecCsB| ¡|j |j|j¡}|s q>t| d¡ƒ}|j|7_qdSri)rrÿÚmatchrørr„Úgroup)rrÚlengthrrrrs zTokenizer._SkipWhitespacecCs|j|kr| ¡dSdS)z‰Tries to consume a given piece of text.
 
    Args:
      token: Text to consume.
 
    Returns:
      True iff the text was consumed.
    TF)rñrrrrrr¼
s    
zTokenizer.TryConsumecCs| |¡s| d|¡‚dS)zˆConsumes a piece of text.
 
    Args:
      token: Text to consume.
 
    Raises:
      ParseError: If the text couldn't be consumed.
    r¶N)r¼rrrrrr¾s    
zTokenizer.ConsumecCs(|j}|j |¡s| d¡‚| ¡|S)NzExpected comment.)rñÚ_COMMENTrrr©rrBrrrÚConsumeComment$s
 
zTokenizer.ConsumeCommentcCs:|jdko|jdk}|j}| ¡}|j|ko0| }||fS)zCConsumes a comment, returns a 2-tuple (trailing bool, comment str).r)rrrùr )rZ just_startedZbefore_parsingÚcommentZtrailingrrrÚConsumeCommentOrTrailingComment+s
ÿz)Tokenizer.ConsumeCommentOrTrailingCommentcCs*z| ¡WdStk
r$YdSXdS©NTF)rÀrr%rrrrí;s
zTokenizer.TryConsumeIdentifiercCs(|j}|j |¡s| d¡‚| ¡|S)úConsumes protocol message field identifier.
 
    Returns:
      Identifier string.
 
    Raises:
      ParseError: If an identifier couldn't be consumed.
    zExpected identifier.)rñÚ _IDENTIFIERrrrr rrrrÀBs
     
zTokenizer.ConsumeIdentifiercCs*z| ¡WdStk
r$YdSXdSr)rÄrr%rrrÚTryConsumeIdentifierOrNumberQs
z&Tokenizer.TryConsumeIdentifierOrNumbercCs,|j}|j |¡s | d|¡‚| ¡|S)rz&Expected identifier or number, got %s.)rñÚ_IDENTIFIER_OR_NUMBERrrrr rrrrÄXs
     z#Tokenizer.ConsumeIdentifierOrNumbercCs*z| ¡WdStk
r$YdSXdSr)ÚConsumeIntegerrr%rrrÚTryConsumeIntegergs
zTokenizer.TryConsumeIntegerc
CsLzt|jƒ}Wn0tk
r>}z| t|ƒ¡‚W5d}~XYnX| ¡|S)z‹Consumes an integer number.
 
    Returns:
      The integer parsed.
 
    Raises:
      ParseError: If an integer couldn't be consumed.
    N)Ú_ParseAbstractIntegerrñÚ
ValueErrorrrr©rrBÚerrrrns      zTokenizer.ConsumeIntegercCs*z| ¡WdStk
r$YdSXdSr)rÜrr%rrrrð~s
zTokenizer.TryConsumeFloatc
CsLzt|jƒ}Wn0tk
r>}z| t|ƒ¡‚W5d}~XYnX| ¡|S)zžConsumes an floating point number.
 
    Returns:
      The number parsed.
 
    Raises:
      ParseError: If a floating point number couldn't be consumed.
    N)Ú
ParseFloatrñrrrrrrrrr܅s      zTokenizer.ConsumeFloatc
CsLzt|jƒ}Wn0tk
r>}z| t|ƒ¡‚W5d}~XYnX| ¡|S)z‹Consumes a boolean value.
 
    Returns:
      The bool parsed.
 
    Raises:
      ParseError: If a boolean value couldn't be consumed.
    N)Ú    ParseBoolrñrrrrrrrrrݕs      zTokenizer.ConsumeBoolcCs*z| ¡WdStk
r$YdSXdSr)rßrr%rrrrì¥s
zTokenizer.TryConsumeByteStringc
CsF| ¡}z t|dƒWStk
r@}z| |¡‚W5d}~XYnXdS)z‹Consumes a string value.
 
    Returns:
      The string parsed.
 
    Raises:
      ParseError: If a string value couldn't be consumed.
    rCN)rßrÚUnicodeDecodeErrorÚ_StringParseError)rZ    the_bytesrrrrrÞ¬s
     zTokenizer.ConsumeStringcCs8| ¡g}|jr.|jdtkr.| | ¡¡q
d |¡S)z Consumes a byte array value.
 
    Returns:
      The array parsed (as a string).
 
    Raises:
      ParseError: If a byte array value couldn't be consumed.
    rro)Ú_ConsumeSingleByteStringrñÚ_QUOTESrÁrÂ)rZthe_listrrrrß»s    
zTokenizer.ConsumeByteStringc
Cs®|j}t|ƒdks|dtkr.| d|f¡‚t|ƒdksJ|d|dkrZ| d|f¡‚zt |dd…¡}Wn0tk
r }z| t|ƒ¡‚W5d}~XYnX| ¡|S)aOConsume one token of a string literal.
 
    String literals (whether bytes or text) can come in multiple adjacent
    tokens which are automatically concatenated, like in C or Python.  This
    method only consumes one token.
 
    Returns:
      The token parsed.
    Raises:
      ParseError: When the wrong format data is found.
    rŽrzExpected string but found: %rr]rzString missing ending quote: %rN)    rñr„rrrZ    CUnescaperrr)rrJrBrrrrrÉs  z"Tokenizer._ConsumeSingleByteStringc
CsNzt||jƒ}Wn0tk
r@}z| t|ƒ¡‚W5d}~XYnX| ¡|Sr$)Ú    ParseEnumrñrrrr)rrQrBrrrrràãs  zTokenizer.ConsumeEnumcCst||jd|jdƒS)z¯Creates and *returns* a ParseError for the previously read token.
 
    Args:
      message: A message to set for the exception.
 
    Returns:
      A ParseError instance.
    rŽ)rrùrú©rrrrrr¿ës     ÿz!Tokenizer.ParseErrorPreviousTokencCs&td|jd||jd|jdƒS)z9Creates and *returns* a ParseError for the current token.r z': rŽ)rrørrr!rrrr÷sÿzTokenizer.ParseErrorcCs| dt|ƒ¡S)NzCouldn't parse string: )rr)rrrrrrüszTokenizer._StringParseErrorcCs’|j|_|j|_|jt|jƒ7_| ¡|js<d|_dS|j     |j
|j¡}|sj|j sj|j      |j
|j¡}|r€|  d¡}||_n|j
|j|_dS)z Reads the next meaningful token.raNr)rrùrrúr„rñrrûÚ_TOKENrrørür
r)rrrñrrrrÿs
 
zTokenizer.NextTokenN)T)*rrrrÚreÚcompilerþÚ    MULTILINEr
rýrÂrr"rrrrær³rrr¼r¾r rrírÀrrÄrrrðrÜrÝrìrÞrßrràr¿rrrrrrrr²ÁsR
þýý    
 
 
       r²cCst|dddS)úæConsumes a signed 32bit integer number from tokenizer.
 
  Args:
    tokenizer: A tokenizer used to parse the number.
 
  Returns:
    The integer parsed.
 
  Raises:
    ParseError: If a signed 32bit integer couldn't be consumed.
  TF©Ú    is_signedÚis_long©Ú_ConsumeIntegerrérrrrØs rØcCst|dddS)zìConsumes an unsigned 32bit integer number from tokenizer.
 
  Args:
    tokenizer: A tokenizer used to parse the number.
 
  Returns:
    The integer parsed.
 
  Raises:
    ParseError: If an unsigned 32bit integer couldn't be consumed.
  Fr'r*rérrrrÚ(s rÚcCs*zt|ƒWdStk
r$YdSXdSr)rÙrrérrrrî7s
rîcCst|dddS)r&Tr'r*rérrrrÙ?s rÙcCs*zt|ƒWdStk
r$YdSXdSr)rÛrrérrrrïNs
rïcCst|dddS)zìConsumes an unsigned 64bit integer number from tokenizer.
 
  Args:
    tokenizer: A tokenizer used to parse the number.
 
  Returns:
    The integer parsed.
 
  Raises:
    ParseError: If an unsigned 64bit integer couldn't be consumed.
  FTr'r*rérrrrÛVs rÛc
CsRzt|j||d}Wn0tk
rD}z| t|ƒ¡‚W5d}~XYnX| ¡|S)aUConsumes an integer number from tokenizer.
 
  Args:
    tokenizer: A tokenizer used to parse the number.
    is_signed: True if a signed integer must be parsed.
    is_long: True if a long integer must be parsed.
 
  Returns:
    The integer parsed.
 
  Raises:
    ParseError: If an integer with given characteristics couldn't be consumed.
  r'N)rÆrñrrrr)rµr(r)rBrrrrr+es  r+cCs.t|ƒ}tdt|ƒt|ƒ}| |¡|S)aParses an integer.
 
  Args:
    text: The text to parse.
    is_signed: True if a signed integer must be parsed.
    is_long: True if a long integer must be parsed.
 
  Returns:
    The integer value.
 
  Raises:
    ValueError: Thrown Iff the text is not a valid integer.
  r])rÚ_INTEGER_CHECKERSÚintZ
CheckValue)rJr(r)rBÚcheckerrrrrÆ{s
rÆcCs^|}t d|¡}|r,| d¡d| d¡}z t|dƒWStk
rXtd|ƒ‚YnXdS)zÆParses an integer without checking size/signedness.
 
  Args:
    text: The text to parse.
 
  Returns:
    The integer value.
 
  Raises:
    ValueError: Thrown Iff the text is not a valid integer.
  z (-?)0(\d+)$rŽZ0or]rzCouldn't parse integer: %sN)r#rrr-r)rJÚ    orig_textZ c_octal_matchrrrr’s   rc Cs z
t|ƒWStk
ršt |¡rJ|ddkr<tdƒYStdƒYSnLt |¡r`tdƒYSzt| d¡ƒWYStk
r”td|ƒ‚YnXYnXdS)    z°Parse a floating point number.
 
  Args:
    text: Text to parse.
 
  Returns:
    The number parsed.
 
  Raises:
    ValueError: If a floating point number couldn't be parsed.
  rú-z-infÚinfÚnanÚfzCouldn't parse float: %sN)ÚfloatrÚ_FLOAT_INFINITYrÚ
_FLOAT_NANr5©rJrrrr«s 
 
 
 rcCs$|dkr dS|dkrdStdƒ‚dS)zœParse a boolean value.
 
  Args:
    text: Text to parse.
 
  Returns:
    Boolean values parsed
 
  Raises:
    ValueError: If text is not a valid boolean.
  )r–ÚtÚ1ÚTrueT)r—r3Ú0ÚFalseFzExpected "true" or "false".N)rr7rrrrËs
rcCsœ|j}zt|dƒ}Wn<tk
rP|j |d¡}|dkrLtd|j|fƒ‚YnFXt|jdƒrn|jjdkrn|S|j     |d¡}|dkr–td|j|fƒ‚|j
S)a&Parse an enum value.
 
  The value can be specified by a number (the enum value), or by
  a string literal (the enum name).
 
  Args:
    field: Enum field descriptor.
    value: String value.
 
  Returns:
    Enum value number.
 
  Raises:
    ValueError: If the enum value could not be parsed.
  rNz%Enum type "%s" has no value named %s.rÔrÕz+Enum type "%s" has no value with number %d.) r˜r-rZvalues_by_namerGrrrÖÚfilerÔr™rk)rQrWZenum_descriptorrkrrrrr ßs$ÿ   ÿr ) FFFFFNNFNrNFF) rFFFFFNNFNNFF) rFFFFFNNNFF) rFFFFFNNNFF)FFNF)FFNF)FFNF)FFNF)FF)FF)ArÚ
__author__Zencodings.raw_unicode_escapeÚ    encodingsZencodings.unicode_escaper*r›r#Zgoogle.protobuf.internalrrrYrrÚ__all__ZUint32ValueCheckerZInt32ValueCheckerZUint64ValueCheckerZInt64ValueCheckerr,r$Ú
IGNORECASEr5r6Ú    frozensetrrsr…rrÚobjectr)rr rRrr    r
r\r‚r€r4rr r¡r¦r§rÌrêrèrçr²Z
_TokenizerrØrÚrîrÙrïrÛr+rÆrrrr rrrrÚ<module>s     ÿýò
R
ò
"ó
ó
<û
<û
(û
$û
"TW