HEX
Server: LiteSpeed
System: Linux in-mum-web921.main-hosting.eu 4.18.0-553.34.1.lve.el8.x86_64 #1 SMP Thu Jan 9 16:30:32 UTC 2025 x86_64
User: u590867752 (590867752)
PHP: 8.2.33
Disabled: NONE
Upload Files
File: //proc/self/root/lib/python3.6/site-packages/google/protobuf/__pycache__/text_format.cpython-36.pyc
3

8��e���	@sdZdZddlZddlZddlZejr*eZddlm	Z	ddl
mZddl
mZddd	d
dgZ
e	j�e	j�e	j�e	j�fZejdej�Zejd
ej�Zeejjejjg�ZedO�ZdZGdd�de�ZGdd�de�Z Gdd�de!�Z"dPdd�Z#dd�Z$dQdd�Z%dRdd	�Z&dSdd
�Z'dd�Z(Gd d!�d!e!�Z)dTd"d#�Z*dUd$d�Z+dVd%d&�Z,dWd'd(�Z-Gd)d*�d*e!�Z.d+d,�Z/d-d.�Z0d/d0�Z1d1d2�Z2Gd3d4�d4e!�Z3e3Z4d5d6�Z5d7d8�Z6d9d:�Z7d;d<�Z8d=d>�Z9d?d@�Z:dXdAdB�Z;dYdCdD�Z<dZdEdF�Z=d[dGdH�Z>dIdJ�Z?dKdL�Z@dMdN�ZAdS)\abContains 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)�
type_checkers)�
descriptor)�
text_encoding�MessageToString�PrintMessage�
PrintField�PrintFieldValue�Mergez-?inf(?:inity)?f?znanf?�'�"zgoogle.protobuf.Anyc@seZdZdZdS)�Errorz'Top-level module error for text_format.N)�__name__�
__module__�__qualname__�__doc__�rr�!/usr/lib/python3.6/text_format.pyrIsrcs2eZdZdZd	�fdd�	Zdd�Zdd�Z�ZS)
�
ParseErrorz3Thrown in case of text parsing or tokenizing error.Ncsr|dk	r:|dk	r:t|�}|dk	r.|dj|�7}dj||�}|dk	rTtt|�j|�ntt|�j�||_||_dS)Nz:{0}z	{0} : {1})�str�format�superr�__init__�_line�_column)�self�message�line�column�loc)�	__class__rrrPszParseError.__init__cCs|jS)N)r)rrrr�GetLine]szParseError.GetLinecCs|jS)N)r)rrrr�	GetColumn`szParseError.GetColumn)NNN)r
rrrrr r!�
__classcell__rr)rrrMs
rc@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�
TextWritercCs tjrtj�|_n
tj�|_dS)N)�six�PY2�io�BytesIO�_writer�StringIO)r�as_utf8rrrrfszTextWriter.__init__cCs(tjrt|tj�r|jd�}|jj|�S)Nzutf-8)r$r%�
isinstance�	text_type�encoder(�write)r�valrrrr.ls
zTextWriter.writecCs
|jj�S)N)r(�close)rrrrr0rszTextWriter.closecCs
|jj�S)N)r(�getvalue)rrrrr1uszTextWriter.getvalueN)r
rrrr.r0r1rrrrr#dsr#Fc

CsLt|�}
t|
|||||||||	�
}|j|�|
j�}|
j�|rH|j�S|S)aConvert protobuf message to text format.

  Floating point values can be formatted compactly with 15 digits of
  precision (which is the most that IEEE 754 "double" can guarantee)
  using float_format='.15g'. To ensure that converting to text and back to a
  proto will result in an identical value, float_format='.17g' should be used.

  Args:
    message: The protocol buffers message.
    as_utf8: Produce text output in UTF8 format.
    as_one_line: Don't introduce newlines between fields.
    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: If set, use this to specify floating point number formatting
      (per the "Format Specification Mini-Language"); otherwise, str() is used.
    use_field_number: If True, print field numbers instead of names.
    descriptor_pool: A DescriptorPool used to resolve Any types.
    indent: The indent level, in terms of spaces, for pretty print.
    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.

  Returns:
    A string of the text formatted protocol buffer message.
  )r#�_Printerrr1r0�rstrip)
rr*�as_one_line�pointy_brackets�use_index_order�float_format�use_field_number�descriptor_pool�indent�message_formatter�out�printer�resultrrrrys(
cCs"|jtjjko |jjo |jj�jS)N)�typer�FieldDescriptor�TYPE_MESSAGE�message_typeZhas_options�
GetOptionsZ	map_entry)�fieldrrr�_IsMapEntry�srEcCs(t|||||||||	|
�
}|j|�dS)N)r2r)rr<r:r*r4r5r6r7r8r9r;r=rrrr�sc
	Cs&t||||||||	�}
|
j||�dS)z%Print a single field name/value pair.N)r2r)rD�valuer<r:r*r4r5r6r7r;r=rrrr�s
c
	Cs&t||||||||	�}
|
j||�dS)z0Print a single field value (not including name).N)r2r)rDrFr<r:r*r4r5r6r7r;r=rrrr�s
cCsd|dkrddlm}|j�}ddlm}|j�}y|j|�}Wntk
rRdSX|j|�}|�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)r9)�symbol_database)�google.protobufr9ZDefaultrGZFindMessageTypeByName�KeyErrorZGetPrototype)Z	type_namer9Zpool_modrGZdatabase�message_descriptorrBrrr�_BuildMessageFromTypeName�s
rKc	@sJeZdZdZddd�Zdd�Zd	d
�Zdd�Zd
d�Zdd�Z	dd�Z
dS)r2z)Text format printer for protocol message.rFNcCs@||_||_||_||_||_||_||_||_|	|_|
|_	dS)aZInitialize the Printer.

    Floating point values can be formatted compactly with 15 digits of
    precision (which is the most that IEEE 754 "double" can guarantee)
    using float_format='.15g'. To ensure that converting to text and back to a
    proto will result in an identical value, float_format='.17g' should be used.

    Args:
      out: To record the text format result.
      indent: The indent level for pretty print.
      as_utf8: Produce text output in UTF8 format.
      as_one_line: Don't introduce newlines between fields.
      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 floating point number formatting
        (per the "Format Specification Mini-Language"); 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.
    N)
r<r:r*r4r5r6r7r8r9r;)rr<r:r*r4r5r6r7r8r9r;rrrrs%z_Printer.__init__cCsht|j�|j�}|r`|j|j�|jjd|jd|jf�|j	|�|jj|j
rVdnd�dSdSdS)z5Serializes if message is a google.protobuf.Any field.z%s[%s]� �
TFN)rKZTypeNamer9�MergeFromStringrFr<r.r:Ztype_url�_PrintMessageFieldValuer4)rrZpacked_messagerrr�_TryPrintAsAnyMessage0s
z_Printer._TryPrintAsAnyMessagecCsV|j||j|j�}|dkrdS|j}|jd|j�|j|�|j|jrLdnd�dS)NFrLrMT)r;r:r4r<r.)rrZ	formattedr<rrr�_TryCustomFormatMessage=s
z _Printer._TryCustomFormatMessagecCs�|jr|j|�rdS|jjtkr.|j|�r.dS|j�}|jrL|jdd�d�x�|D]z\}}t	|�r�xht
|�D]$}|j�|||d�}|j||�qlWqR|j
tjjkr�x&|D]}|j||�q�WqR|j||�qRWdS)zeConvert protobuf message to text format.

    Args:
      message: The protocol buffers message.
    NcSs|djr|djS|djS)Nr)�is_extension�number�index)�xrrr�<lambda>Vsz'_Printer.PrintMessage.<locals>.<lambda>)�key)rWrF)r;rQ�
DESCRIPTOR�	full_name�_ANY_FULL_TYPE_NAMErPZ
ListFieldsr6�sortrE�sorted�
GetEntryClassr�labelrr@�LABEL_REPEATED)rrZfieldsrDrFrWZentry_submsg�elementrrrrHs$

z_Printer.PrintMessagecCs�|j}|jd|j�|jr.|jt|j��n�|jr�|jd�|jj�j	rv|j
tjj
krv|jtjjkrv|j|jj�n|j|j�|jd�n*|j
tjjkr�|j|jj�n|j|j�|jtjjkr�|jd�|j||�|jr�|jd�n
|jd�dS)z%Print a single field name/value pair.rL�[�]z: rMN)r<r.r:r8rrSrR�containing_typerCZmessage_set_wire_formatr?rr@rAr^ZLABEL_OPTIONALrBrY�
TYPE_GROUP�name�cpp_type�CPPTYPE_MESSAGErr4)rrDrFr<rrrrgs*

z_Printer.PrintFieldcCs�|jrd}d}nd}d}|jrF|jjd|�|j|�|jj|�nL|jjd|�|jd7_|j|�|jd8_|jjd|j|�dS)	N�<�>�{�}z %s z %s
�rL)r5r4r<r.rr:)rrFZopenbZclosebrrrrO�s

z _Printer._PrintMessageFieldValuecCs<|j}|jtjjkr"|j|��n|jtjjkrf|jjj	|d�}|dk	rV|j
|j�n|j
t|��n�|jtjj
kr�|j
d�t|tj�r�|jd�}n|}|jtjjkr�d}n|j}|j
tj||��|j
d�nf|jtjjkr�|r�|j
d�n
|j
d�n<|jtk�r*|jdk	�r*|j
dj|j|��n|j
t|��dS)z�Print a single field value (not including name).

    For repeated fields, the value should be a single element.

    Args:
      field: The descriptor of the field to be printed.
      value: The value of the field.
    Nrzutf-8F�true�falsez{1:{0}})r<rfrr@rgrOZCPPTYPE_ENUM�	enum_type�values_by_number�getr.rerZCPPTYPE_STRINGr+r$r,r-r?�
TYPE_BYTESr*rZCEscapeZCPPTYPE_BOOL�_FLOAT_TYPESr7r)rrDrFr<�
enum_valueZ	out_valueZout_as_utf8rrrr�s2	
z_Printer.PrintFieldValue)	rFFFFNFNN)r
rrrrrPrQrrrOrrrrrr2�s 
&
!r2cCs>t|t�s&tjr|jd�}n
|jd�}t|jd�||||d�S)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.

  Example
    a = MyProto()
    a.repeated_field.append('test')
    b = MyProto()

    text_format.Parse(repr(a), b)
    text_format.Parse(repr(a), b) # repeated_field contains ["test", "test"]

    # Binary version:
    b.ParseFromString(a.SerializeToString()) # repeated_field is now "test"

  Caller is responsible for clearing the message as needed.

  Args:
    text: Message 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.

  Returns:
    The same message passed as argument.

  Raises:
    ParseError: On text parsing problems.
  zutf-8rM)r9)r+rr$�PY3�decoder-�
ParseLines�split)�textr�allow_unknown_extension�allow_field_numberr9rrr�Parse�s%


r|cCs>t|t�s&tjr|jd�}n
|jd�}t|jd�||||d�S)a^Parses a text representation of a protocol message into a message.

  Like Parse(), but allows repeated values for a non-repeated field, and uses
  the last one.

  Args:
    text: Message 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.

  Returns:
    The same message passed as argument.

  Raises:
    ParseError: On text parsing problems.
  zutf-8rM)r9)r+rr$rurvr-�
MergeLinesrx)ryrrzr{r9rrrr	�s

cCst|||d�}|j||�S)aParses a text representation of a protocol message into a message.

  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.

  Returns:
    The same message passed as argument.

  Raises:
    ParseError: On text parsing problems.
  )r9)�_Parserrw)�linesrrzr{r9�parserrrrrwsrwcCst|||d�}|j||�S)aParses a text representation of a protocol message into a message.

  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.

  Returns:
    The same message passed as argument.

  Raises:
    ParseError: On text parsing problems.
  )r9)r~r})rrrzr{r9r�rrrr}6sr}c@sneZdZdZddd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Ze
dd��Zdd�ZdS)r~z(Text format parser for protocol message.FNcCs||_||_||_dS)N)rzr{r9)rrzr{r9rrrrTsz_Parser.__init__cCs&t|t�s|jd�}|j|jd�|�S)zBParses a text representation of a protocol message into a message.zutf-8rM)r+rrvrwrx)rryrrrr�ParseFromString\s

z_Parser.ParseFromStringcCsd|_|j||�|S)zBParses a text representation of a protocol message into a message.F)�_allow_multiple_scalars�
_ParseOrMerge)rrrrrrrwbsz_Parser.ParseLinescCs|j|jd�|�S)zBMerges a text representation of a protocol message into a message.rM)Z_MergeLinesrx)rryrrrrrNhsz_Parser.MergeFromStringcCsd|_|j||�|S)zBMerges a text representation of a protocol message into a message.T)r�r�)rrrrrrr}lsz_Parser.MergeLinescCs&t|�}x|j�s |j||�q
WdS)z�Converts a text representation of a protocol message into a message.

    Args:
      lines: Lines of a message's text representation.
      message: A protocol buffer message to merge into.

    Raises:
      ParseError: On text parsing problems.
    N)�	Tokenizer�AtEnd�_MergeField)rrr�	tokenizerrrrr�rs

z_Parser._ParseOrMergec
Cs`|j}|jtkr�|jd�r�|j|�\}}|jd�|jd�|jd�rLd}n|jd�d}t||j�}|svtd|��x2|j|�s�|j	�r�|j
d	|f��|j||�qxW|j||d
�dS|jd��rn|j
�g}x|jd�r�|j|j
��q�Wdj|�}|j�s|j
d
|j��|jj|�}	|	�sB|j�r2d}	n|j
d|��n ||	jk�rb|j
d||jf��|jd�n�|j�}|j�r�|j��r�t|dd�}
|jj|
d�}	|	�r(|j�r(|jj|
�}	nh|jj|d�}	|	�s|jj|j�d�}	|	�r|	jtj j!k�rd}	|	�r(|	jtj j!k�r(|	j"j#|k�r(d}	|	�sB|j
d|j|f��|	�r2|j$�r�|	j%�r�|j&|	j%j#�}|dk	�r�||	j#k�r�|j
d|	j#||	j%j#|jf��|	j'tj j(k�r�|jd�|j)}n|jd�|j*}|	j+tj j,k�r$|jd��r$|jd��s0x8||||	�|jd��rP|jd��q�Wn||||	�n|j�s>t-�t.|�|jd��s\|jd�dS)z�Merges a single protocol message field into a message.

    Args:
      tokenizer: A tokenizer to parse the field name and values.
      message: A protocol message to record the data.

    Raises:
      ParseError: In case of text parsing problems.
    rarb�:rhrirjrkz$Type %s not found in descriptor poolzExpected "%s".)�type_url_prefixN�.z+Message type "%s" does not have extensions.z�Extension "%s" not registered. Did you import the _pb2 module which defines it? If you are trying to place the extension in the MessageSet field of another message that is in an Any or MessageSet field, that message's _pb2 module must be imported as wellz1Extension "%s" does not extend message type "%s".Tz*Message type "%s" has no field named "%s".zbField "%s" is specified along with field "%s", another member of oneof "%s" for message type "%s".�,�;)/rXrYrZ�
TryConsume�_ConsumeAnyTypeUrl�ConsumerKr9rr��ParseErrorPreviousTokenr�ZPack�ConsumeIdentifier�append�joinZ
is_extendable�
ExtensionsZ_FindExtensionByNamerzrc�ConsumeIdentifierOrNumberr{�isdigit�ParseIntegerZfields_by_numberrqZ_FindExtensionByNumber�fields_by_name�lowerr?rr@rdrBrer�Zcontaining_oneofZ
WhichOneofrfrg�_MergeMessageField�_MergeScalarFieldr^r_�AssertionError�_SkipFieldContents)
rr�rrJr�Zpacked_type_nameZexpanded_any_end_tokenZexpanded_any_sub_messagererDrSZwhich_oneofZmergerrrrr��s�













z_Parser._MergeFieldcCs�|j�g}|jd�|j|j��|jd�|j|j��|jd�|j�g}x|jd�rj|j|j��qPWdj|�dj|�fS)zBConsumes a google.protobuf.Any type URL and returns the type name.r��/)r�r�r�r�r�)rr��prefixrerrrr�s




z_Parser._ConsumeAnyTypeUrlc	Cs�t|�}|jd�rd}n|jd�d}|jtjjkrt|jrJ|j|j	�}q�|rbt
||j�j��}q�t
||j�j	�}n||jr�|j
r�|j|�r�|jd|jj|jf��|j|}n8|j
r�|j|j�r�|jd|jj|jf��t
||j�}|j�x6|j|��s&|j��r|jd|f��|j||�q�W|�r~|jjdj}|tjjk�rjt
||j�|j}|j|j�n|jt
||j�|j<d	S)
a"Merges a single scalar field into a message.

    Args:
      tokenizer: A tokenizer to parse the field value.
      message: The message of which field is a member.
      field: The descriptor of the field to be merged.

    Raises:
      ParseError: In case of text parsing problems.
    rhrirjrkz;Message type "%s" should not have multiple "%s" extensions.z7Message type "%s" should not have multiple "%s" fields.zExpected "%s".rFN)rEr�r�r^rr@r_rRr��add�getattrrer]r��HasExtensionr�rXrY�HasFieldZSetInParentr�r�rBr�rfrgrWZ	MergeFromrF)	rr�rrDZis_map_entryZ	end_tokenZsub_messageZ
value_cpptyperFrrrr�sF



z_Parser._MergeMessageFieldcCs|j}t|d�o|jdkS)N�syntax�proto3)rX�hasattrr�)rrJrrr�_IsProto3SyntaxOs
z_Parser._IsProto3SyntaxcCs|j}d}|jtjjtjjtjjfkr0t|�}n�|jtjjtjj	tjj
fkrVt|�}n�|jtjjtjj
fkrvt|�}n�|jtjjtjjfkr�t|�}n�|jtjjtjjfkr�|j�}nr|jtjjkr�|j�}nZ|jtjjkr�|j�}nB|jtjjkr�|j�}n*|jtjjk�r|j|�}ntd|j��|jtjjk�rf|j �rR|j!|j"|�nt#||j$�j"|�n�|j%|�}|j �r�|j&�r�|�r�|j'|��r�|j(d|j)j*|j*f��n
||j!|<nF|j&�r�|�r�|j+|j$��r�|j(d|j)j*|j$f��nt,||j$|�dS)aHMerges a single scalar field into a message.

    Args:
      tokenizer: A tokenizer to parse the field value.
      message: A protocol message to record the data.
      field: The descriptor of the field to be merged.

    Raises:
      ParseError: In case of text parsing problems.
      RuntimeError: On runtime errors.
    NzUnknown field type %dz;Message type "%s" should not have multiple "%s" extensions.z7Message type "%s" should not have multiple "%s" fields.)-rzr?rr@Z
TYPE_INT32ZTYPE_SINT32Z
TYPE_SFIXED32�
_ConsumeInt32Z
TYPE_INT64ZTYPE_SINT64Z
TYPE_SFIXED64�
_ConsumeInt64ZTYPE_UINT32ZTYPE_FIXED32�_ConsumeUint32ZTYPE_UINT64ZTYPE_FIXED64�_ConsumeUint64Z
TYPE_FLOATZTYPE_DOUBLE�ConsumeFloatZ	TYPE_BOOL�ConsumeBoolZTYPE_STRING�
ConsumeStringrr�ConsumeByteStringZ	TYPE_ENUM�ConsumeEnum�RuntimeErrorr^r_rRr�r�r�rer�r�r�r�rXrYr��setattr)rr�rrD�_rFZcan_check_presencerrrr�Us\












z_Parser._MergeScalarField)FFN)r
rrrrr�rwrNr}r�r�r�r��staticmethodr�r�rrrrr~Qs
:r~cCs8|jd�r,|jd�r,|jd�r,t|�nt|�dS)z}Skips over contents (value or message) of a field.

  Args:
    tokenizer: A tokenizer to parse the field name and values.
  r�rjrhN)r��	LookingAt�_SkipFieldValue�_SkipFieldMessage)r�rrrr��s
r�cCs^|jd�r6|j�x|jd�r(|j�qW|jd�n|j�t|�|jd�sZ|jd�dS)z�Skips over a complete field (name and value/message).

  Args:
    tokenizer: A tokenizer to parse the field name and values.
  rar�rbr�r�N)r�r�r�r�r�)r�rrr�
_SkipField�s

r�cCsR|jd�rd}n|jd�d}x$|jd�rB|jd�rBt|�q W|j|�dS)zfSkips over a field message.

  Args:
    tokenizer: A tokenizer to parse the field name and values.
  rhrirjrkN)r�r�r�r�)r�Z	delimiterrrrr��s

r�cCsT|j�rx|j�rq
WdS|j�rPt|�rPt|�rP|j�rPtd|j��dS)z�Skips over a field value.

  Args:
    tokenizer: A tokenizer to parse the field name and values.

  Raises:
    ParseError: In case an invalid field value is found.
  NzInvalid field value: )�TryConsumeByteString�TryConsumeIdentifier�_TryConsumeInt64�_TryConsumeUint64�TryConsumeFloatr�token)r�rrrr��s


r�c@sHeZdZdZejd�Zejdej�Zejdej�Z	ejdj
ddgdd	�eD���Zejd
�Z
ejd�ZdEd
d�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�ZdFd*d+�Zd,d-�Zd.d/�Zd0d1�Z d2d3�Z!d4d5�Z"d6d7�Z#d8d9�Z$d:d;�Z%d<d=�Z&d>d?�Z'd@dA�Z(dBdC�Z)dDS)Gr�z�Protocol buffer text representation tokenizer.

  This class handles the lower level string parsing by splitting it into
  meaningful tokens.

  It was directly ported from the Java protocol buffer API.
  z\s+z	(\s*#.*$)z(\s|(#.*$))+�|z[a-zA-Z_][0-9a-zA-Z_+-]*z#([0-9+-]|(\.[0-9]))[0-9a-zA-Z_.+-]*cCsg|]}dj|d��qS)z!{qt}([^{qt}\n\\]|\\.)*({qt}|\\?$))Zqt)r)�.0Zmarkrrr�
<listcomp>�szTokenizer.<listcomp>z
[^\d\W]\w*z\w+TcCsld|_d|_d|_d|_d|_t|�|_d|_d|_d|_	d|_
||_|rP|jpT|j
|_|j�|j�dS)Nr��T���)Z	_positionrrZ_token_startr��iter�_lines�
_current_line�_previous_line�_previous_column�_more_lines�_skip_comments�_WHITESPACE_OR_COMMENT�_WHITESPACE�_whitespace_pattern�_SkipWhitespace�	NextToken)rrZ
skip_commentsrrrrs

zTokenizer.__init__cCs
|j|kS)N)r�)rr�rrrr�szTokenizer.LookingAtcCs|jS)z^Checks the end of the text was reached.

    Returns:
      True iff the end was reached.
    )r�)rrrrr�szTokenizer.AtEndcCs`xZt|j�|jkrZyt|j�|_Wn tk
rBd|_d|_dSX|jd7_d|_qWdS)Nr�Fr�r)�lenr�r�nextr��
StopIterationr�r)rrrr�_PopLine szTokenizer._PopLinecCsFx@|j�|jj|j|j�}|s"Pt|jd��}|j|7_qWdS)Nr)r�r��matchr�rr��group)rr�Zlengthrrrr�,szTokenizer._SkipWhitespacecCs|j|kr|j�dSdS)z�Tries to consume a given piece of text.

    Args:
      token: Text to consume.

    Returns:
      True iff the text was consumed.
    TF)r�r�)rr�rrrr�5s	
zTokenizer.TryConsumecCs|j|�s|jd|��dS)z�Consumes a piece of text.

    Args:
      token: Text to consume.

    Raises:
      ParseError: If the text couldn't be consumed.
    zExpected "%s".N)r�r)rr�rrrr�Cs	
zTokenizer.ConsumecCs(|j}|jj|�s|jd��|j�|S)NzExpected comment.)r��_COMMENTr�rr�)rr>rrr�ConsumeCommentOs

zTokenizer.ConsumeCommentcCs:|jdko|jdk}|j}|j�}|j|ko0|}||fS)zCConsumes a comment, returns a 2-tuple (trailing bool, comment str).r)rrr�r�)rZjust_startedZbefore_parsingZcommentZtrailingrrr�ConsumeCommentOrTrailingCommentVs
z)Tokenizer.ConsumeCommentOrTrailingCommentcCs&y|j�dStk
r dSXdS)NTF)r�r)rrrrr�fs
zTokenizer.TryConsumeIdentifiercCs(|j}|jj|�s|jd��|j�|S)z�Consumes protocol message field identifier.

    Returns:
      Identifier string.

    Raises:
      ParseError: If an identifier couldn't be consumed.
    zExpected identifier.)r��_IDENTIFIERr�rr�)rr>rrrr�ms
	
zTokenizer.ConsumeIdentifiercCs&y|j�dStk
r dSXdS)NTF)r�r)rrrr�TryConsumeIdentifierOrNumber|s
z&Tokenizer.TryConsumeIdentifierOrNumbercCs,|j}|jj|�s |jd|��|j�|S)z�Consumes protocol message field identifier.

    Returns:
      Identifier string.

    Raises:
      ParseError: If an identifier couldn't be consumed.
    z&Expected identifier or number, got %s.)r��_IDENTIFIER_OR_NUMBERr�rr�)rr>rrrr��s
	z#Tokenizer.ConsumeIdentifierOrNumbercCs&y|j�dStk
r dSXdS)NTF)�ConsumeIntegerr)rrrr�TryConsumeInteger�s
zTokenizer.TryConsumeIntegerFcCsPyt|j|d�}Wn0tk
rB}z|jt|���WYdd}~XnX|j�|S)z�Consumes an integer number.

    Args:
      is_long: True if the value should be returned as a long integer.
    Returns:
      The integer parsed.

    Raises:
      ParseError: If an integer couldn't be consumed.
    )�is_longN)�_ParseAbstractIntegerr��
ValueErrorrrr�)rr�r>�errrr��s zTokenizer.ConsumeIntegercCs&y|j�dStk
r dSXdS)NTF)r�r)rrrrr��s
zTokenizer.TryConsumeFloatcCsLyt|j�}Wn0tk
r>}z|jt|���WYdd}~XnX|j�|S)z�Consumes an floating point number.

    Returns:
      The number parsed.

    Raises:
      ParseError: If a floating point number couldn't be consumed.
    N)�
ParseFloatr�r�rrr�)rr>r�rrrr��s	 zTokenizer.ConsumeFloatcCsLyt|j�}Wn0tk
r>}z|jt|���WYdd}~XnX|j�|S)z�Consumes a boolean value.

    Returns:
      The bool parsed.

    Raises:
      ParseError: If a boolean value couldn't be consumed.
    N)�	ParseBoolr�r�rrr�)rr>r�rrrr��s	 zTokenizer.ConsumeBoolcCs&y|j�dStk
r dSXdS)NTF)r�r)rrrrr��s
zTokenizer.TryConsumeByteStringcCsF|j�}ytj|d�Stk
r@}z|j|��WYdd}~XnXdS)z�Consumes a string value.

    Returns:
      The string parsed.

    Raises:
      ParseError: If a string value couldn't be consumed.
    zutf-8N)r�r$r,�UnicodeDecodeError�_StringParseError)rZ	the_bytesr�rrrr��s
	zTokenizer.ConsumeStringcCs<|j�g}x&|jr0|jdtkr0|j|j��qWdj|�S)z�Consumes a byte array value.

    Returns:
      The array parsed (as a string).

    Raises:
      ParseError: If a byte array value couldn't be consumed.
    r�)�_ConsumeSingleByteStringr��_QUOTESr�r�)rZthe_listrrrr��s	
zTokenizer.ConsumeByteStringcCs�|j}t|�dks|dtkr.|jd|f��t|�dksJ|d|dkrZ|jd|f��ytj|dd��}Wn0tk
r�}z|jt|���WYdd}~XnX|j�|S)	aOConsume one token of a string literal.

    String literals (whether bytes or text) can come in multiple adjacent
    tokens which are automatically concatenated, like in C or Python.  This
    method only consumes one token.

    Returns:
      The token parsed.
    Raises:
      ParseError: When the wrong format data is found.
    r�rzExpected string but found: %rrlzString missing ending quote: %rNr�r�)	r�r�r�rrZ	CUnescaper�rr�)rryr>r�rrrr��s z"Tokenizer._ConsumeSingleByteStringcCsNyt||j�}Wn0tk
r@}z|jt|���WYdd}~XnX|j�|S)N)�	ParseEnumr�r�rrr�)rrDr>r�rrrr�s zTokenizer.ConsumeEnumcCst||jd|jd�S)z�Creates and *returns* a ParseError for the previously read token.

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

    Returns:
      A ParseError instance.
    r�)rr�r�)rrrrrr�s	z!Tokenizer.ParseErrorPreviousTokencCst||jd|jd�S)z9Creates and *returns* a ParseError for the current token.r�)rrr)rrrrrr%szTokenizer.ParseErrorcCs|jdt|��S)NzCouldn't parse string: )rr)rr�rrrr�)szTokenizer._StringParseErrorcCs�|j|_|j|_|jt|j�7_|j�|js<d|_dS|jj	|j
|j�}|rn|jrn|jj	|j
|j�}|r�|j
d�}||_n|j
|j|_dS)z Reads the next meaningful token.r�Nr)rr�rr�r�r�r�r��_TOKENr�r�r�r�r�)rr�r�rrrr�,s
zTokenizer.NextTokenN)T)F)*r
rrr�re�compiler��	MULTILINEr�r�r�r�r�r�r�rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr�r�rrrrr��sJ



	
r�cCst|ddd�S)z�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_signedr�)�_ConsumeInteger)r�rrrr�Fsr�cCst|ddd�S)z�Consumes an unsigned 32bit integer number from tokenizer.

  Args:
    tokenizer: A tokenizer used to parse the number.

  Returns:
    The integer parsed.

  Raises:
    ParseError: If an unsigned 32bit integer couldn't be consumed.
  F)r�r�)r�)r�rrrr�Usr�cCs&yt|�dStk
r dSXdS)NTF)r�r)r�rrrr�ds
r�cCst|ddd�S)z�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.
  T)r�r�)r�)r�rrrr�lsr�cCs&yt|�dStk
r dSXdS)NTF)r�r)r�rrrr�{s
r�cCst|ddd�S)z�Consumes an unsigned 64bit integer number from tokenizer.

  Args:
    tokenizer: A tokenizer used to parse the number.

  Returns:
    The integer parsed.

  Raises:
    ParseError: If an unsigned 64bit integer couldn't be consumed.
  FT)r�r�)r�)r�rrrr��sr�cCs,yt|||d�dStk
r&dSXdS)N)r�r�TF)r�r)r�r�r�rrr�_TryConsumeInteger�s
r�cCsRyt|j||d�}Wn0tk
rD}z|jt|���WYdd}~XnX|j�|S)aUConsumes an integer number from tokenizer.

  Args:
    tokenizer: A tokenizer used to parse the number.
    is_signed: True if a signed integer must be parsed.
    is_long: True if a long integer must be parsed.

  Returns:
    The integer parsed.

  Raises:
    ParseError: If an integer with given characteristics couldn't be consumed.
  )r�r�N)r�r�r�rrr�)r�r�r�r>r�rrrr��s r�cCs2t||d�}tdt|�t|�}|j|�|S)aParses an integer.

  Args:
    text: The text to parse.
    is_signed: True if a signed integer must be parsed.
    is_long: True if a long integer must be parsed.

  Returns:
    The integer value.

  Raises:
    ValueError: Thrown Iff the text is not a valid integer.
  )r�rl)r��_INTEGER_CHECKERS�intZ
CheckValue)ryr�r�r>Zcheckerrrrr��s
r�cCsBy|rt|d�St|d�SWn tk
r<td|��YnXdS)aParses an integer without checking size/signedness.

  Args:
    text: The text to parse.
    is_long: True if the value should be returned as a long integer.

  Returns:
    The integer value.

  Raises:
    ValueError: Thrown Iff the text is not a valid integer.
  rzCouldn't parse integer: %sN)�longr�r�)ryr�rrrr��s
r�cCs�yt|�Stk
r�tj|�r@|ddkr6td�Std�SnBtj|�rRtd�Syt|jd��Stk
r�td|��YnXYnXdS)	z�Parse a floating point number.

  Args:
    text: Text to parse.

  Returns:
    The number parsed.

  Raises:
    ValueError: If a floating point number couldn't be parsed.
  r�-z-inf�inf�nan�fzCouldn't parse float: %sN)�floatr��_FLOAT_INFINITYr��
_FLOAT_NANr3)ryrrrr��s


r�cCs$|d
krdS|dkrd
Std��dS)z�Parse a boolean value.

  Args:
    text: Text to parse.

  Returns:
    Boolean values parsed

  Raises:
    ValueError: If text is not a valid boolean.
  rm�t�1�TrueTrnr��0�FalseFzExpected "true" or "false".N)rmr�r�r�)rnr�r�r)r�)ryrrrr�s
r�cCs�|j}yt|d�}Wn<tk
rP|jj|d�}|dkrLtd|j|f��YnFXt|jd�rn|jjdkrn|S|j	j|d�}|dkr�td|j|f��|j
S)a&Parse an enum value.

  The value can be specified by a number (the enum value), or by
  a string literal (the enum name).

  Args:
    field: Enum field descriptor.
    value: String value.

  Returns:
    Enum value number.

  Raises:
    ValueError: If the enum value could not be parsed.
  rNz%Enum type "%s" has no value named %s.r�r�z+Enum type "%s" has no value with number %d.)ror�r�Zvalues_by_namerqrYr��filer�rprS)rDrFZenum_descriptorrSrtrrrr�s r�)r
r)	FFFFNFNrN)	rFFFFNFNN)rFFFFNN)rFFFFNN)FFN)FFN)FFN)FFN)FF)FF)FF)F)Br�
__author__r&r�r$rur�r�Zgoogle.protobuf.internalrrHrr�__all__ZUint32ValueCheckerZInt32ValueCheckerZUint64ValueCheckerZInt64ValueCheckerr�r��
IGNORECASEr�r��	frozensetr@Z
CPPTYPE_FLOATZCPPTYPE_DOUBLErsr�rZ�	Exceptionrr�objectr#rrErrrrKr2r|r	rwr}r~r�r�r�r�r�Z
_Tokenizerr�r�r�r�r�r�r�r�r�r�r�r�r�rrrr�<module>)s�

+




K
/
#

LW