hf BdZdZddlZddlZddlZddlZddlZddlm Z ddlm Z ddl m Z ddl m Z ddl mZgd Ze je je je jfZejd ejZejd ejZed Zd ZdZGddeZGddeZGdde Z! d6de"fdZ#de$fdZ%dZ& d7dZ' d8dZ( d8dZ)dZ*dZ+dZ,Gd d!e Z- d9d"Z. d9d#Z/ d9d$Z0 d9d%Z1Gd&d'e Z2Gd(d)e Z3e3Z4d*Z5d+Z6d,Z7d-Z8d.Z9d/Z:d:d0Z;d:d1Zd4Z?d5Z@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)unknown_fields)MessageToStringParse PrintMessage PrintFieldPrintFieldValueMergeMessageToBytesz-?inf(?:inity)?f?$znanf?$)'"zgoogle.protobuf.Anyz ceZdZdZdS)Errorz'Top-level module error for text_format.N)__name__ __module__ __qualname____doc__}/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib64/python3.11/site-packages/google/protobuf/text_format.pyrrIs////rrc0eZdZdZdfd ZdZdZxZS) ParseErrorz3Thrown in case of text parsing or tokenizing error.NcN|A|?t|}||d|z }d||}|)tt||n'tt|||_||_dS)Nz:{0}z {0} : {1})strformatsuperr__init___line_column)selfmessagelinecolumnloc __class__s rr zParseError.__init__Pst/ IIc   v}}V$$$""300g J&&w//// J&&(((DJDLLLrc|jSN)r!r#s rGetLinezParseError.GetLine]s :rc|jSr*)r"r+s r GetColumnzParseError.GetColumn`s <r)NNN)rrrrr r,r. __classcell__)r(s@rrrMsa;;      rrc&eZdZdZdZdZdZdS) TextWriterc6tj|_dSr*)ioStringIO_writer)r#as_utf8s rr zTextWriter.__init__fs;==DLLLrc6|j|Sr*)r5write)r#vals rr8zTextWriter.writeis <  c " ""rc4|jSr*)r5closer+s rr;zTextWriter.closels <    rc4|jSr*)r5getvaluer+s rr=zTextWriter.getvalueos < " ""rN)rrrr r8r;r=rrrr1r1dsP!!!###   #####rr1Freturnct|}t|| ||||||||| | | | }|||}||r|S|S)aConvert 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)r1_Printerr r=r;rstrip)r$r6 as_one_lineuse_short_repeated_primitivespointy_bracketsuse_index_order float_format double_formatuse_field_numberdescriptor_poolindentmessage_formatterr@rAoutprinterresults rrrssn 7#    #/   ' w <<>>&))+++ ==?? -rc t|fi|}t|tr|S|drdnd}||S)zFConvert protobuf message to encoded text format. See MessageToString.r6utf-8ascii)r isinstancebytesgetencode)r$kwargstextcodecs rrrsZ  + +F + +$e KZZ ** 7''% U  rc|jtjjko)|jjo|jjSr*)typerFieldDescriptor TYPE_MESSAGE message_type has_options GetOptions map_entry)fields r _IsMapEntryrds? * 2? ? 4   ( 4   ' ' ) ) 35rcjt||||||||| | | | | |}||dS)aConvert 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. rNrLr6rDrErFrGrHrIrJrKrMr@rAN)rBr )r$rNrLr6rDrErFrGrHrIrJrKrMr@rArOs rr r s]Z  fg$A%%!'%)/   ' wrcht|||||||| | | | |  }|||dS)%Print a single field name/value pair.rMr@rAN)rBr rcvaluerNrLr6rDrErFrGrHrIrMr@rArOs rr r sS S&';2O$lM'8*>!,  . . .'  UE"""""rcht|||||||| | | | |  }|||dS)z0Print a single field value (not including name).riN)rBr rjs rr r &sS S&';2O$lM'8*>!,  . . .'  %'''''rc|ddlm}|}ddlm} ||}n#t $rYdSwxYw||}|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)rK)message_factory)google.protobufrKDefaultrnFindMessageTypeByNameKeyErrorGetMessageClass) type_namerKpool_modrnmessage_descriptorr_s r_BuildMessageFromTypeNamerw>s;;;;;;&&((O------(>>yII  44 001CDD, s: AAcjeZdZdZ ddZdZdZdZd Zd Z d Z d Z d Z dZ dS)rBz)Text format printer for protocol message.rFNc||_||_||_||_||_||_||_||_| | |_n||_| |_ | |_ | |_ | |_ ||_ dS)aInitialize 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. Nrf)r#rNrLr6rDrErFrGrHrIrJrKrMr@rAs rr z_Printer.__init__^sdDHDKDL"D)FD&*D*D$D (d'd,D*D.D 4D"Drcd|jvrdSt||j}|r||j|jrdnd}|j|j dzd|jd|d| ||j|j rdndd SdS) z5Serializes if message is a google.protobuf.Any field./F: [] T) type_urlrwTypeNamerKMergeFromStringrkrArNr8rL_PrintMessageFieldValuerD)r#r$packed_messagecolons r_TryPrintAsAnyMessagez_Printer._TryPrintAsAnyMessages '""" U.w/?/?/A/A/3/CEEN$$W]333%-cc2e hnnDK#$5$5$5w7G7G7GOPPP "">222 hnnD,6SS$777 T Urc|||j|j}|dS|j}|d|jz||||jrdnddS)NFrrT)rMrLrDrNr8)r#r$ formattedrNs r_TryCustomFormatMessagez _Printer._TryCustomFormatMessages~&&w T=MNNI U (CIIcDK   IIiIIT%/cc4000 4rch|jr||rdS|jjtkr||rdS|}|jr|d|D]\}}t|rNt|D]=}| |||}| ||>c|j tjjkrn|jrK|jtjjkr1|jtjjkr||||D]}| ||| |||jr)|t1j|dSdS)zeConvert protobuf message to text format. Args: message: The protocol buffers message. NcP|djr |djn |djS)Nr) is_extensionnumberindex)xs rz'_Printer.PrintMessage..s"qt'8H! adjr)key)rrk)rMr DESCRIPTOR full_name_ANY_FULL_TYPE_NAMEr ListFieldsrGsortrdsorted GetEntryClassr labelrr]LABEL_REPEATEDrEcpp_typeCPPTYPE_MESSAGECPPTYPE_STRING"_PrintShortRepeatedPrimitivesValuer@_PrintUnknownFieldsrUnknownFieldSet)r#r$fieldsrcrkr entry_submsgelements rr z_Printer.PrintMessages   $">">w"G"G  f$(;;; ""7++ < f    ! !F J kkHHJJJ&& u U  &%== / /C /,,..3eCjIII, //% . . . . / ;*4C C C  . ,*"<"LLL*"<"KKK  1 1% ? ? ? ? , ,g OOE7 + + + + , u%%%%  H ~=gFFGGGGGHHrc|j}|D]}|d|jz|t|j|jt kr|jr|dn%|d|xjdz c_||j |jr|d|xjdzc_|d|jzdz|jtkrr tj t|j dt|j \}}n#t$rd}YnwxYw|t|j kr|jr|dn%|d|xjdz c_|||jr|d|xjdzc_|d|jzdz#|d|t!j|j d ||jrd nd |d |t|j ||jrdnd dS)zPrint unknown fields.rz { z { rxz} z} rz: "Fz" z" z: rN)rNr8rLr field_number wire_typeWIRETYPE_START_GROUPrDrdataWIRETYPE_LENGTH_DELIMITEDr_DecodeUnknownFieldSet memoryviewlen ExceptionrCEscape)r#unknown_field_setrNrcembedded_unknown_messageposs rrz_Printer._PrintUnknownFieldss (C"2525 iidk!""" iiE&''((( 0 0 0    ))E     ))F    ++ ++   ,,,   / ))D//// ++ ++ ))C$+%- . . . . ?7 7 7 -4,J$$aUZ-:-: ) #SS   ###  #ej// ! !    IIe     IIf    KK1 KK  " "#; < < <   1 IIdOOOO KK1 KK IIcDK'%/ 0 0 0 0 ))F    ))M)%*e<< = = = ))T-9EE6 : : : : $ #ej//""" )3##t4444e2525s=E E+*E+cB|j}|d|jz|jr)|t |jn|jr|d|jj rT|j tj j kr:|jtj jkr ||jjn||j|dnT|j tj jkr ||jjn||j|js|jtj jkr|ddSdS)zPrint field name.rrrr~N)rNr8rLrJrrrcontaining_typeramessage_set_wire_formatr\rr]r^rLABEL_OPTIONALr_r TYPE_GROUPnamerArr)r#rcrNs r_PrintFieldNamez_Printer._PrintFieldNamesd (CIIcDK     iiEL!!""""    #  ! , , . . F % J*4A A A K:5D D D ))E&0 1 1 1 1 ))EO $ $ $ # :3> > > %$)**** %*  *4DDD iinnnnn EDrc|||jd||||j|jrdnddS)rhrrN)rrNr8r rD)r#rcrks rr z_Printer.PrintField8sfHNN3&&&HNN$*43355555rc|||jdtt |dz D]8}|||||jd9|||d|jd|j|jrdnddS) z("Prints short repeated primitives value.z [z, rrrN)rrNr8rangerr rD)r#rcrkis rrz+_Printer._PrintShortRepeatedPrimitivesValue?s HNN4 3u::> " " 5%(+++ hnnTb ***HNN3HNN$*43355555rc|jrd}d}nd}d}|jrN|jd|z|||j|dS|jd|z|xjdz c_|||xjdzc_|jd|jz|zdS) N<>{}z%s z%s rxr)rFrDrNr8r rL)r#rkopenbclosebs rrz _Printer._PrintMessageFieldValueKs effef  1 hnnUU]###  hnnV hnnVe^$$$ kkQkk  kkQkk hnnS4;&/00000rc|j}|jtjjkr||dS|jtjjkrb|jj |d}|| |j dS| t|dS|jtjj kr| dt|tr|js|d}n|}|jtjjkrd}n|j}| t'j||| ddS|jtjjkr0|r| ddS| ddS|jtjjkr|j0| d|j|dSt3j|r$| t|dS| tt7j|dS|jtjjkr7|j0| d|j|dS| t|dS)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. NrrRFtruefalsez{1:{0}})rNrrr]rr CPPTYPE_ENUM enum_typevalues_by_numberrVr8rrrrTr6rWr\ TYPE_BYTESrr CPPTYPE_BOOL CPPTYPE_FLOATrHrmathisnanrToShortestFloatCPPTYPE_DOUBLErI)r#rcrkrN enum_value out_value out_as_utf8s rr z_Printer.PrintFieldValue^s (C ~3CCC ""5))))) :5B B B?377tDDj   */""""" #e** :5D D D iiooo E3   LL))  z1< < < l  ii %i==>>> iiooooo :5B B B  & ' :5C C C  & )""4#4e<<===== :e   ? ))CJJ      ))C 5e<<== > > > > > .J6E E E   ( ii   !3U;;<<<<< iiE r rFFFFFNNFNNFF)rrrrr rrr rrr rrr rrrrBrB[s11 $) B#B#B#B#H   %H%H%HN555555n:666 6 6 6111&00000rrBct|t|trdnd|||||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.  rrKallow_unknown_field) ParseLinessplitrTrUrYr$allow_unknown_extensionallow_field_numberrKrs rr r sLd DJJ 4(?(?JuuUKK+&$3(;  = = ==rct|t|trdnd|||||S)aParses 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. rrr) MergeLinesrrTrUrs rr r sL:  jj*T511<u== %-  / / //rcTt||||}|||S)aParses 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)_Parserrlinesr$rrrKrparsers rrr<6 *%#2': < < <&   5' * **rcTt||||}|||S)aParses 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)rrrs rrrrrcveZdZdZ ddZdZdZdZdZd Z d Z d Z d Z d Z dZdZdZdZdZdS)rz(Text format parser for protocol message.FNc>||_||_||_||_dSr*)rrrKr)r#rrrKrs rr z_Parser.__init__8s* $;D 0D*D2Drc@d|_||||S)zBParses a text representation of a protocol message into a message.F_allow_multiple_scalars _ParseOrMerger#rr$s rrz_Parser.ParseLinesBs%#(D ug&&& Nrc@d|_||||S)zBMerges a text representation of a protocol message into a message.Trrs rrz_Parser.MergeLinesHs%#'D ug&&& Nrc d|D}t|}n#t$r }t|d}~wwxYw|r|jj|_|s,||||*dSdS)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. c3nK|]0}t|tr|n|dV1dS)rRN)rTrdecode).0r%s r z(_Parser._ParseOrMerge..ZsUT3'' A$$T[[-A-ArN) TokenizerUnicodeDecodeErrorrrr root_typeAtEnd _MergeField)r#rr$ str_lines tokenizeres rrz_Parser._ParseOrMergeNsiI&&ii  A4)3dnoo+ y'***oo+++++s 505c  |j}|jtkr[|drE||\}}|d|d|||j|dz|z|drd}n|dd}t||j}|td |z||sX| r| d |d | ||||Xd }| |||d S|dr |g} |dr<| ||d|d|||j| j|j+} n=|d|||j| j|j,} | j-t@j!j.kre|drP|ds: | ||| |drn|d9n:| ||| n,|js |j%sJ|/|| |j|ds|dd Sd S)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. rrr~r}rrrrNz$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 "TMessage type "z" has no field named "zField "z!" is specified along with field "z", another member of oneof "z" for message type ",;)0rrr TryConsume_ConsumeAnyTypeUrlConsume_DetectSilentMarkerrwrKrrParseErrorPreviousTokenrPackConsumeIdentifierappendjoin is_extendable Extensions_FindExtensionByNamerrConsumeIdentifierOrNumberrisdigit ParseIntegerfields_by_numberrV_FindExtensionByNumberfields_by_namelowerr\rr]rr_rrrcontaining_oneof WhichOneofrr_MergeMessageField_MergeScalarFieldrr_SkipFieldContents)r#rr$rvrpacked_type_nameexpanded_any_end_tokenexpanded_any_sub_messagerrrcr which_oneofmergers rrz_Parser._MergeFieldes!+$(;;;S!! <*.*A*A)*L*L'o'3 y*<*F.47GGIII   c " "%!$#!$!:;K;?;O"Q"Q " )?)*++ +$$%;<<> ??   M1113I3I3I3LMM M $<=== $$%;<<> m ll+#2!.000 fC  72))++ ,d   % %3 I//11222   % %3 XXd^^d  -*// 9  ( )** * 55d;;e  2  ' M%%11EHL LMM M !6 6 6/// TT%/// 122 2 0 0 2 2d T\\^^dD$//"377EE D+9 D$;;FCC%"155dDAA  $377 dKK%  uzZ%?%JJJE  ejJ$>$III   #t + +% 2432///  ) ) )444 122 2 'M  ) .e.D .(()?)DEE  "{ej'@'@111zzz;;;(>(C(C(C!+++-.. . :5E E ES!!!   ,>,H!& 2 2 2(#   ,>,H!& 2 2 2' +3B B B   s # # C##C(( # # F9gu - - -##C((    c " " "  # y'5))))*Gd.FGGF i/A/KLLL    $ $ 3  rcdSr*r)r#immediate_message_type field_names r_LogSilentMarkerz_Parser._LogSilentMarkersDrcD|jr|||dSdSr*)+contains_silent_marker_before_current_tokenr+)r#rr)r*s rrz_Parser._DetectSilentMarkers7<@ 2J?????@@rcf|g}|d|||d|||d|g}|dr<|||d?? ?(/ , :   UZ ( ( :111!+++UZZZ9:: :guz22 ""9--/   Q///III0OPPP y+...""9--/ J(7@Im *4D D D,,[_= {()))))8C8I$$[_555 JJrc|j}d}|jtjjtjjtjjfvrt|}n|jtjjtjj tjj fvrt|}n|jtjj tjj fvrt|}nL|jtjjtjjfvrt#|}n|jtjjtjjfvr|}n|jtjjkr|}n|jtjjkr|}nv|jtjjkr|}nG|jtjjkr||}nt;d|jz|jtjjkrS|j r"|j!|"|dStG||j$"|dS|j rZ|j%sG|j&r@|'|r+|(d|j)j*d|j*d||j!|<dSd}|j%sD|j&r|+|j$}n"tYtG||j$}|r+|(d|j)j*d|j$dt[||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 %drr1r2Fr3).rr\rr] 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 ConsumeStringrConsumeByteString TYPE_ENUM ConsumeEnum RuntimeErrorrrrrrr5rr has_presencer6rrrr7boolsetattr)r#rr$rc_rkduplicate_errors rr!z_Parser._MergeScalarFieldGs $A E zj0; 0< 0>@@@I&&ee  2="2>"2@B B BI&&ee  2>"2?A A AY''ee  2>"2?A A AY''ee  2="2>@ @ @$$&&ee z1; ; ;##%%ee z1= = =%%''ee z1< < <))++ee z1; ; ;##E**ee 05:= > >> {j0???  35!((/////$$++E22222  ., ,   ,   ' ' ,111!+++U___>?? ?',' U # # #+ A   A%..uz::OO#77EJ#?#?@@O  .111!+++UZZZ9:: : '5:u - - - - -rc|dr|dso|dsZ|||||dr||dS||dS|||||||dS)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~rrrN)r  LookingAtr_SkipRepeatedFieldValue_SkipFieldValue_SkipFieldMessage)r#rr*r)s rr"z_Parser._SkipFieldContentss   @((-- @6?6I6I#6N6N @ y*@*MMM   S ! !( $$Y///// Y''''' y*@*MMM Y(>?????rcd}|dr|d|zz }d}|dr4|d|zz }|dz }|d4|dkrs|dr^|d|zz }|dr/|d|zz }|d/|d|dz }n||z }|||||ds|d d Sd S) 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. rrrrryr}rr r N)r rr rr")r#rr)r*num_identifierss r _SkipFieldz_Parser._SkipFieldsJC  :C)557777jo   % %cI779999 1   % % A  )"6"6s";"; cI779999 ""3'' < i99;;; ;*""3'' <CjjI77999jIz3IJJJ    $ $ 3  rcb|drd}n|dd}|dsU|ds@||||ds|d@||dS)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 rrrrN)r r r^rd)r#rr) delimiters rraz_Parser._SkipFieldMessagesC  iii!!#&&9y/B/B3/G/G9 ooi!7888!!#&&9y/B/B3/G/G9i     rc|s]|sKt|s>t|s1|st d|jzdSdSdSdSdS)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. zInvalid field value: N)TryConsumeByteStringTryConsumeIdentifier_TryConsumeInt64_TryConsumeUint64TryConsumeFloatrtokenr#rs rr`z_Parser._SkipFieldValues  * * , ,B  * * , ,B Y ' 'B i ( (B  % % ' ' B .@ A AA BBBBBBBBBBrc,|d|dsT|||dr*|||d*|ddS)ziSkips over a repeated field value. Args: tokenizer: A tokenizer to parse the field value. rrr N)r r^r`r rns rr_z_Parser._SkipRepeatedFieldValues c   s # #( 9%%%   % %( Y'''   % %( crFFNF)rrrrr rrrrr+rr r r!r"rdrar`r_rrrrr5s$00(-"'##( 3333  +++.P P P d   @@@ , , ,8J8J8JtI.I.I.V@@@4   B!!!&BBB     rrceZdZdZejdZejdejZejdejZ ejd ddgde DzZ ejd Z ejd Zd(d Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!dZ"d Z#d!Z$d"Z%d#Z&d$Z'd%Z(d&Z)d'S))rzProtocol 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_.+-]*c:g|]}d|S)z0{qt}[^{qt}\n\\]*((\\.)+[^{qt}\n\\]*)*({qt}|\\?$))qt)r)rmarks r zTokenizer. s; :@@D@IIrz [^\d\W]\w*z\w+TcBd|_d|_d|_d|_d|_t ||_d|_d|_d|_ d|_ ||_ |r|j p|j |_d|_||dS)NrrrTF) _positionr!r" _token_startrmiter_lines _current_line_previous_line_previous_column _more_lines_skip_comments_WHITESPACE_OR_COMMENT _WHITESPACE_whitespace_patternr-_SkipWhitespace NextToken)r#r skip_commentss rr zTokenizer.__init__sDNDJDLDDJu++DKDDDD'D - M$2M!4#'#3 7rc t|j|jkrp t|j|_|xjdz c_d|_n#t $rd|_d|_YdSwxYwt|j|jkndSdS)NrrrF)rr|r"nextr{r! StopIterationrr+s r_PopLinezTokenizer._PopLine4s d ! !T\ 1 1!$+.. a    d ! !T\ 1 1 1 1 1 1sAA,+A,c0 ||j|j|j}|sdS|ddt zk|_t|d}|xj|z c_)NTrr) rrmatchr|r"group_DEBUG_STRING_SILENT_MARKERr-r)r#rlengths rrzTokenizer._SkipWhitespace@s mmooo&,,T-?NNe  9>Q + +:-d65;;q>>""f llfllrcH|j|kr|dSdS)zTries to consume a given piece of text. Args: token: Text to consume. Returns: True iff the text was consumed. TF)rmrrs rr zTokenizer.TryConsumeKs+ zU nn T 5rc`||s|d|zdS)zConsumes a piece of text. Args: token: Text to consume. Raises: ParseError: If the text couldn't be consumed. zExpected "%s".N)r rrs rr zTokenizer.ConsumeYs: ??5 ! !6 OO,u4 5 5566rc|j}|j|s|d||S)NzExpected comment.)rm_COMMENTrrrr#rPs rConsumeCommentzTokenizer.ConsumeCommentesI ZF =  v & &1 OO/ 0 00NN Mrc|jdko |jdk}|j}|}|j|ko| }||fS)zCConsumes a comment, returns a 2-tuple (trailing bool, comment str).r)r!r"r}r)r# just_startedbefore_parsingcommenttrailings rConsumeCommentOrTrailingCommentz)Tokenizer.ConsumeCommentOrTrailingCommentls^ :?8t|q'8L(N!!##G#~5%$$  W rcR |dS#t$rYdSwxYwNTF)rrr+s rrizTokenizer.TryConsumeIdentifier|@  T  UU  &&c|j}|j|s|d||S)Consumes protocol message field identifier. Returns: Identifier string. Raises: ParseError: If an identifier couldn't be consumed. zExpected identifier.)rm _IDENTIFIERrrrrs rrzTokenizer.ConsumeIdentifiersLZF   ! !& ) )4 OO2 3 33NN MrcR |dS#t$rYdSwxYwr)rrr+s rTryConsumeIdentifierOrNumberz&Tokenizer.TryConsumeIdentifierOrNumbers@ $$&&& T  UUrc|j}|j|s|d|z||S)rz&Expected identifier or number, got %s.)rm_IDENTIFIER_OR_NUMBERrrrrs rrz#Tokenizer.ConsumeIdentifierOrNumbersRZF  % + +F 3 3O OODvM N NNNN MrcR |dS#t$rYdSwxYwr)ConsumeIntegerrr+s rTryConsumeIntegerzTokenizer.TryConsumeIntegers@  T  UUrc t|j}n4#t$r'}|t |d}~wwxYw||S)zConsumes an integer number. Returns: The integer parsed. Raises: ParseError: If an integer couldn't be consumed. N)_ParseAbstractIntegerrm ValueErrorrrrr#rPrs rrzTokenizer.ConsumeIntegersd$$TZ00ff $$$ OOCFF # ##$NN M A"AAcR |dS#t$rYdSwxYwr)rOrr+s rrlzTokenizer.TryConsumeFloats@  T  UUrc t|j}n4#t$r'}|t |d}~wwxYw||S)zConsumes an floating point number. Returns: The number parsed. Raises: ParseError: If a floating point number couldn't be consumed. N) ParseFloatrmrrrrrs rrOzTokenizer.ConsumeFloatsd$$*%%ff $$$ OOCFF # ##$NN Mrc t|j}n4#t$r'}|t |d}~wwxYw||S)zConsumes a boolean value. Returns: The bool parsed. Raises: ParseError: If a boolean value couldn't be consumed. N) ParseBoolrmrrrrrs rrQzTokenizer.ConsumeBoolsd$$$ff $$$ OOCFF # ##$NN MrcR |dS#t$rYdSwxYwr)rTrr+s rrhzTokenizer.TryConsumeByteStringrrc|} t|dS#t$r}||d}~wwxYw)zConsumes a string value. Returns: The string parsed. Raises: ParseError: If a string value couldn't be consumed. rRN)rTrr_StringParseError)r# the_bytesrs rrSzTokenizer.ConsumeStrings]&&((I& G $ $$ &&&  " "1 % %%&s& A AA c|g}|jrV|jdtvrB|||jr|jdtvBd|S)zConsumes a byte array value. Returns: The array parsed (as a string). Raises: ParseError: If a byte array value couldn't be consumed. rr)_ConsumeSingleByteStringrm_QUOTESrr)r#the_lists rrTzTokenizer.ConsumeByteStrings~--//0H *7A'11ood3355666 *7A'11 88H  rc|j}t|dks|dtvr|d|t|dks|d|dkr|d| t j|dd}n4#t $r'}|t|d}~wwxYw||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. rrzExpected string but found: rxrzString missing ending quote: N) rmrrrr CUnescaperrr)r#rYrPrs rrz"Tokenizer._ConsumeSingleByteString s :D 4yy1}}Qw.. OOOttE F FF 4yy1}}RDG++ OOOG H HH$&tAbDz22ff $$$ OOCFF # ##$NN MsB C'"C  Cc t||j}n4#t$r'}|t |d}~wwxYw||Sr*) ParseEnumrmrrrr)r#rcrPrs rrVzTokenizer.ConsumeEnum$sf$ ++ff $$$ OOCFF # ##$NN Ms A "AA cDt||jdz|jdzS)zCreates 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~r#r$s rrz!Tokenizer.ParseErrorPreviousToken,s- gt2Q6+a/ 1 11rc`td|jzdz|z|jdz|jdzS)z9Creates and *returns* a ParseError for the current token.rz': r)rr|r!r"rs rrzTokenizer.ParseError8s: dT//&87Bj1ndlQ&6 8 88rcL|dt|zS)NzCouldn't parse string: )rr)r#rs rrzTokenizer._StringParseError=s ??5A> ? ??rc|j|_|j|_d|_|xjt |jz c_||js d|_dS|j |j |j}|s,|j s%|j |j |j}|r|d}||_dS|j |j|_dS)z Reads the next meaningful token.FrNr)r!r}r"r~r-rrmrr_TOKENrr|rrr)r#rrms rrzTokenizer.NextToken@s*D LD7400-B   q ! !D (=+>+>q+A+A AD@ tQ<< @@@ 2Y> ? ??@s AA6c t|S#t$rt|r.|ddkrtdcYStdcYSt|rtdcYS t|dcYS#t$rtd|zwxYwwxYw)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. r-z-infinfnanfzCouldn't parse float: %s)floatr_FLOAT_INFINITYr _FLOAT_NANrCrYs rrrs= ;; ===T"" = aCV}}U||   $  = 5\\=T[[%%&&&&& ===4t;<<<==s-?CC#)C!B30C3CCc8|dvrdS|dvrdStd)zParse a boolean value. Args: text: Text to parse. Returns: Boolean values parsed Raises: ValueError: If text is not a valid boolean. )rt1TrueT)rr0FalseFzExpected "true" or "false".)rrs rrr s5 ''' 4 +++ 5 2 3 33rcZ|j} t|d}|jjs|S|j|d}|t d|j|fznH#t $r;|j|d}|t d|jd|dYnwxYw|jS)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 with number %d.z Enum type "z" has no value named r) rr is_closedrrVrrvalues_by_namer)rcrkenum_descriptorrrs rrr!s O/< ]]F ? $ m 155fdCCJ D'16:; < << ;;; /33E4@@J J'111555: ; ;;;  sAAB#"B#) FFFFFNNFNrNFFr) rFFFFFNNNFFrp)FF)Ar __author__encodings.raw_unicode_escape encodingsencodings.unicode_escaper3rrgoogle.protobuf.internalrrrorrr__all__Uint32ValueCheckerInt32ValueCheckerUint64ValueCheckerInt64ValueCheckerrr IGNORECASErr frozensetrrrrrrobjectr1rrrUrrdr r r rwrrrBr r rrrr _TokenizerrBrIrjrFrkrLrrrrrrrrrrs>  0 $### ,,,,,,222222&&&&&&))))))****** 9 9 96]5774]4665]5774]4668"*12=AA RZ"- 0 0 )J  +#00000I000. # # # # # # # #" "' LLLLLL^555"/4!&!&"#"'!%#'&+": : : : @ -2$$ !!%$) ####6! %27$)$)!%"&&*). %((((02sssssvsssp #("# 7=7=7=7=x#("# #/#/#/#/P(-"'##( ++++H(-"'##( ++++DFFFFFfFFFRV4V4V4V4V4V4V4V4t   C C C D D D B B B C C C,.@@@2===@444(     r