
    q	h                        S r SrSSKrSSKrSSKrSSKrSSKrSSKJ	r	  SSKJ
r
  SSKJr  SSKJr  SSKJr  / S	Qr\
R                   " 5       \
R"                  " 5       \
R$                  " 5       \
R&                  " 5       4r\R*                  " S
\R,                  5      r\R*                  " S\R,                  5      r\R*                  " S5      r\" S5      rSrSrSr " S S\5      r  " S S\ 5      r! " S S\"5      r#\SSSSSSSSSSSS4S\$4S jjr%S\&4S jr'S r(S r)S\SSSSSSSSSSS4S jr*S\SSSSSSSSS4S jr+S\SSSSSSSSS4S jr,S  r-S!r.S"r/ " S# S$\"5      r0    S9S% jr1    S9S& jr2    S9S' jr3    S9S( jr4 " S) S*\"5      r5 " S+ S,\"5      r6\6r7S- r8S. r9S/ r:S0 r;S1 r<S2 r=S:S3 jr>S:S4 jr?S5 r@S6 rAS7 rBS8 rCg);ac  Contains 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)unknown_fields)MessageToStringParsePrintMessage
PrintFieldPrintFieldValueMergeMessageToBytesz-?inf(?:inity)?f?$znanf?$z	-?0[0-9]+)'"zgoogle.protobuf.Anyz	 Tc                       \ rS rSrSrSrg)Error5   z'Top-level module error for text_format. N)__name__
__module____qualname____firstlineno____doc____static_attributes__r       M/var/www/html/env/lib/python3.13/site-packages/google/protobuf/text_format.pyr   r   5   s    /r   r   c                   <   ^  \ rS rSrSrSU 4S jjrS rS rSrU =r	$ )
ParseError9   z3Thrown in case of text parsing or tokenizing error.c                    > Ub6  Ub3  [        U5      nUb  USR                  U5      -  nSR                  XA5      nUb  [        [        U ]  U5        O[        [        U ]  5         X l        X0l        g )Nz:{0}z	{0} : {1})strformatsuperr   __init___line_column)selfmessagelinecolumnloc	__class__s        r   r$   ParseError.__init__<   sl    t/Ic		v}}V$$""30gJ&w/J&(JLr   c                     U R                   $ N)r%   r'   s    r   GetLineParseError.GetLineI   s    ::r   c                     U R                   $ r/   )r&   r0   s    r   	GetColumnParseError.GetColumnL   s    <<r   )r&   r%   )NNN)
r   r   r   r   r   r$   r1   r4   r   __classcell__)r,   s   @r   r   r   9   s    ; r   r   c                   ,    \ rS rSrS rS rS rS rSrg)
TextWriterP   c                 8    [         R                  " 5       U l        g r/   )ioStringIO_writer)r'   as_utf8s     r   r$   TextWriter.__init__R   s    ;;=DLr   c                 8    U R                   R                  U5      $ r/   )r=   write)r'   vals     r   rA   TextWriter.writeU   s    <<c""r   c                 6    U R                   R                  5       $ r/   )r=   closer0   s    r   rE   TextWriter.closeX   s    <<r   c                 6    U R                   R                  5       $ r/   )r=   getvaluer0   s    r   rH   TextWriter.getvalue[   s    <<  ""r   )r=   N)	r   r   r   r   r$   rA   rE   rH   r   r   r   r   r8   r8   P   s    !# #r   r8   Freturnc                     [        U5      n[        UU
UUUUUUUUU	UUUS9nUR                  U 5        UR                  5       nUR	                  5         U(       a  UR                  5       $ U$ )ap  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.
  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)r8   _Printerr
   rH   rE   rstrip)r(   r>   as_one_lineuse_short_repeated_primitivespointy_bracketsuse_index_orderfloat_formatdouble_formatuse_field_numberdescriptor_poolindentmessage_formatterrL   rM   outprinterresults                    r   r   r   _   s{    n 	7#	#/' 
w<<>&))+==?	-r   c                     [        U 40 UD6n[        U[        5      (       a  U$ UR                  S5      (       a  SOSnUR	                  U5      $ )zFConvert protobuf message to encoded text format.  See MessageToString.r>   utf-8ascii)r   
isinstancebytesgetencode)r(   kwargstextcodecs       r   r   r      sG    		+F	+$eKZZ	**'%	U	r   c                     U R                   [        R                  R                  :H  =(       aA    U R                  R
                  =(       a$    U R                  R                  5       R                  $ r/   )typer   FieldDescriptorTYPE_MESSAGEmessage_typehas_options
GetOptions	map_entryfields    r   _IsMapEntryrq      sP    
**
22??
? 4



(
(4



'
'
)
3
35r   c                    U R                   [        R                  R                  :w  a  gU R                  U R
                  R                  R                  5       :w  a  gU R
                  R                  U R                  :w  a  gU R                  (       a#  U R
                  R                  U R                  :H  $ U R
                  R                  U R                  :H  $ )zDetermines if a field is consistent with a proto2 group.

Args:
  field: The field descriptor.

Returns:
  True if this field is group-like, false otherwise.
F)rh   r   ri   
TYPE_GROUPnamerk   lowerfileis_extensioncontaining_typeextension_scopero   s    r   _IsGroupLikerz      s     ZZ:--888 ZZ5%%**0022


* 
		 ((E,A,AA --1F1FFr   c                 P    [        XUUUUUUU	U
UUUUS9nUR                  U 5        g)a  Convert the message to text format and write it to the out stream.

Args:
  message: The Message object to convert to text format.
  out: A file handle to write the message to.
  indent: The initial indent level for pretty print.
  as_utf8: Return unescaped Unicode for non-ASCII characters.
  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.
rZ   rX   r>   rP   rQ   rR   rS   rT   rU   rV   rW   rY   rL   rM   N)rN   r
   )r(   rZ   rX   r>   rP   rQ   rR   rS   rT   rU   rV   rW   rY   rL   rM   r[   s                   r   r
   r
      sE    Z 
g$A%%!'%)/' 
wr   c                 F    [        X#XEXgXU
UUUS9nUR                  X5        g)%Print a single field name/value pair.rY   rL   rM   N)rN   r   rp   valuerZ   rX   r>   rP   rQ   rR   rS   rT   rU   rY   rL   rM   r[   s                  r   r   r     s3     S'2$M'8*>!,.' 
U"r   c                 F    [        X#XEXgXU
UUUS9nUR                  X5        g)z0Print a single field value (not including name).r   N)rN   r   r   s                  r   r   r   0  s3     S'2$M'8*>!,.' 
%'r   c                     Uc  SSK Jn  UR                  5       nSSK Jn   UR	                  U 5      nUR                  U5      nU" 5       $ ! [
         a     gf = f)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   )rW   )message_factory)google.protobufrW   Defaultr   FindMessageTypeByNameKeyErrorGetMessageClass)	type_namerW   pool_modr   message_descriptorrk   s         r   _BuildMessageFromTypeNamer   H  sc     ;&&(O-(>>yI !001CD,	 
 s   A
 

AA      c                   r    \ rS rSrSrS\SSSSSSSSSSS4S jrS rS rS	 r	S
 r
S rS rS rS rS rSrg)rN   ie  z)Text format printer for protocol message.r   FNc                     Xl         X l        X0l        X@l        XPl        X`l        Xpl        Xl        U	b  Xl        OXl        Xl	        Xl
        Xl        Xl        Xl        g)aO  Initialize 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.
  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.
Nr|   )r'   rZ   rX   r>   rP   rQ   rR   rS   rT   rU   rV   rW   rY   rL   rM   s                  r   r$   _Printer.__init__h  sb    d HKL")F&**$ (',*. 4"r   c                    SUR                   ;  a  g[        UR                  5       U R                  5      nUb  UR	                  UR
                  5        U R                  (       a  SOSnU R                  R                  U R                  S-  < SUR                   < SU< S35        U R                  U5        U R                  R                  U R                  (       a  SOS5        g	g)
z5Serializes if message is a google.protobuf.Any field./F:  []
T)type_urlr   TypeNamerW   MergeFromStringr   rM   rZ   rA   rX   _PrintMessageFieldValuerP   )r'   r(   packed_messagecolons       r   _TryPrintAsAnyMessage_Printer._TryPrintAsAnyMessage  s    
'""".w/?/?/A/3/C/CEN!$$W]]3%%c2e
hhnnDKK#$5w7G7GOP
"">2
hhnnD,,S$7r   c                    U R                  XR                  U R                  5      nUc  gU R                  nUR	                  SU R                  -  5        UR	                  U5        UR	                  U R                  (       a  SOS5        g)NFr   r   T)rY   rX   rP   rZ   rA   )r'   r(   	formattedrZ   s       r   _TryCustomFormatMessage _Printer._TryCustomFormatMessage  sj    &&wT=M=MNI
((CIIcDKK IIiIIT%%c40r   c                    U R                   (       a  U R                  U5      (       a  gUR                  R                  [        :X  a  U R                  U5      (       a  gUR                  5       nU R                  (       a  UR                  S S9  U GH  u  p4[        U5      (       a<  [        U5       H+  nUR                  5       " XTU   S9nU R                  X65        M-     MR  UR                  [        R                  R                   :X  a  U R"                  (       ac  UR$                  [        R                  R&                  :w  a;  UR$                  [        R                  R(                  :w  a  U R+                  X45        M  U H  nU R                  X75        M     GM  U R                  X45        GM     U R,                  (       a&  U R/                  [0        R2                  " U5      5        gg)zYConvert protobuf message to text format.

Args:
  message: The protocol buffers message.
Nc                 f    U S   R                   (       a  U S   R                  $ U S   R                  $ )Nr   )rw   numberindex)xs    r   <lambda>'_Printer.PrintMessage.<locals>.<lambda>  s(    qt'8'8!HadjjHr   )key)r   r   )rY   r   
DESCRIPTOR	full_name_ANY_FULL_TYPE_NAMEr   
ListFieldsrS   sortrq   sortedGetEntryClassr   labelr   ri   LABEL_REPEATEDrQ   cpp_typeCPPTYPE_MESSAGECPPTYPE_STRING"_PrintShortRepeatedPrimitivesValuerL   _PrintUnknownFieldsr   UnknownFieldSet)r'   r(   fieldsrp   r   r   entry_submsgelements           r   r
   _Printer.PrintMessage  sm    $">">w"G"G$$(;;""7++!FkkH  J	U		%=C ,,.3CjI,
//%
. ! ;;*44CCC..*"<"<"L"LL*"<"<"K"KK

1
1%
?gOOE+  	%' *   
~==gFG !r   c                 V   U R                   nU GH  nUR                  SU R                  -  5        UR                  [        UR                  5      5        UR
                  [        :X  a  U R                  (       a  UR                  S5        O&UR                  S5        U =R                  S-  sl        U R                  UR                  5        U R                  (       a  UR                  S5        M  U =R                  S-  sl        UR                  SU R                  -  S-   5        GM  UR
                  [        :X  Gaz   [        R                  " [        UR                  5      S[        UR                  5      5      u  pEU[        UR                  5      :X  a  U R                  (       a  UR                  S5        O&UR                  S5        U =R                  S-  sl        U R                  W5        U R                  (       a  UR                  S5        GM	  U =R                  S-  sl        UR                  SU R                  -  S-   5        GMB  UR                  S5        UR                  [         R"                  " UR                  S	5      5        UR                  U R                  (       a  S
OS5        GM  UR                  S5        UR                  [        UR                  5      5        UR                  U R                  (       a  SOS5        GM     g! [         a    Sn GNf = f)zPrint unknown fields.r   z { z {
r   z} z}
r   z: "Fz" z"
z: r   N)rZ   rA   rX   r!   field_number	wire_typeWIRETYPE_START_GROUPrP   r   dataWIRETYPE_LENGTH_DELIMITEDr   _DecodeUnknownFieldSet
memoryviewlen	Exceptionr   CEscape)r'   unknown_field_setrZ   rp   embedded_unknown_messageposs         r   r   _Printer._PrintUnknownFields  s&   
((C"	iidkk!"	iiE&&'(	0	0
))E

))F

++
+  ,
))D/
++
+
))C$++%-
.??77	 -4,J,J$aUZZ-:
)#
 #ejj/!IIeIIfKK1K

"
"#;
<IIdOKK1KIIcDKK'%/0 ))F

))M))%**e<
=
))T--E6
: 			$		#ejj/"		))#t4e #0  	#	s    A LL('L(c                    U R                   nUR                  SU R                  -  5        U R                  (       a&  UR                  [	        UR
                  5      5        GO?UR                  (       a  UR                  S5        UR                  R                  5       R                  (       av  UR                  [        R                  R                  :X  aN  UR                  [        R                  R                  :X  a&  UR                  UR                   R"                  5        OUR                  UR"                  5        UR                  S5        OQ[%        U5      (       a&  UR                  UR                   R&                  5        OUR                  UR&                  5        U R(                  (       d(  UR*                  [        R                  R,                  :w  a  UR                  S5        gg)zPrint field name.r   r   r   r   N)rZ   rA   rX   rV   r!   r   rw   rx   rm   message_set_wire_formatrh   r   ri   rj   r   LABEL_OPTIONALrk   r   rz   rt   rM   r   r   )r'   rp   rZ   s      r   _PrintFieldName_Printer._PrintFieldName%  s4   
((CIIcDKK 	iiELL!"					#!!,,.FFJJ*44AAAKK:55DDD
))E&&00
1
))EOO
$		#		%$$))*		%***44DDD 
iin	 	Er   c                     U R                  U5        U R                  R                  S5        U R                  X5        U R                  R                  U R                  (       a  S5        gS5        g)r~   r   r   N)r   rZ   rA   r   rP   )r'   rp   r   s      r   r   _Printer.PrintFieldB  sK    HHNN3&HHNN$**355r   c                    U R                  U5        U R                  R                  S5        [        [	        U5      S-
  5       H2  nU R                  XU   5        U R                  R                  S5        M4     U R                  XS   5        U R                  R                  S5        U R                  R                  U R                  (       a  S5        gS5        g)	z("Prints short repeated primitives value.z [   z, r   r   r   N)r   rZ   rA   ranger   r   rP   )r'   rp   r   is       r   r   +_Printer._PrintShortRepeatedPrimitivesValueI  s     	HHNN43u:>"
5(+
hhnnT # 	b	*HHNN3HHNN$**355r   c                    U R                   (       a  SnSnOSnSnU R                  (       aK  U R                  R                  SU-  5        U R	                  U5        U R                  R                  U5        g U R                  R                  SU-  5        U =R
                  S-  sl        U R	                  U5        U =R
                  S-  sl        U R                  R                  SU R
                  -  U-   5        g )	N<>{}z%s z%s
r   r   )rR   rP   rZ   rA   r
   rX   )r'   r   openbclosebs       r   r    _Printer._PrintMessageFieldValueU  s    efef
hhnnUU]#

hhnnV
hhnnVe^$
kkQk

kkQk
hhnnS4;;&/0r   c                    U R                   nUR                  [        R                  R                  :X  a  U R                  U5        gUR                  [        R                  R                  :X  a`  UR                  R                  R                  US5      nUb  UR                  UR                  5        gUR                  [        U5      5        gUR                  [        R                  R                  :X  a  UR                  S5        [        U[        5      (       a#  U R                  (       d  UR!                  S5      nOUnUR"                  [        R                  R$                  :X  a  SnOU R                  nUR                  [&        R(                  " XV5      5        UR                  S5        gUR                  [        R                  R*                  :X  a+  U(       a  UR                  S5        gUR                  S5        gUR                  [        R                  R,                  :X  a  U R.                  b,  UR                  SR1                  U R.                  U5      5        g[2        R4                  " U5      (       a  UR                  [        U5      5        gUR                  [        [6        R8                  " U5      5      5        gUR                  [        R                  R:                  :X  a9  U R<                  b,  UR                  SR1                  U R<                  U5      5        gUR                  [        U5      5        g)zPrint 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.
Nr   r^   Ftruefalsez{1:{0}})rZ   r   r   ri   r   r   CPPTYPE_ENUM	enum_typevalues_by_numberrb   rA   rt   r!   r   r`   r>   rc   rh   
TYPE_BYTESr   r   CPPTYPE_BOOLCPPTYPE_FLOATrT   r"   mathisnanr   ToShortestFloatCPPTYPE_DOUBLErU   )r'   rp   r   rZ   
enum_value	out_valueout_as_utf8s          r   r   _Printer.PrintFieldValueh  s"    ((C~~33CCC
""5)	:55BB	B??3377tDj				*//"		#e*	:55DD	D	iio	E3		LL)			z11<<	<ll	ii%%i=>	iio	:55BB	B			&		'	:55CC	C				&		)""4#4#4e<=::e
))CJ

))C55e<=
>
..J66EE
E



(	ii	  !3!3U;<	iiE
r   )rP   r>   rW   rU   rT   rM   rX   rY   rZ   rR   rL   rV   rS   rQ   )r   r   r   r   r   _as_utf8_defaultr$   r   r   r
   r   r   r   r   r   r   r   r   r   r   rN   rN   e  se    1
 $) B#H 	%HN55n:6
61&0r   rN   c           	      j    [        U R                  [        U [        5      (       a  SOS5      UUUUUS9$ )a  Parses 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.
   
r   rW   allow_unknown_field)
ParseLinessplitr`   ra   re   r(   allow_unknown_extensionallow_field_numberrW   r   s         r   r	   r	     s:    d 
DJJ
4(?(?uUK+&$3(;
= =r   c           	      j    [        U R                  [        U [        5      (       a  SOS5      UUUUUS9$ )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   r   r   )
MergeLinesr   r`   ra   r   s         r   r   r     s:    : 

jj*T511u=%-
/ /r   c                 <    [        UUUUS9nUR                  X5      $ )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   linesr(   r   r   rW   r   parsers          r   r   r     -    6 *%#2':<& 
		5	**r   c                 <    [        UUUUS9nUR                  X5      $ )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  s          r   r  r    r  r   c                   ~    \ rS rSrSr    SS jrS rS rS rS r	S	 r
S
 rS rS rS rS rS rS rS rS rSrg)r  i?  z(Text format parser for protocol message.Nc                 4    Xl         X l        X0l        X@l        g r/   )r   r   rW   r   )r'   r   r   rW   r   s        r   r$   _Parser.__init__B  s    
 $; 0*2r   c                 6    SU l         U R                  X5        U$ )zBParses a text representation of a protocol message into a message.F_allow_multiple_scalars_ParseOrMerger'   r  r(   s      r   r   _Parser.ParseLinesL  s    #(D u&Nr   c                 6    SU l         U R                  X5        U$ )zBMerges a text representation of a protocol message into a message.Tr  r  s      r   r  _Parser.MergeLinesR  s    #'D u&Nr   c                      S U 5       n[        U5      nU(       a  UR                  R                  U l        UR                  5       (       d)  U R                  XB5        UR                  5       (       d  M(  gg! [         a  n[        UeSnAff = f)zConverts 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.
c              3   r   #    U  H-  n[        U[        5      (       a  UOUR                  S 5      v   M/     g7f)r^   N)r`   r!   decode).0r)   s     r   	<genexpr>(_Parser._ParseOrMerge.<locals>.<genexpr>d  s1      d T3''$T[[-A
As   57N)	TokenizerUnicodeDecodeErrorr   r   r   	root_typeAtEnd_MergeField)r'   r  r(   	str_lines	tokenizeres         r   r  _Parser._ParseOrMergeX  s~    i I&i ))33dnoo
y* oo	  As   A7 7
BBBc                    UR                   nUR                  [        :X  Ga?  UR                  S5      (       Ga(  U R	                  U5      u  pEUR                  S5        UR                  S5        U R                  XR                  US-   U-   5        UR                  S5      (       a  SnOUR                  S5        Sn[        UU R                  5      nUc  [        S
U-  5      eUR                  U5      (       dT  UR                  5       (       a  UR                  SU< S35      eU R                  X5        UR                  U5      (       d  MT  SnUR                  UUUS9  g	UR                  S5      (       Ga.  UR                  5       /n	UR                  S5      (       a7  U	R                  UR                  5       5        UR                  S5      (       a  M7  SR!                  U	5      n	UR"                  (       d  UR                  SUR                  -  5      eUR$                  R'                  U	5      n
U
(       d(  U R(                  (       a  S	n
OGUR                  SU	-  5      eX:R*                  :w  a$  UR                  SU	< SUR                  < S35      eUR                  S5        GOXUR-                  5       n	U R.                  (       ar  U	R1                  5       (       a]  [3        U	SS5      nUR4                  R7                  US	5      n
U
(       d,  UR"                  (       a  UR$                  R9                  U5      n
OUR:                  R7                  U	S	5      n
U
(       df  UR:                  R7                  U	R=                  5       S	5      n
U
(       a  [?        U
5      (       d  S	n
U
(       a  U
R@                  RB                  U	:w  a  S	n
U
(       d5  U RD                  (       d$  UR                  SUR                  < SU	< S35      eU
(       Ga  U RF                  (       d  U
RH                  (       a  URK                  U
RH                  RB                  5      nUbY  XRB                  :w  aJ  UR                  SU
RB                  < SU< SU
RH                  RB                  < SUR                  < S3	5      eU
RL                  [N        RP                  RR                  :X  aD  UR                  S5        U R                  XR                  U
R                  5        U RT                  nOCUR                  S5        U R                  XR                  U
R                  5        U RV                  nU
RX                  [N        RP                  RZ                  :X  aa  UR                  S5      (       aK  UR                  S5      (       d4   U" XU
5        UR                  S5      (       a  O^UR                  S5        M3  OJU" XU
5        O@U R(                  (       d  U RD                  (       d   eU R]                  XUR                  5        UR                  S5      (       d  UR                  S5        g	g	)zMerges 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   r   Nz$Type %s not found in descriptor pool
Expected "".F)type_url_prefixdeterministic.z+Message type "%s" does not have extensions.zExtension "%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 wellzExtension "z " does not extend message type "TMessage type "z" has no field named "zField "z!" is specified along with field "z", another member of oneof "z" for message type ",;)/r   r   r   
TryConsume_ConsumeAnyTypeUrlConsume_DetectSilentMarkerr   rW   r   r  ParseErrorPreviousTokenr  PackConsumeIdentifierappendjoinis_extendable
Extensions_FindExtensionByNamer   rx   ConsumeIdentifierOrNumberr   isdigitParseIntegerfields_by_numberrb   _FindExtensionByNumberfields_by_nameru   rz   rk   rt   r   r  containing_oneof
WhichOneofr   r   ri   r   _MergeMessageField_MergeScalarFieldr   r   _SkipFieldContents)r'   r!  r(   r   r'  packed_type_nameexpanded_any_end_tokenexpanded_any_sub_messager(  rt   rp   r   which_oneofmergers                 r   r  _Parser._MergeFieldo  sn    !++$$(;;S!!*.*A*A)*L'o3
y*F*F.47GGI			c	"	"!$#!$!:;K;?;O;O"Q
 
"	)?)* + 	+$$%;<<??113I3L M M=	 $$%;<<
 mll+#2!.  0 C  ))+,d  %%I//12   %%XXd^d--//9(()* 	*   55d;e''%11E HL	LM M !6!66//%//12 	2  002d		 	 T\\^^dD$/"3377E+99$$;;FC%"1155dDA
 $3377

dK%<..Eu))..$6E433//))412 	2 ))e.D.D (()?)?)D)DE"{jj'@11 zz;(>(>(C(C!++-. . 
:55EE	ES!  ,H,H!&	2((#  ,H,H!&	2''
++33BB
B


s
#
###C((9u-##C((c"	  ) 	y5) **d.F.FGF
i/A/K/KL $$3 %r   c                     g r/   r   )r'   immediate_message_type
field_names      r   _LogSilentMarker_Parser._LogSilentMarker  s    r   c                 J    UR                   (       a  U R                  X#5        g g r/   )+contains_silent_marker_before_current_tokenrM  )r'   r!  rK  rL  s       r   r0  _Parser._DetectSilentMarker  s    <<
2? =r   c                    UR                  5       /nUR                  S5        UR                  UR                  5       5        UR                  S5        UR                  UR                  5       5        UR                  S5        UR                  5       /nUR                  S5      (       a7  UR                  UR                  5       5        UR                  S5      (       a  M7  SR	                  U5      SR	                  U5      4$ )zBConsumes a google.protobuf.Any type URL and returns the type name.r)  r   )r3  r/  r4  r-  r5  )r'   r!  prefixrt   s       r   r.  _Parser._ConsumeAnyTypeUrl  s     ))+,Fc
MM)--/0c
MM)--/0c'')*D


s
#
#
kk)--/0 

s
#
#88FSXXd^++r   c                 $   [        U5      nUR                  S5      (       a  SnOUR                  S5        SnUR                  [        R
                  R                  :X  a  UR                  (       a  UR                  U   R                  5       nGOdU(       a*  [        X#R                  5      R                  5       " 5       nGO3[        X#R                  5      R                  5       nGOUR                  (       ao  U R                  (       dN  UR                  U5      (       a8  UR                  SUR                   R"                  < SUR"                  < S35      eUR                  U   nO~U R                  (       dX  UR%                  UR                  5      (       a8  UR                  SUR                   R"                  < SUR                  < S35      e[        X#R                  5      nUR'                  5         UR                  U5      (       dT  UR)                  5       (       a  UR                  S	U< S
35      eU R+                  X5        UR                  U5      (       d  MT  U(       a  UR,                  R.                  S   R0                  nU[        R
                  R2                  :X  a>  [        X#R                  5      UR4                     nUR7                  UR8                  5        gUR8                  [        X#R                  5      UR4                  '   gg)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   r*  " should not have multiple "" extensions.	" fields.r%  r&  r   N)rq   r-  r/  r   r   ri   r   rw   r7  addgetattrrt   r   r  HasExtensionr1  r   r   HasFieldSetInParentr  r  rk   r>  r   r   r   CopyFromr   )	r'   r!  r(   rp   is_map_entry	end_tokensub_messagevalue_cpptyper   s	            r   rA  _Parser._MergeMessageField  sC    u%LC  ii{{j00???			((/335gzz2@@BDgzz2668			,,  ''11!!++U__>? ? ((/ ,,UZZ((11!!++UZZ9: : gzz2""9--			//I0OPP
y. ""9--
 ((77@IIm	*44DD	D,[__={(()8C8I8I$[__5 r   c                 <	   U R                   nSnUR                  [        R                  R                  [        R                  R
                  [        R                  R                  4;   a  [        U5      nGOVUR                  [        R                  R                  [        R                  R                  [        R                  R                  4;   a  [        U5      nGOUR                  [        R                  R                  [        R                  R                  4;   a  [        U5      nGOUR                  [        R                  R                  [        R                  R                   4;   a  [#        U5      nGOPUR                  [        R                  R$                  [        R                  R&                  4;   a  UR)                  5       nOUR                  [        R                  R*                  :X  a  UR-                  5       nOUR                  [        R                  R.                  :X  a  UR1                  5       nOUR                  [        R                  R2                  :X  a  UR5                  5       nORUR                  [        R                  R6                  :X  a  UR9                  U5      nO[;        SUR                  -  5      eUR<                  [        R                  R>                  :X  aU  UR@                  (       a  URB                  U   RE                  U5        g[G        X#RH                  5      RE                  U5        gUR@                  (       a  U RJ                  (       d_  URL                  (       aN  URO                  U5      (       a8  URQ                  SURR                  RT                  < SURT                  < S35      eXRRB                  U'   gSnU RJ                  (       d[  URL                  (       a  URW                  URH                  5      nO.[X        RZ                  " [G        X#RH                  5      5      (       + nU(       a8  URQ                  SURR                  RT                  < SURH                  < S35      e[]        X#RH                  U5        g)a(  Merges 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.
NzUnknown field type %dr*  rV  rW  FrX  )/r   rh   r   ri   
TYPE_INT32TYPE_SINT32TYPE_SFIXED32_ConsumeInt32
TYPE_INT64TYPE_SINT64TYPE_SFIXED64_ConsumeInt64TYPE_UINT32TYPE_FIXED32_ConsumeUint32TYPE_UINT64TYPE_FIXED64_ConsumeUint64
TYPE_FLOATTYPE_DOUBLEConsumeFloat	TYPE_BOOLConsumeBoolTYPE_STRINGConsumeStringr   ConsumeByteString	TYPE_ENUMConsumeEnumRuntimeErrorr   r   rw   r7  r4  rZ  rt   r  has_presencer[  r1  r   r   r\  r   IsDefaultScalarValuesetattr)r'   r!  r(   rp   _r   duplicate_errors          r   rB  _Parser._MergeScalarFieldO  sU    	$$AEzzj00;; 00<< 00>>@ @ I&e	
22=="22>>"22@@B 
B I&e	
22>>"22??A 
AY'e	
22>>"22??A 
AY'e	
22=="22>>@ 
@$$&e	z11;;	;##%e	z11==	=%%'e	z11<<	<))+e	z11;;	;##E*e05::=>>{{j00???			5!((/$++E2			,,  ''11!!++U__>? ? ',

U
#++%..uzz:O #*">">,# O 11!!++UZZ9: : '::u
-r   c                 f   UR                  S5      (       ax  UR                  S5      (       db  UR                  S5      (       dL  U R                  XU5        UR                  S5      (       a  U R                  U5        gU R	                  U5        gU R                  XU5        U R                  X5        g)a  Skips over contents (value or message) of a field.

Args:
  tokenizer: A tokenizer to parse the field name and values.
  field_name: The field name currently being parsed.
  immediate_message_type: The type of the message immediately containing
    the silent marker.
r   r   r   r   N)r-  	LookingAtr0  _SkipRepeatedFieldValue_SkipFieldValue_SkipFieldMessage)r'   r!  rL  rK  s       r   rC  _Parser._SkipFieldContents  s      ((--i6I6I#6N6N
y*M			S	!	!$$Y/Y'
y*M
Y?r   c                    SnUR                  S5      (       a  USUR                  5       -   -  nSnUR                  S5      (       a3  USUR                  5       -   -  nUS-  nUR                  S5      (       a  M3  US:X  ap  UR                  S5      (       aZ  USUR                  5       -   -  nUR                  S5      (       a.  USUR                  5       -   -  nUR                  S5      (       a  M.  UR                  S5        US-  nOX1R                  5       -  nU R	                  XU5        UR                  S5      (       d  UR                  S	5        g
g
)zSkips over a complete field (name and value/message).

Args:
  tokenizer: A tokenizer to parse the field name and values.
  immediate_message_type: The type of the message immediately containing
    the silent marker.
r   r   r   r)  r   r   r   r+  r,  N)r-  r3  r/  r9  rC  )r'   r!  rK  rL  num_identifierss        r   
_SkipField_Parser._SkipField  sK    JC  C)55777jo  %%cI77999
1   %% 
A	)"6"6s";";cI77999
""3''
i99;;
;* ""3''Cj7799jI3IJ $$3 %r   c                 T   UR                  S5      (       a  SnOUR                  S5        SnUR                  S5      (       dU  UR                  S5      (       d?  U R                  X5        UR                  S5      (       d  UR                  S5      (       d  M?  UR                  U5        g)zSkips over a field message.

Args:
  tokenizer: A tokenizer to parse the field name and values.
  immediate_message_type: The type of the message immediately containing
    the silent marker
r   r   r   r   N)r-  r/  r  r  )r'   r!  rK  	delimiters       r   r  _Parser._SkipFieldMessage  s     C  ii!!#&&y/B/B3/G/G
ooi8 !!#&&y/B/B3/G/G i r   c                     UR                  5       (       df  UR                  5       (       dP  [        U5      (       d?  [        U5      (       d.  UR	                  5       (       d  [        SUR                  -   5      eggggg)zSkips 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.
zInvalid field value: N)TryConsumeByteStringTryConsumeIdentifier_TryConsumeInt64_TryConsumeUint64TryConsumeFloatr   tokenr'   r!  s     r   r  _Parser._SkipFieldValue  su     **,,**,,Y''i((%%''.@AA ( ) ( - -r   c                    UR                  S5        UR                  S5      (       dP  U R                  U5        UR                  S5      (       a)  U R                  U5        UR                  S5      (       a  M)  UR                  S5        g)z]Skips over a repeated field value.

Args:
  tokenizer: A tokenizer to parse the field value.
r   r   r+  N)r/  r  r  r-  r  s     r   r  _Parser._SkipRepeatedFieldValue  sq     cs##
9%  %%Y'   %%cr   )r  r   r   r   rW   r  FFNF)r   r   r   r   r   r$   r   r  r  r  rM  r0  r.  rA  rB  rC  r  r  r  r  r   r   r   r   r  r  ?  sh    0 (-"'##(	3+.N `	@,8JtK.Z@4 B!&B r   r  c                   6   \ rS rSrSr\R                  " S5      r\R                  " S\R                  5      r	\R                  " S\R                  5      r
\R                  " SR                  SS/\ V Vs/ s H  nS	R                  US
9PM     snn -   5      5      r\R                  " S5      r\R                  " S5      rS*S jrS rS rS rS rS rS rS rS rS rS rS rS rS rS rS r S r!S r"S r#S  r$S! r%S" r&S# r'S$ r(S% r)S& r*S' r+S(r,g)s  snn f )+r  i  zProtocol 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_.+-]*z0{qt}[^{qt}\n\\]*((\\.)+[^{qt}\n\\]*)*({qt}|\\?$))qtz
[^\d\W]\w*z\w+c                 V   SU l         SU l        SU l        S U l        SU l        [        U5      U l        SU l        SU l        SU l	        SU l
        X l        U=(       a    U R                  =(       d    U R                  U l        SU l        U R!                  5         U R#                  5         g )Nr   r   r   TF)	_positionr%   r&   _token_startr  iter_lines_current_line_previous_line_previous_column_more_lines_skip_comments_WHITESPACE_OR_COMMENT_WHITESPACE_whitespace_patternrP  _SkipWhitespace	NextToken)r'   r  skip_commentss      r   r$   Tokenizer.__init__   s    DNDJDLDDJu+DKDDDD' - M$2M2M !4#'#3#3 	7<D4NNr   c                      U R                   U:H  $ r/   r  r'   r  s     r   r  Tokenizer.LookingAt3  s    ::r   c                 $    U R                   (       + $ )zRChecks the end of the text was reached.

Returns:
  True iff the end was reached.
r  r0   s    r   r  Tokenizer.AtEnd6  s     zz>r   c                 @   [        U R                  5      U R                  ::  a]   [        U R                  5      U l        U =R
                  S-  sl        SU l        [        U R                  5      U R                  ::  a  M\  g g ! [         a    SU l        SU l         g f = f)Nr   r   r   F)r   r  r&   nextr  r%   StopIterationr  r0   s    r   _PopLineTokenizer._PopLine>  s    
d  
!T\\
1!$++. 	

a
 d  
!T\\
1   s   B BBc                 6    U R                  5         U R                  R                  U R                  U R                  5      nU(       d  g UR                  S5      S[        -   :H  U l        [        UR                  S5      5      nU =R                  U-  sl        M  )Nr   r   )	r  r  matchr  r&   group_DEBUG_STRING_SILENT_MARKERrP  r   )r'   r  lengths      r   r  Tokenizer._SkipWhitespaceJ  sy    

mmo&&,,T-?-?Ne9>Q
+
+:-d65;;q>"f
llfl r   c                 F    U R                   U:X  a  U R                  5         gg)zuTries to consume a given piece of text.

Args:
  token: Text to consume.

Returns:
  True iff the text was consumed.
TF)r  r  r  s     r   r-  Tokenizer.TryConsumeU  s      zzU
nnr   c                 X    U R                  U5      (       d  U R                  SU-  5      eg)ztConsumes a piece of text.

Args:
  token: Text to consume.

Raises:
  ParseError: If the text couldn't be consumed.
zExpected "%s".N)r-  r   r  s     r   r/  Tokenizer.Consumec  s-     ??5!!OO,u455 "r   c                     U R                   nU R                  R                  U5      (       d  U R                  S5      eU R	                  5         U$ )NzExpected comment.)r  _COMMENTr  r   r  r'   r\   s     r   ConsumeCommentTokenizer.ConsumeCommento  s?    ZZF==v&&OO/00NNMr   c                     U R                   S:H  =(       a    U R                  S:H  nU R                  nU R                  5       nU R                  U:H  =(       a    U(       + nXC4$ )zCConsumes a comment, returns a 2-tuple (trailing bool, comment str).r   )r%   r&   r  r  )r'   just_startedbefore_parsingcommenttrailings        r   ConsumeCommentOrTrailingComment)Tokenizer.ConsumeCommentOrTrailingCommentv  sc    
 ::?8t||q'8L((N!!#G ##~5 %$$  r   c                 F     U R                  5         g! [         a     gf = fNTF)r3  r   r0   s    r   r  Tokenizer.TryConsumeIdentifier  (    
     
  c                     U R                   nU R                  R                  U5      (       d  U R                  S5      eU R	                  5         U$ )Consumes protocol message field identifier.

Returns:
  Identifier string.

Raises:
  ParseError: If an identifier couldn't be consumed.
zExpected identifier.)r  _IDENTIFIERr  r   r  r  s     r   r3  Tokenizer.ConsumeIdentifier  sC     ZZF!!&))OO233NNMr   c                 F     U R                  5         g! [         a     gf = fr  )r9  r   r0   s    r   TryConsumeIdentifierOrNumber&Tokenizer.TryConsumeIdentifierOrNumber  s(    
$$& r  c                     U R                   nU R                  R                  U5      (       d  U R                  SU-  5      eU R	                  5         U$ )r  z&Expected identifier or number, got %s.)r  _IDENTIFIER_OR_NUMBERr  r   r  r  s     r   r9  #Tokenizer.ConsumeIdentifierOrNumber  sH     ZZF%%++F33OODvMNNNNMr   c                 F     U R                  5         g! [         a     gf = fr  )ConsumeIntegerr   r0   s    r   TryConsumeIntegerTokenizer.TryConsumeInteger  s(    
 r  c                      [        U R                  5      nU R                  5         U$ ! [         a  nU R                  [	        U5      5      eSnAff = f)zwConsumes an integer number.

Returns:
  The integer parsed.

Raises:
  ParseError: If an integer couldn't be consumed.
N)_ParseAbstractIntegerr  
ValueErrorr   r!   r  r'   r\   r"  s      r   r  Tokenizer.ConsumeInteger  sK    $$TZZ0f 	NNM  $OOCF##$   ) 
AAAc                 F     U R                  5         g! [         a     gf = fr  )ru  r   r0   s    r   r  Tokenizer.TryConsumeFloat  s(    
 r  c                      [        U R                  5      nU R                  5         U$ ! [         a  nU R                  [	        U5      5      eSnAff = f)zConsumes an floating point number.

Returns:
  The number parsed.

Raises:
  ParseError: If a floating point number couldn't be consumed.
N)
ParseFloatr  r  r   r!   r  r  s      r   ru  Tokenizer.ConsumeFloat  sK    $$**%f 	NNM  $OOCF##$r  c                      [        U R                  5      nU R                  5         U$ ! [         a  nU R                  [	        U5      5      eSnAff = f)zwConsumes a boolean value.

Returns:
  The bool parsed.

Raises:
  ParseError: If a boolean value couldn't be consumed.
N)	ParseBoolr  r  r   r!   r  r  s      r   rw  Tokenizer.ConsumeBool  sK    $$f 	NNM  $OOCF##$r  c                 F     U R                  5         g! [         a     gf = fr  )rz  r   r0   s    r   r  Tokenizer.TryConsumeByteString  r  r  c                     U R                  5       n [        US5      $ ! [         a  nU R                  U5      eSnAff = f)zwConsumes a string value.

Returns:
  The string parsed.

Raises:
  ParseError: If a string value couldn't be consumed.
r^   N)rz  r!   r  _StringParseError)r'   	the_bytesr"  s      r   ry  Tokenizer.ConsumeString  sE     &&(I&G$$ &""1%%&s    
>9>c                 (   U R                  5       /nU R                  (       a`  U R                  S   [        ;   aI  UR                  U R                  5       5        U R                  (       a  U R                  S   [        ;   a  MI  SR	                  U5      $ )zConsumes a byte array value.

Returns:
  The array parsed (as a string).

Raises:
  ParseError: If a byte array value couldn't be consumed.
r   r   )_ConsumeSingleByteStringr  _QUOTESr4  r5  )r'   the_lists     r   rz  Tokenizer.ConsumeByteString  sg     --/0H
**A'1ood3356 **A'188Hr   c                    U R                   n[        U5      S:  d  US   [        ;  a  U R                  SU< 35      e[        U5      S:  d  US   US   :w  a  U R                  SU< 35      e [        R
                  " USS 5      nU R                  5         U$ ! [         a  nU R                  [        U5      5      eSnAff = f)a/  Consume 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   r   zExpected string but found: r   r   zString missing ending quote: N)	r  r   r  r   r   	CUnescaper  r!   r  )r'   re   r\   r"  s       r   r  "Tokenizer._ConsumeSingleByteString  s     ::D
4y1}Qw.OOtEFF
4y1}RDG+OOGHH$&&tAbz2f 	NNM  $OOCF##$s   /B 
C$B>>Cc                      [        XR                  5      nU R                  5         U$ ! [         a  nU R                  [	        U5      5      eS nAff = fr/   )	ParseEnumr  r  r   r!   r  )r'   rp   r\   r"  s       r   r|  Tokenizer.ConsumeEnum.  sK    $

+f 	NNM  $OOCF##$r  c                 N    [        XR                  S-   U R                  S-   5      $ )zCreates and *returns* a ParseError for the previously read token.

Args:
  message: A message to set for the exception.

Returns:
  A ParseError instance.
r   )r   r  r  r'   r(   s     r   r1  !Tokenizer.ParseErrorPreviousToken6  s,     g22Q6++a/1 1r   c                 v    [        SU R                  -   S-   U-   U R                  S-   U R                  S-   5      $ )z9Creates and *returns* a ParseError for the current token.r   z': r   )r   r  r%   r&   r  s     r   r   Tokenizer.ParseErrorB  s<    dT///&87Bjj1ndllQ&68 8r   c                 <    U R                  S[        U5      -   5      $ )NzCouldn't parse string: )r   r!   )r'   r"  s     r   r  Tokenizer._StringParseErrorG  s    ??5A>??r   c                 b   U R                   U l        U R                  U l        SU l        U =R                  [        U R                  5      -  sl        U R                  5         U R                  (       d  SU l        gU R                  R                  U R                  U R                  5      nU(       dA  U R                  (       d0  U R                  R                  U R                  U R                  5      nU(       a  UR                  S5      nX l        gU R                  U R                     U l        g)z Reads the next meaningful token.Fr   Nr   )r%   r  r&   r  rP  r   r  r  r  _TOKENr  r  r  r  r  )r'   r  r  s      r   r  Tokenizer.NextTokenJ  s    **D LLD7<D4LLC

O#LdjKKd00$,,?E,,mm!!$"4"4dllCekk!nej%%dll3djr   )r&   r  r%   r  r  r  r  r  r  r  r  rP  r  N)T)-r   r   r   r   r   recompiler  	MULTILINEr  r  r5  r  r"   r  r  r  r$   r  r  r  r  r-  r/  r  r  r  r3  r  r9  r  r  r  ru  rw  r  ry  rz  r  r|  r1  r   r  r  r   )r  marks   00r   r  r    sC    

6"+ZZbll3(::or||D::chh!,   $ :@@D@I   & 

=)+**V,&
	
6    &4
18
@4g	s   4Dr  c                     [        U SSS9$ )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_ConsumeIntegerr!  s    r   rh  rh  e  s     
dE	BBr   c                     [        U SSS9$ )zConsumes 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  s    r   ro  ro  t  s     
eU	CCr   c                 <     [        U 5        g! [         a     gf = fr  )rl  r   r  s    r   r  r    s$    )	     
c                     [        U SSS9$ )r  Tr  r  r  s    r   rl  rl    s     
dD	AAr   c                 <     [        U 5        g! [         a     gf = fr  )rr  r   r  s    r   r  r    s$    9	 r  c                     [        U SSS9$ )zConsumes 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  s    r   rr  rr    s     
eT	BBr   c                      [        U R                  XS9nU R                  5         U$ ! [         a  nU R                  [	        U5      5      eSnAff = f)aC  Consumes 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  r  r   r!   r  )r!  r  r  r\   r"  s        r   r  r    sQ    ')//YPF 	- 
 '


s1v
&&'s   ( 
AAAc                     [        U 5      n[        S[        U5      -  [        U5      -      nUR                  U5        U$ )zParses 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int
CheckValue)re   r  r  r\   checkers        r   r;  r;    s?     !&& a#g,.Y?@'	V	-r   c                     U n[         R                  " SU 5      nU(       a&  UR                  S5      S-   UR                  S5      -   n  [        U S5      $ ! [         a    [	        SU-  5      ef = f)zParses 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   0or   r   zCouldn't parse integer: %s)r  r  r  r#  r  )re   	orig_textc_octal_matchs      r   r  r    sw     )((>40- q!D(=+>+>q+AAD@tQ<	 @
2Y>
??@s   A A-c                    [         R                  U 5      (       a  [        SU -  5      e [        U 5      $ ! [         a    [        R                  U 5      (       a#  U S   S:X  a  [        S5      s $ [        S5      s $ [
        R                  U 5      (       a  [        S5      s $  [        U R                  S5      5      s $ ! [         a    [        SU -  5      ef = ff = f)	zParse a floating point number.

Args:
  text: Text to parse.

Returns:
  The number parsed.

Raises:
  ValueError: If a floating point number couldn't be parsed.
zInvalid octal float: %sr   -z-infinfnanfFzCouldn't parse float: %s)_FLOAT_OCTAL_PREFIXr  r  float_FLOAT_INFINITY
_FLOAT_NANrO   re   s    r   r  r    s     t$$
.5
66<;	 <T""	aCV}U|			$		5\<T[[&'' <3d:;;<<s-   
5 8C/C<%C$C =C CCc                 4    U S;   a  gU S;   a  g[        S5      e)zParse 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   f0FalseFzExpected "true" or "false".)r  r3  s    r   r  r    s(     
''++
2
33r   c                    U R                   n [        US5      nU R                   R                  (       d  U$ UR                  R	                  US5      nUc  [        SUR                  U4-  5      e UR                  $ ! [
         aK    UR                  R	                  US5      nUc  [        SUR                  < SU< S35      e UR                  $ f = f)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.
r   Nz+Enum type "%s" has no value with number %d.zEnum type "z" has no value named r)  )	r   r#  	is_closedr   rb   r  r   values_by_namer   )rp   r   enum_descriptorr   r   s        r   r  r  -  s      OO/<]F ??$$m 1155fdCJD'116:; < <  
		 
 ; //33E4@J'115: ; ;  
		;s   A= =ACCr  )FF)Dr   
__author__encodings.raw_unicode_escape	encodingsencodings.unicode_escaper;   r   r  google.protobuf.internalr   r   r   r   r   r   __all__Uint32ValueCheckerInt32ValueCheckerUint64ValueCheckerInt64ValueCheckerr"  r  
IGNORECASEr1  r2  r/  	frozensetr  r   r  r   r   r   r   objectr8   r!   r   ra   r   rq   rz   r
   r   r   r   r   r   rN   r	   r   r   r  r  r  
_Tokenizerrh  ro  r  rl  r  rr  r  r;  r  r  r  r  r   r   r   <module>rM     s  
 0
 $  	  	 , 2 & ) *9 #557"446"557"4468  **12==AZZ"--0
jj- 
J
+ #  0I 0 .# #" "'L L^ 5@ )"/4!&!&"#"'!%#'&+": @ ' -2$$ !!%$) #6 , %27$)$)!%"&&*). %(02   sv sp	 #("#7=x #("##/P (-"'##(+H (-"'##(+DFf FRV4 V4t
 
CDBC,.@2<D4( r   