K i xdZdZddlZddlZddlZddlZddlZddlZddl m Z ddl m Z ddl m Z ddl mZddl mZgd Ze j"e j$e j&e j(fZej,d ej.Zej,d ej.Zej,d Zed ZdZdZdZGdde Z!Gdde!Z"Gdde#Z$eddddddddddddf de%fdZ&de'fdZ(dZ)dZ*dedddddddddddf dZ+dedddddddddf dZ,dedddddddddf dZ-d Z.d!Z/d"Z0Gd#d$e#Z1 d9d%Z2 d9d&Z3 d9d'Z4 d9d(Z5Gd)d*e#Z6Gd+d,e#Z7e7Z8d-Z9d.Z:d/Z;d0Zd:d3Z?d:d4Z@d5ZAd6ZBd7ZCd8ZDy);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?$z -?0[0-9]+)'"zgoogle.protobuf.Anyz TceZdZdZy)Errorz'Top-level module error for text_format.N)__name__ __module__ __qualname____doc__a/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/google/protobuf/text_format.pyrr6s/rrc0eZdZdZdfd ZdZdZxZS) ParseErrorz3Thrown in case of text parsing or tokenizing error.c|5|3t|}||dj|z }dj||}|tt||ntt|||_||_y)Nz:{0}z {0} : {1})strformatsuperr__init___line_column)selfmessagelinecolumnloc __class__s rr zParseError.__init__=srt/ Ic   v}}V$$""30g J&w/ J&(DJDLrc|jSN)r!r#s rGetLinezParseError.GetLineJs ::rc|jSr*)r"r+s r GetColumnzParseError.GetColumnMs <<r)NNN)rrrrr r,r. __classcell__)r(s@rrr:s; rrc$eZdZdZdZdZdZy) TextWriterc6tj|_yr*)ioStringIO_writer)r#as_utf8s rr zTextWriter.__init__Ss;;=DLrc8|jj|Sr*)r5write)r#vals rr8zTextWriter.writeVs <<  c ""rc6|jjSr*)r5closer+s rr;zTextWriter.closeYs <<   rc6|jjSr*)r5getvaluer+s rr=zTextWriter.getvalue\s << ""rN)rrrr r8r;r=rrrr1r1Qs!# #rr1Freturnct|}t|| ||||||||| | | | }|j||j}|j |r|j 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): Deprecated. 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): Deprecated. 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 rrr`s{n 7#    #/ ' w <<>&))+ ==? -rc t|fi|}t|tr|S|jdrdnd}|j |S)zFConvert protobuf message to encoded text format. See MessageToString.r6utf-8ascii)r isinstancebytesgetencode)r$kwargstextcodecs rrrsA  +F +$e KZZ *'% U rc|jtjjk(xr<|jj xr$|jj jSr*)typerFieldDescriptor TYPE_MESSAGE message_type has_options GetOptions map_entryfields r _IsMapEntryresP ** 22?? ? 4    ( ( 4    ' ' ) 3 35rc|jtjjk7ry|j|j jj k7ry|j j|jk7ry|jr#|j j|jk(S|j j|jk(S)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) r\rr] TYPE_GROUPnamer_lowerfile is_extensioncontaining_typeextension_scopercs r _IsGroupLikerns ZZ:--888  ZZ5%%**0022   *     ((E,A,AA    - -1F1F FrcXt||||||||| | | | | |}|j|y)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 sGZ  fg$A%%!'%)/ ' wrcVt|||||||| | | | |  }|j||y)%Print a single field name/value pair.rMr@rAN)rBr rdvaluerNrLr6rDrErFrGrHrIrMr@rArOs rr r s= S&';2O$lM'8*>!,  .'  UE"rcVt|||||||| | | | |  }|j||y)z0Print a single field value (not including name).rrN)rBr rss rr r 1s= S&';2O$lM'8*>!,  .'  %'rc|ddlm}|j}ddlm} |j |}|j |}|S#t $rYywxYw)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.protobufrKDefaultrwFindMessageTypeByNameKeyErrorGetMessageClass) type_namerKpool_modrwmessage_descriptorr_s r_BuildMessageFromTypeNamerIsc;&&(O-(>>yI!001CD,   sA AAc heZdZdZdedddddddddddf dZdZdZdZd Z d Z d Z d Z d Z dZy)rBz)Text format printer for protocol message.rFNc||_||_||_||_||_||_||_||_| tjd| |_ n||_ | |_ | |_ | |_ | |_||_y)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: Deprecated. 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: Deprecated. 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. Nzodouble_format is deprecated for text_format. This will turn into error in 7.34.0, please remove it before that.)rNrLr6rDrErFrGrHwarningswarnrIrJrKrMr@rA)r#rNrLr6rDrErFrGrHrIrJrKrMr@rAs rr z_Printer.__init__isdDHDKDL"D)FD&*D*D$D mm E)d'd,D*D.D 4D"Drcd|jvryt|j|j}||j |j |j rdnd}|jj|jdzd|jd|d|j||jj|jrdy dy y) z5Serializes if message is a google.protobuf.Any field./F: [] T) type_urlrTypeNamerKMergeFromStringrtrArNr8rL_PrintMessageFieldValuerD)r#r$packed_messagecolons r_TryPrintAsAnyMessagez_Printer._TryPrintAsAnyMessages '""" .w/?/?/A/3/C/CEN!$$W]]3%%c2e hhnnDKK#$5w7G7GOP "">2 hhnnD,,S7 377  rc|j||j|j}|y|j}|j d|jz|j ||j |jrdydy)NFrrT)rMrLrDrNr8)r#r$ formattedrNs r_TryCustomFormatMessagez _Printer._TryCustomFormatMessagesu&&w T=M=MNI  ((CIIcDKK IIiIIT%%c0 ,00 rcN|jr|j|ry|jjtk(r|j |ry|j }|jr|jd|D]\}}t|r>t|D]/}|j|||}|j||1O|jr|jra|jt j"j$k7r:|jt j"j&k7r|j)|||D]}|j|||j|||j*r%|j-t/j0|yy)zeConvert protobuf message to text format. Args: message: The protocol buffers message. Nc\|djr|djS|djS)Nr)rknumberindex)xs rz'_Printer.PrintMessage..s&qt'8'8! adjjr)key)rrt)rMr DESCRIPTOR full_name_ANY_FULL_TYPE_NAMEr ListFieldsrGsortresorted GetEntryClassr is_repeatedrEcpp_typerr]CPPTYPE_MESSAGECPPTYPE_STRING"_PrintShortRepeatedPrimitivesValuer@_PrintUnknownFieldsrUnknownFieldSet)r#r$fieldsrdrtr entry_submsgelements rr z_Printer.PrintMessagesr  $">">w"G $$(;; ""7+    !F  kkHJ& u U %= /C /,,.3eCjI, //% . /     . .*"<"<"L"LL*"<"<"K"KK  1 1% ? ,g OOE7 + , u%'&*    ~==gFG!rc|j}|D]}|jd|jz|jt|j|j t k(r|jr|jdn&|jd|xjdz c_|j|j|jr|jd|xjdzc_|jd|jzdz|j tk(rf tjt|jdt|j\}}|t|jk(r|jr|jdn&|jd|xjdz c_|j|jr|jd|xjdzc_|jd|jzdz'|jd|jt!j"|jd |j|jrd nd |jd |jt|j|j|jrdnd y#t$rd}YwxYw)zPrint unknown fields.rz { z { rz} z} rz: "Fz" z" z: rN)rNr8rLr field_number wire_typeWIRETYPE_START_GROUPrDrdataWIRETYPE_LENGTH_DELIMITEDr_DecodeUnknownFieldSet memoryviewlen ExceptionrCEscape)r#unknown_field_setrNrdembedded_unknown_messageposs rrz_Printer._PrintUnknownFieldss- ((C"25 iidkk!" iiE&&'( 0 0    ))E  ))F  ++ +   ,    ))D/ ++ + ))C$++%- . ??7 7 -4,J,J$aUZZ-: ) #S #ejj/ !    IIe  IIf  KK1 K  " "#; <    IIdO KK1 K IIcDKK'%/ 0 ))F  ))M))%**e< = ))T--E6 : $ #ejj/" ))#t4e250 # s2AK// K>=K>c|j}|jd|jz|jr&|jt |j n|j r|jd|jjjre|jtjjk(r>|js2|js&|j|j j"n|j|j"|jdnLt%|r&|j|j j&n|j|j&|j(s'|j*tjj,k7r|jdyy)zPrint field name.rrrrN)rNr8rLrJrrrkrlramessage_set_wire_formatr\rr]r^ is_requiredrr_rrnrhrArr)r#rdrNs r_PrintFieldNamez_Printer._PrintFieldName*s+ ((CIIcDKK   iiELL!"    #  ! ! , , . F F JJ*44AA A!!!! ))E&&00 1 ))EOO $ #   %$$))* %**  *44DDD iin Erc|j||jjd|j|||jj|jrdydy)rqrrN)rrNr8r rD)r#rdrts rr z_Printer.PrintFieldHsMHHNN3&HHNN$**355rc|j||jjdtt |dz D]2}|j ||||jjd4|j ||d|jjd|jj|j rdydy) z("Prints short repeated primitives value.z [z, rrrN)rrNr8rangerr rD)r#rdrtis rrz+_Printer._PrintShortRepeatedPrimitivesValueOs HHNN4 3u:> " 5%(+ hhnnT b *HHNN3HHNN$**355rc|jrd}d}nd}d}|jrK|jjd|z|j ||jj|y|jjd|z|xj dz c_|j ||xj dzc_|jjd|j z|zy) N<>{}z%s z%s rr)rFrDrNr8r rL)r#rtopenbclosebs rrz _Printer._PrintMessageFieldValue[s efef  hhnnUU]#  hhnnV hhnnVe^$ kkQk  kkQk hhnnS4;;&/0rct|j}|jtjjk(r|j |y|jtjj k(r_|jjj|d}||j|jy|jt|y|jtjjk(r|jdt|tr|js|j!d}n|}|j"tjj$k(rd}n |j}|jt'j(|||jdy|jtjj*k(r&|r|jdy|jdy|jtjj,k(r|j.At1j2d|jdj5|j.|yt7j8|r|jt|y|jtt;j<|y|jtjj>k(r8|j@,|jdj5|j@|y|jt|y) 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. NrrRFtruefalseznfloat_format is deprecated for text_format. This will turn into error in 7.34.0, please remove it before that.z{1:{0}})!rNrrr]rr CPPTYPE_ENUM enum_typevalues_by_numberrVr8rhrrrTr6rWr\ TYPE_BYTESrr CPPTYPE_BOOL CPPTYPE_FLOATrHrrrmathisnanrToShortestFloatCPPTYPE_DOUBLErI)r#rdrtrN enum_value out_value out_as_utf8s rr z_Printer.PrintFieldValuens1 ((C ~~33CCC ""5) :55BB B??3377tDj   *//" #e* :55DD D iio E3  LL)  z11<< < ll  ii %%i=> iio :55BB B  & ' :55CC C   &   )""4#4#4e<= ::e  ))CJ  ))C 55e<= > ..J66EE E    ( ii   !3!3U;< iiE r)rrrr_as_utf8_defaultr rrr rrr rrr rrrrBrBfse1 $) F#P %HN55n<6 61&5rrBcft|jt|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 s7d DJJ 4(?uUK+&$3(;  ==rcft|jt|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 s7:  jj*T51u= %-  //rcDt||||}|j||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' **rcDt||||}|j||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 rrr(rrcteZdZdZ ddZdZdZdZdZdZ d Z d Z d Z d Z d ZdZdZdZdZy)rz(Text format parser for protocol message.Nc<||_||_||_||_yr*)rrrKr)r#rrrKrs rr z_Parser.__init__Ms$ $;D 0D*D2Drc8d|_|j|||S)zBParses a text representation of a protocol message into a message.F_allow_multiple_scalars _ParseOrMerger#rr$s rrz_Parser.ParseLinesWs#(D ug& Nrc8d|_|j|||S)zBMerges a text representation of a protocol message into a message.Trrs rrz_Parser.MergeLines]s#'D ug& Nrc d|D}t|}|r|jj|_|j s$|j|||j s#yy#t$r }t|d}~wwxYw)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. c3bK|]'}t|tr|n|jd)yw)rRN)rTrdecode).0r%s r z(_Parser._ParseOrMerge..os/T3'$T[[-A As-/N) TokenizerUnicodeDecodeErrorrrr root_typeAtEnd _MergeField)r#rr$ str_lines tokenizeres rrz_Parser._ParseOrMergecsziI&i))33dnoo y'*oo  AsA(( A=1A88A=c 6 |j}|jtk(r)|jdr|j |\}}|j d|jd|j ||j|dz|z|jdrd}n|j dd}t||j}|td |z|j|sI|jr|jd |d |j|||j|sId }|j|||y |jdr|jg} |jdr1| j|j|jdr1dj!| } |j"s|jd|jz|j$j'| } | s#|j(rd } nE|jd| z|| j*k7r"|jd| d|jd |j dn#|j-} |j.rc| j1rSt3| dd} |j4j7| d } | s|j"r|j$j9| } nt|j:j7| d } | sV|j:j7| j=d } | r t?| sd } | r| j@jB| k7rd } | s.|jDs"|jd|jd| d | r|jFs| jHr||jK| jHjB} | U| | jBk7rF|jd| jBd| d| jHjBd|jd | jLtNjPjRk(rE|jd|j ||j| j|jT} nD|j d|j ||j| j|jV} | jXrQ|jdr@|jdsq | ||| |jdrnT|j d.| ||| n7|j(s|jDsJ|j[|| |j|jds|jdy y )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. rrrrrrrrNz$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 ",;).rrr TryConsume_ConsumeAnyTypeUrlConsume_DetectSilentMarkerrrKrrParseErrorPreviousTokenrPackConsumeIdentifierappendjoin is_extendable Extensions_FindExtensionByNamerrlConsumeIdentifierOrNumberrisdigit ParseIntegerfields_by_numberrV_FindExtensionByNumberfields_by_namerirnr_rhrrcontaining_oneof WhichOneofrrr]r_MergeMessageField_MergeScalarFieldr_SkipFieldContents)r#rr$rr packed_type_nameexpanded_any_end_tokenexpanded_any_sub_messager rhrdr which_oneofmergers rrz_Parser._MergeFieldzsI!++$$(;;S!*.*A*A)*L'o'3 y*<*F*F.47GGI   c "!$#!$!:;K;?;O;O"Q " )?)*+ +$$%;< ?? 113I3LM M $<= $$%;< m ll+#2!.0 C ))+ ,d   % I//12   % XXd^d  - -// 9  ( ( )* *  55d;e   ' '%11EHL LM M !6!6 6// %// 12 2 0 0 2d T\\^dD$/"3377E+99$$;;FC%"1155dDA $3377 dK% <.E u))..$6E 433//  ) )4 12 2  ) )e.D.D(()?)?)D)DE  "{ejj'@11zz;(>(>(C(C!++-. . :55EE ES!   ,>,H,H!& 2((#   ,>,H,H!& 2''      s ###C( 9gu -##C(   c "  y'5)**d.F.FGF i/A/K/KL    $3 %rcyr*r)r#immediate_message_type field_names r_LogSilentMarkerz_Parser._LogSilentMarker srcB|jr|j||yyr*)+contains_silent_marker_before_current_tokenr0)r#rr.r/s rrz_Parser._DetectSilentMarker s!<< 2J?=rc|jg}|jd|j|j|jd|j|j|jd|jg}|jdr1|j|j|jdr1dj |dj |fS)zBConsumes a google.protobuf.Any type URL and returns the type name.r r)rrrrr)r#rprefixrhs rrz_Parser._ConsumeAnyTypeUrls))+ ,F c MM)--/0 c MM)--/0 c  ' ' ) *D   s # kk)--/0   s # 88F SXXd^ ++rcpt|}|jdrd}n|jdd}|jr}|jr|j |j }nD|r+t||jj}nt||jj }n|jrc|jsG|j|r6|jd|jjd|jd|j |}ns|jsQ|j|jr6|jd|jjd|jdt||j}|j!|j|sI|j#r|jd |d |j%|||j|sI|r|j&j(d j*}|t,j.j0k(r?t||j|j2}|j5|j6y |j6t||j|j2<y y ) 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. rrrrr" should not have multiple " " extensions. " fields.r r rtN)rerrrrkraddgetattrrhrr HasExtensionrrrHasField SetInParentrrr_r"rrr]rrCopyFromrt) r#rr$rd is_map_entry end_token sub_message value_cpptyperts rr%z_Parser._MergeMessageField s0u%LC ii    ((/335 Bgguzz2@@BD guzz2668   ,,   '11!!++U__>? ?((/ ,,   UZZ (11!!++UZZ9: :guzz2 ""9-  //I0OPP y+.""9- ((77@IIm *44DD D,[__= {(()8C8I8I$[__5 rc|j}d}|jtjjtjj tjj fvr t|}nJ|jtjjtjjtjjfvr t|}n|jtjjtjjfvr t|}n|jtjjtjj fvr t#|}nJ|jtjj$tjj&fvr|j)}n|jtjj*k(r|j-}n|jtjj.k(r|j1}n|jtjj2k(r|j5}nQ|jtjj6k(r|j9|}nt;d|jz|j<rQ|j>r|j@|jC|ytE||jFjC|y|j>ro|jHsS|jJrG|jM|r6|jOd|jPjRd|jRd||j@|<yd}|jHsR|jJr|jU|jF}n*tWjXtE||jF }|r6|jOd|jPjRd|jFdt[||jF|y)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 %drr6r7Fr8).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 RuntimeErrorrrkrrr:rhr has_presencer;rrrr<rIsDefaultScalarValuesetattr)r#rr$rd_rtduplicate_errors rr&z_Parser._MergeScalarFieldZsK $$A E zzj00;; 00<< 00>>@@I&e  22=="22>>"22@@B BI&e  22>>"22??A AY'e  22>>"22??A AY'e  22=="22>>@ @$$&e z11;; ;##%e z11== =%%'e z11<< <))+e z11;; ;##E*e 05::= >>    5!((/$++E2   ,,      '11!!++U__>? ?','  U #++   %..uzz:O#*">">,#O 11!!++UZZ9: : '5::u -rcF|jdrk|jdsZ|jdsI|j||||jdr|j||y|j |y|j||||j ||y)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. rrrrN)r LookingAtr_SkipRepeatedFieldValue_SkipFieldValue_SkipFieldMessage)r#rr/r.s rr'z_Parser._SkipFieldContentss  ((-i6I6I#6N y*@*M   S ! $$Y0FG Y' y*@*M Y(>?rc`d}|jdr|d|jzz }d}|jdr-|d|jzz }|dz }|jdr-|dk(r`|jdrO|d|jzz }|jdr(|d|jzz }|jdr(|jd|dz }n||jz }|j ||||jds|jd y y ) 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. rrrr rrrrrN)rrrrr')r#rr.r/num_identifierss r _SkipFieldz_Parser._SkipFields:JC C)55777jo   %cI77999 1   % A )"6"6s";cI77999 ""3' i99;; ;*""3'CjI7799jIz3IJ    $3 %rc"|jdrd}n|jdd}|jdsF|jds5|j|||jds|jds5|j|y)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)rrrcri)r#rr. delimiters rrfz_Parser._SkipFieldMessagesC ii!!#&y/B/B3/G ooi!78!!#&y/B/B3/Gi rc|jsR|jsAt|s5t|s)|j st d|j zyyyyy)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_TryConsumeUint64TryConsumeFloatrtoken)r#rs rrez_Parser._SkipFieldValuesf  * * ,  * * , Y ' i (  % % ' .@ AA ( ) ( - -rc|jd|jdsk |jds|jdr|j||n|j ||jdry|jdjy)ziSkips over a repeated field value. Args: tokenizer: A tokenizer to parse the field value. rrrrrN)rrrcrfre)r#rr.s rrdz_Parser._SkipRepeatedFieldValues c    $    s #y':':3'?  ,B C   y )    $ #  %rFFNF)rrrrr rrrrr0rrr%r&r'rirfrerdrrrrrJsh0(-"'##( 3  +.N ` @ ,8JtK.Z@4 B!&B rrc ,eZdZdZej dZej dejZej dejZ ej djddge Dcgc]}dj| c}}zZ ej d Zej d Zd(d Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!dZ"dZ#d Z$d!Z%d"Z&d#Z'd$Z(d%Z)d&Z*y'cc}}w))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_.+-]*z0{qt}[^{qt}\n\\]*((\\.)+[^{qt}\n\\]*)*({qt}|\\?$))qtz [^\d\W]\w*z\w+cDd|_d|_d|_d|_d|_t ||_d|_d|_d|_ d|_ ||_ |xr |jxs |j|_d|_|j!|j#y)NrrrTF) _positionr!r" _token_startrriter_lines _current_line_previous_line_previous_column _more_lines_skip_comments_WHITESPACE_OR_COMMENT _WHITESPACE_whitespace_patternr2_SkipWhitespace NextToken)r#r skip_commentss rr zTokenizer.__init__/sDNDJDLDDJu+DKDDDD'D - M$2M2M!4#'#3#3 7rc8t|j|jkr[ t|j|_|xj dz c_d|_t|j|jkrZyy#t $rd|_d|_YywxYw)NrrrF)rr}r"nextr|r! StopIterationrr+s r_PopLinezTokenizer._PopLineMs d  !T\\ 1!$++. a   d  !T\\ 1 sA??BBc* |j|jj|j|j}|sy|j ddt zk(|_t|j d}|xj|z c_)Nrr) rrmatchr}r"group_DEBUG_STRING_SILENT_MARKERr2r)r#rlengths rrzTokenizer._SkipWhitespaceYsy  mmo&&,,T-?-?Ne  9>Q + +:-d65;;q>"f llfl rcD|j|k(r|jyy)zTries to consume a given piece of text. Args: token: Text to consume. Returns: True iff the text was consumed. TF)rrrrs rrzTokenizer.TryConsumeds  zzU nn  rcN|j|s|jd|zy)zConsumes a piece of text. Args: token: Text to consume. Raises: ParseError: If the text couldn't be consumed. zExpected "%s".N)rrrs rrzTokenizer.Consumers* ??5 ! OO,u4 55 "rc|j}|jj|s|jd|j |S)NzExpected comment.)rr_COMMENTrrrr#rPs rConsumeCommentzTokenizer.ConsumeComment~s< ZZF ==  v & OO/ 00NN Mrc|jdk(xr|jdk(}|j}|j}|j|k(xr| }||fS)zCConsumes a comment, returns a 2-tuple (trailing bool, comment str).r)r!r"r~r)r# just_startedbefore_parsingcommenttrailings rConsumeCommentOrTrailingCommentz)Tokenizer.ConsumeCommentOrTrailingCommentse ::?8t||q'8L((N!!#G##~5%$$  W rcD |jy#t$rYywxYwNTF)rrr+s rrnzTokenizer.TryConsumeIdentifier(      c|j}|jj|s|jd|j |S)Consumes protocol message field identifier. Returns: Identifier string. Raises: ParseError: If an identifier couldn't be consumed. zExpected identifier.)rr _IDENTIFIERrrrrs rrzTokenizer.ConsumeIdentifiers@ZZF    ! !& ) OO2 33NN MrcD |jy#t$rYywxYwr)rrr+s rTryConsumeIdentifierOrNumberz&Tokenizer.TryConsumeIdentifierOrNumbers( $$&   rc|j}|jj|s|jd|z|j |S)rz&Expected identifier or number, got %s.)rr_IDENTIFIER_OR_NUMBERrrrrs rrz#Tokenizer.ConsumeIdentifierOrNumbersEZZF  % % + +F 3 OODvM NNNN MrcD |jy#t$rYywxYwr)ConsumeIntegerrr+s rTryConsumeIntegerzTokenizer.TryConsumeIntegers(    rc t|j}|j |S#t$r}|jt |d}~wwxYw)zConsumes an integer number. Returns: The integer parsed. Raises: ParseError: If an integer couldn't be consumed. N)_ParseAbstractIntegerrr ValueErrorrrrr#rPrs rrzTokenizer.ConsumeIntegersK$$TZZ0f NN M $ OOCF ##$) AA  AcD |jy#t$rYywxYwr)rTrr+s rrqzTokenizer.TryConsumeFloats(    rc t|j}|j |S#t$r}|jt |d}~wwxYw)zConsumes an floating point number. Returns: The number parsed. Raises: ParseError: If a floating point number couldn't be consumed. N) ParseFloatrrrrrrrs rrTzTokenizer.ConsumeFloatsK$$**%f NN M $ OOCF ##$rc t|j}|j |S#t$r}|jt |d}~wwxYw)zConsumes a boolean value. Returns: The bool parsed. Raises: ParseError: If a boolean value couldn't be consumed. N) ParseBoolrrrrrrrs rrVzTokenizer.ConsumeBoolsK$$f NN M $ OOCF ##$rcD |jy#t$rYywxYwr)rYrr+s rrmzTokenizer.TryConsumeByteStringrrc|j} t|dS#t$r}|j|d}~wwxYw)zConsumes a string value. Returns: The string parsed. Raises: ParseError: If a string value couldn't be consumed. rRN)rYrr_StringParseError)r# the_bytesrs rrXzTokenizer.ConsumeStringsE&&(I& G $$ &  " "1 %%&s  =8=c |jg}|jrV|jdtvrA|j|j|jr|jdtvrAdj |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)_ConsumeSingleByteStringrr_QUOTESrr)r#the_lists rrYzTokenizer.ConsumeByteStringsg--/0H **A'1ood3356 **A'1 88H rcz|j}t|dks |dtvr|jd|t|dks |d|dk7r|jd| t j |dd}|j|S#t $r}|jt|d}~wwxYw)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: rrzString missing ending quote: N) rrrrrr CUnescaperrr)r#rYrPrs rrz"Tokenizer._ConsumeSingleByteString#s ::D 4y1}Qw. OOtE FF 4y1}RDG+ OOG HH$&&tAbz2f NN M $ OOCF ##$s(B B:B55B:c t||j}|j |S#t$r}|jt |d}~wwxYwr*) ParseEnumrrrrrr)r#rdrPrs rr[zTokenizer.ConsumeEnum=sM$ +f NN M $ OOCF ##$s* AA  AcPt||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~rr#r$s rrz!Tokenizer.ParseErrorPreviousTokenEs. gt22Q6++a/ 11rcvtd|jzdz|z|jdz|jdzS)z9Creates and *returns* a ParseError for the current token.rz': r)rr}r!r"rs rrzTokenizer.ParseErrorQs< dT///&87Bjj1ndllQ&6 88rc<|jdt|zS)NzCouldn't parse string: )rr)r#rs rrzTokenizer._StringParseErrorVs ??5A> ??rc<|j|_|j|_d|_|xjt |j z c_|j|jsd|_y|jj|j|j}|s<|js0|jj|j|j}|r|jd}||_y|j|j|_y)z Reads the next meaningful token.FrNr)r!r~r"rr2rrrrr_TOKENrr}rrr)r#rrrs rrzTokenizer.NextTokenYs**D LLD740-   q !D (=+>+>q+A AD@ tQ< @ 2Y> ??@s  AA&ctj|rtd|z t|S#t$rtj|r"|ddk(r tdcYStdcYSt j|r tdcYS t|j 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. zInvalid octal float: %sr-z-infinfnanfFzCouldn't parse float: %s)_FLOAT_OCTAL_PREFIXrrfloat_FLOAT_INFINITY _FLOAT_NANrCrYs rrrst$ .5 66< ; <T" aCV}U|   $  5\<T[[&'' <3d:;;<r s 0 $ ,2&)* 96]5574]4465]5574]4468"**12==A RZZ"-- 0  bjj- J +#0I0. # #" "' LL^5 @)"/4!&!&"#"'!%#'&+": @' -2$$ !!%$) #6, %27$)$)!%"&&*). %(02}v}D #("# 7=x#("# #/P(-"'##( +H(-"'##( +DJfJZV4V4t   C D B C,.@2