
    @R<iP                     f   d Z dZddlZddlmZ ddlZddlZddlmZ ddl	Z	ddl
Z
ddlmZ ddlmZ ddlmZ d	Z eej$                  j&                  ej$                  j(                  ej$                  j*                  ej$                  j,                  g      Z eej$                  j*                  ej$                  j,                  g      Z eej$                  j2                  ej$                  j4                  g      Zd
ZdZdZ e	j>                  d      Z  e	j>                  d      Z! G d de"      Z# G d de#      Z$ G d de#      Z%	 	 	 	 	 	 	 	 d0dZ&	 	 	 	 	 d1dZ'd Z( G d de)      Z*d Z+d Z,d Z-	 	 	 d2dZ.	 	 	 d2dZ/e0e1fZ2 G d d e)      Z3d3d!Z4d" Z5d# Z6d$ Z7d%d&gd'd(gd'd(gd)d*gd+d,gd'd(gd-d.gd/Z8y)4at  Contains routines for printing protocol messages in JSON format.

Simple usage example:

  # Create a proto object and serialize it to a json format string.
  message = my_proto_pb2.MyMessage(foo='bar')
  json_string = json_format.MessageToJson(message)

  # Parse a json format string to proto object.
  message = json_format.Parse(json_string, my_proto_pb2.MyMessage())
zjieluo@google.com (Jie Luo)    N)OrderedDict)methodcaller)type_checkers)
descriptor)symbol_databasez%Y-%m-%dT%H:%M:%SInfinityz	-InfinityNaNu.   [-](?![-])|(?<![-])[-]z\[[a-zA-Z0-9\._]*\]$c                       e Zd ZdZy)Errorz'Top-level module error for json_format.N__name__
__module____qualname____doc__     \/var/www/html/delta-backend/venv/lib/python3.12/site-packages/google/protobuf/json_format.pyr   r   N   s    /r   r   c                       e Zd ZdZy)SerializeToJsonErrorz&Thrown if serialization to JSON fails.Nr   r   r   r   r   r   R   s    .r   r   c                       e Zd ZdZy)
ParseErrorz Thrown in case of parsing error.Nr   r   r   r   r   r   V   s    (r   r   c	                 J    t        |||||      }	|	j                  | |||      S )a  Converts protobuf message to JSON format.

  Args:
    message: The protocol buffers message instance to serialize.
    including_default_value_fields: If True, singular primitive fields,
        repeated fields, and map fields will always be serialized.  If
        False, only serialize non-empty fields.  Singular message fields
        and oneof fields are not affected by this option.
    preserving_proto_field_name: If True, use the original proto field
        names as defined in the .proto file. If False, convert the field
        names to lowerCamelCase.
    indent: The JSON object will be pretty-printed with this indent level.
        An indent level of 0 or negative will only insert newlines.
    sort_keys: If True, then the output will be sorted by field names.
    use_integers_for_enums: If true, print integers instead of enum names.
    descriptor_pool: A Descriptor Pool for resolving types. If None use the
        default.
    float_precision: If set, use this to specify float field valid digits.
    ensure_ascii: If True, strings with non-ASCII characters are escaped.
        If False, Unicode strings are returned unchanged.

  Returns:
    A string containing the JSON formatted protocol buffer message.
  float_precision)_PrinterToJsonString)
messageincluding_default_value_fieldspreserving_proto_field_nameindent	sort_keysuse_integers_for_enumsdescriptor_poolr   ensure_asciiprinters
             r   MessageToJsonr&   Z   s7    D $!%'' 
		gvy,	GGr   c                 D    t        |||||      }|j                  |       S )a  Converts protobuf message to a dictionary.

  When the dictionary is encoded to JSON, it conforms to proto3 JSON spec.

  Args:
    message: The protocol buffers message instance to serialize.
    including_default_value_fields: If True, singular primitive fields,
        repeated fields, and map fields will always be serialized.  If
        False, only serialize non-empty fields.  Singular message fields
        and oneof fields are not affected by this option.
    preserving_proto_field_name: If True, use the original proto field
        names as defined in the .proto file. If False, convert the field
        names to lowerCamelCase.
    use_integers_for_enums: If true, print integers instead of enum names.
    descriptor_pool: A Descriptor Pool for resolving types. If None use the
        default.
    float_precision: If set, use this to specify float field valid digits.

  Returns:
    A dict representation of the protocol buffer message.
  r   )r   _MessageToJsonObject)r   r   r   r"   r#   r   r%   s          r   MessageToDictr)      s0    8 $!%'' 
	%	%g	..r   c                     | j                   t        j                  j                  k(  xr< | j                  j
                  xr$ | j                  j                         j                  S N)typer   FieldDescriptorTYPE_MESSAGEmessage_typehas_options
GetOptions	map_entry)fields    r   _IsMapEntryr4      sP    
**
22??
? 4



(
(4



'
'
)
3
35r   c                   ^    e Zd ZdZ	 	 	 	 	 ddZd Zd Zd Zd Zd Z	d	 Z
d
 Zd Zd Zd Zy)r   z)JSON format printer for protocol message.Nc                 |    || _         || _        || _        || _        |rdj	                  |      | _        y d | _        y )Nz.{}g)r   r   r"   r#   formatfloat_format)selfr   r   r"   r#   r   s         r   __init__z_Printer.__init__   sA     +ID''BD$"8D*D --8ddr   c                 V    | j                  |      }t        j                  ||||      S )N)r    r!   r$   )r(   jsondumps)r9   r   r    r!   r$   jss         r   r   z_Printer.ToJsonString   s.    		"	"7	+B::
6Y\K Kr   c                     |j                   }|j                  }t        |      r| j                  |      S |t        v r t        t        |   d   |      |       S i }| j                  ||      S )zEConverts message to an object according to Proto3 JSON Specification.r   )
DESCRIPTOR	full_name_IsWrapperMessage_WrapperMessageToJsonObject_WKTJSONMETHODSr   _RegularMessageToJsonObject)r9   r   message_descriptorrA   r>   s        r   r(   z_Printer._MessageToJsonObject   sq     ++",,I+,--g66O#A\/)4Q7A$GG	B++GR88r   c                    |j                         }	 |D ]+  \  }}| j                  r|j                  }n|j                  }t	        |      rc|j
                  j                  d   }i }|D ]=  }	t        |	t              r|	rd}
nd}
nt        |	      }
| j                  |||	         ||
<   ? |||<   |j                  t        j                  j                  k(  r$|D cg c]  }| j                  ||       c}||<   |j                  r&d|j                   z  }| j                  ||      ||<   | j                  ||      ||<   . | j"                  r|j$                  }|j&                  D ]  }|j                  t        j                  j                  k7  r'|j(                  t        j                  j*                  k(  s|j,                  r^| j                  r|j                  }n|j                  }||v rt	        |      ri ||<   |j                  t        j                  j                  k(  rg ||<   | j                  ||j.                        ||<    |S c c}w # t0        $ r*}t3        dj5                  j                  |            d}~ww xY w)z?Converts normal message according to Proto3 JSON Specification.valuetruefalsez[%s]z#Failed to serialize {0} field: {1}.N)
ListFieldsr   name	json_namer4   r/   fields_by_name
isinstanceboolstr_FieldToJsonObjectlabelr   r-   LABEL_REPEATEDis_extensionrA   r   r@   fieldscpp_typeCPPTYPE_MESSAGEcontaining_oneofdefault_value
ValueErrorr   r7   )r9   r   r>   rV   r3   rH   rL   v_fieldjs_mapkeyrecorded_keykrF   es                 r   rE   z$_Printer._RegularMessageToJsonObject   sf   !F8G  ;,%++$$u&&55g>'& 	%c#t$%& Xl#'#:#:s$%F< 	% "T([[J66EEE  %& --eQ7 &"T(%//)$,,UE:"T(,,UE:"T(9;> 
	,	,$//'.. 	KE{{j88GGG~~!;!;!K!KK$$--::D??DRZBtH{{j88GGGBtH..ue6I6IJBtH%	K0 IG&>  G 
/
6
6uzz1
EG GGs+   CI I2EI I 	J%JJc                    |j                   t        j                  j                  k(  r| j	                  |      S |j                   t        j                  j
                  k(  r| j                  r|S |j                  j                  dk(  ry|j                  j                  j                  |d      }||j                  S |j                  j                  dk(  r|S t        d      |j                   t        j                  j                  k(  rM|j                   t        j                  j"                  k(  r$t%        j&                  |      j)                  d      S |S |j                   t        j                  j*                  k(  rt-        |      S |j                   t.        v rt1        |      S |j                   t2        v rt5        j6                  |      r|dk  rt8        S t:        S t5        j<                  |      rt>        S |j                   t        j                  j@                  k(  r@| jB                  rtE        tG        || jB                              S tI        jJ                  |      S |S )z<Converts field value according to Proto3 JSON Specification.google.protobuf.NullValueNproto3zKEnum field contains an integer value which can not mapped to an enum value.utf-8g        )&rW   r   r-   rX   r(   CPPTYPE_ENUMr"   	enum_typerA   values_by_numbergetrL   filesyntaxr   CPPTYPE_STRINGr,   
TYPE_BYTESbase64	b64encodedecodeCPPTYPE_BOOLrP   _INT64_TYPESrQ   _FLOAT_TYPESmathisinf_NEG_INFINITY	_INFINITYisnan_NANCPPTYPE_FLOATr8   floatr7   r   ToShortestFloat)r9   r3   rH   
enum_values       r   rR   z_Printer._FieldToJsonObject  s   ~~33CCC&&u--	:55BB	B		$	$		"	"&A	A??3377tDj		::(," $L M 	M	:55DD	D	z11<<	<&--g66	:55BB	B%[	<	'Z	<	'	E	3;

	E		:55CC	CveT%6%678
8..u5
5Lr   c                    |j                         si S t               }|j                  }||d<   t        || j                        }|j                  |j                         |j                  }|j                  }t        |      r| j                  |      |d<   |S |t        v r! t        t        |   d   |      |       |d<   |S | j                  ||      S )z<Converts Any message according to Proto3 JSON Specification.@typerH   r   )rK   r   type_url_CreateMessageFromTypeUrlr#   ParseFromStringrH   r@   rA   rB   rC   rD   r   rE   )r9   r   r>   r   sub_messagerF   rA   s          r   _AnyMessageToJsonObjectz _Printer._AnyMessageToJsonObject?  s    i	BHBwK+Hd6J6JKK.$//",,I+,44[AbkiO#.L!;A!>!,..24bki++K<<r   c                 "    |j                         S )z8Converts message according to Proto3 JSON Specification.)r   r9   r   s     r   _GenericMessageToJsonObjectz$_Printer._GenericMessageToJsonObjectT  s     !!r   c                    |j                  d      }||dk(  ry|dk(  r| j                  |j                        S |dk(  r|j                  }nt	        ||      }|j
                  j                  |   }| j                  ||      S )z>Converts Value message according to Proto3 JSON Specification.kindN
null_value
list_valuestruct_value)
WhichOneof_ListValueMessageToJsonObjectr   r   getattrr@   rN   rR   )r9   r   whichrH   oneof_descriptors        r   _ValueMessageToJsonObjectz"_Printer._ValueMessageToJsonObjectZ  s    v&E }-//0B0BCC""egu%e))88?""#3U;;r   c                 ^    |j                   D cg c]  }| j                  |       c}S c c}w )zBConverts ListValue message according to Proto3 JSON Specification.)valuesr   )r9   r   rH   s      r   r   z&_Printer._ListValueMessageToJsonObjectj  s3     !) **51 ) ) )s   *c                 ^    |j                   }i }|D ]  }| j                  ||         ||<    |S )z?Converts Struct message according to Proto3 JSON Specification.)rV   r   )r9   r   rV   retr^   s        r   _StructMessageToJsonObjectz#_Printer._StructMessageToJsonObjecto  s<    ^^F
C =//s<c#h=Jr   c                 h    | j                  |j                  j                  d   |j                        S )NrH   )rR   r@   rN   rH   r   s     r   rC   z$_Printer._WrapperMessageToJsonObjectw  s1    ""))'2GMMC Cr   FFFNN)r   r   r   r   r:   r   r(   rE   rR   r   r   r   r   r   rC   r   r   r   r   r      sQ    1 &+"'" K
	9>@)V=*"< )
Cr   r   c                 4    | j                   j                  dk(  S )Nzgoogle/protobuf/wrappers.proto)rj   rL   )rF   s    r   rB   rB   |  s    		 	 	%	%)I	IIr   c                 d    i }| D ](  \  }}||v rt        dj                  |            |||<   * |S )Nz'Failed to load JSON: duplicate key {0}.)r   r7   )r>   resultrL   rH   s       r   _DuplicateCheckerr     sH    & kdEv~@GGMNNF4L 
-r   c                    t        j                         }||j                  n|}| j                  d      d   }	 |j	                  |      }|j                  |      } |       S # t
        $ r t        dj                  |             w xY w)z"Creates a message from a type URL./z0Can not find message descriptor by type_url: {0})	r   DefaultpoolsplitFindMessageTypeByNameKeyError	TypeErrorr7   GetPrototype)r   r#   dbr   	type_namerF   message_classs          r   r   r     s     "#+$nnS!"%)M33I> //"45-		 
 M
:AA(KM MMs   A# #$Bc                    t        | t              s| j                  d      } 	 t        j                  | t
              }t        |||||      S # t        $ r(}t        dj                  t        |                  d}~ww xY w)al  Parses a JSON representation of a protocol message into a message.

  Args:
    text: Message JSON representation.
    message: A protocol buffer message to merge into.
    ignore_unknown_fields: If True, do not raise errors for unknown fields.
    descriptor_pool: A Descriptor Pool for resolving types. If None use the
      default.
    max_recursion_depth: max recursion depth of JSON message to be
      deserialized. JSON messages over this depth will fail to be
      deserialized. Default value is 100.

  Returns:
    The same message passed as argument.

  Raises::
    ParseError: On JSON parsing problems.
  re   )object_pairs_hookzFailed to load JSON: {0}.N)
rO   rQ   rp   r<   loadsr   r[   r   r7   	ParseDict)textr   ignore_unknown_fieldsr#   max_recursion_depthr>   ra   s          r   Parser     s}    . 
D#	;;wDA	D,=	>B 
2w 5&
( ( 
 A
077A?
@@As   A 	A>#A99A>c                 F    t        |||      }|j                  | |d       |S )a8  Parses a JSON dictionary representation into a message.

  Args:
    js_dict: Dict representation of a JSON message.
    message: A protocol buffer message to merge into.
    ignore_unknown_fields: If True, do not raise errors for unknown fields.
    descriptor_pool: A Descriptor Pool for resolving types. If None use the
      default.
    max_recursion_depth: max recursion depth of JSON message to be
      deserialized. JSON messages over this depth will fail to be
      deserialized. Default value is 100.

  Returns:
    The same message passed as argument.
   )_ParserConvertMessage)js_dictr   r   r#   r   parsers         r   r   r     s+    ( (/;NO&"-	.r   c                   L    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zy)r   z(JSON format parser for protocol message.c                 <    || _         || _        || _        d| _        y )Nr   )r   r#   r   recursion_depth)r9   r   r#   r   s       r   r:   z_Parser.__init__  s"    !6D*D2DDr   c                    | xj                   dz  c_         | j                   | j                  kD  r$t        dj                  | j                              |j                  }|j
                  }|s|j                  }t        |      r| j                  |||       n:|t        v r t        t        |   d   |||      |        n| j                  |||       | xj                   dz  c_         y)a  Convert a JSON object into a message.

    Args:
      value: A JSON object.
      message: A WKT or regular protocol message to record the data.
      path: parent path to log parse error info.

    Raises:
      ParseError: In case of convert problems.
       z,Message too deep. Max recursion depth is {0}N)r   r   r   r7   r@   rA   rL   rB   _ConvertWrapperMessagerD   r   _ConvertFieldValuePair)r9   rH   r   pathrF   rA   s         r   r   z_Parser.ConvertMessage  s     	Ad666ELL

"
"$ % % ++",,I$$d+,
!!%$7	o	%Gl?9-a0%$GM
!!%$7Ar   c                    g }|j                   }t        d |j                  D              }|D ]  }	 |j                  |d      }|s|j                  j                  |d      }|st
        j                  |      r|j                  s%t        dj                  |j                  |            |dd }	|j                  j                  |	      }|s>dj                  |	j                  d      dd       }	|j                  j                  |	      }|sV| j                  rt        dj                  |j                  |||j                  D 
cg c]  }
|
j                    c}
            ||v r0t        dj                  |j                   j                  ||            |j#                  |       ||   }|j$                  ]|[|j$                  j&                  }||v r0t        d	j                  |j                   j                  ||            |j#                  |       ||j(                  t*        j,                  j.                  k(  r7|j0                  j                  d
k(  rt3        ||j&                        }d|_        ns|j(                  t*        j,                  j6                  k(  r1|j8                  j                  dk(  rt;        ||j&                  d       n|j=                  |j&                         t?        |      rA|j=                  |j&                         | jA                  |||dj                  ||             n|jB                  t*        j,                  jD                  k(  ru|j=                  |j&                         tG        |tH              st        dj                  |||            |j(                  t*        j,                  j.                  k(  rtK        |      D ]  \  }}t3        ||j&                        jM                         }|5|j                   j                  d
k7  rt        dj                  |||            | jO                  ||dj                  |||              nitK        |      D ]d  \  }}|t        dj                  |||            t3        ||j&                        j#                  tQ        ||dj                  |||                   f n|j(                  t*        j,                  j.                  k(  rf|jR                  r|j                  |   }nt3        ||j&                        }|jU                          | jO                  ||dj                  ||             ni|jR                  r+tQ        ||dj                  ||            |j                  |<   n2t;        ||j&                  tQ        ||dj                  ||                    yc c}
w # t        $ rB}r'|j$                  t        dj                  ||            t        tW        |            d}~wtX        $ r }t        dj                  ||            d}~wtZ        $ r }t        dj                  ||            d}~ww xY w)a'  Convert field value pairs into regular message.

    Args:
      js: A JSON object to convert the field value pairs.
      message: A regular protocol message to record the data.
      path: parent path to log parse error info.

    Raises:
      ParseError: In case of problems converting.
    c              3   8   K   | ]  }|j                   |f  y wr+   )rM   ).0fs     r   	<genexpr>z1_Parser._ConvertFieldValuePair.<locals>.<genexpr>  s#      C#$ !"Q/ Cs   Nz0Message type {0} does not have extensions at {1}r   r   .zaMessage type "{0}" has no field named "{1}" at "{2}".
 Available Fields(except extensions): "{3}"zBMessage type "{0}" should not have multiple "{1}" fields at "{2}".zHMessage type "{0}" should not have multiple "{1}" oneof fields at "{2}".google.protobuf.Valuer   rc   {0}.{1}z4repeated field {0} must be in [] which is {1} at {2}zPnull is not allowed to be used as an element in a repeated field at {0}.{1}[{2}]z{0}.{1}[{2}]zFailed to parse {0} field: {1}.).r@   dictrV   ri   rN   _VALID_EXTENSION_NAMEmatchis_extendabler   r7   rA   
Extensions_FindExtensionByNamejoinr   r   rM   appendrY   rL   rW   r   r-   rX   r/   r   r   rf   rg   setattr
ClearFieldr4   _ConvertMapFieldValuerS   rT   rO   list	enumerateaddr   _ConvertScalarFieldValuerU   SetInParentrQ   r[   r   )r9   r>   r   r   namesrF   fields_by_json_namerL   r3   
identifierr   rH   
oneof_namer   indexitemra   s                    r   r   z_Parser._ConvertFieldValuePair  s    E ++ C(:(A(AC C qLpL#''d3$3377dC%.44T:#11BII&00$89 9 Abz*$$99*E% *"2"23"7"<=J&&;;JGE''=>Df%//t);)B)BCAAKKC?EF F
 5= 44:F&11;;T45IJ J 	T4!!-%2C--22*5  <<BF!(!3!3!=!=z!%='( ( ,,z
"=nn
 : : J JJ$$..2II!'5::6K%&K"*"<"<"I"IIOO--1LLGUZZ+uzz*
 u


UZZ
(

$
$UGU%.%5%5dD%AC[[J66EEE


UZZ
(E4( **0&ud*CE E^^z99III(/ 	Lt#GUZZ8<<>k,((226MM  "HHN%)4I89 9 !!$"0"7"7dE"JL	L  )/ Nt  "HHN%)4I89 9 guzz*11*E>#8#8tU#KMNN ^^z99III!,,U3K!'5::6K

!
!
#


e[)2B2B42N
O(@ui..tT:)<Gu% ()2)9)9$)EGHKqL8 DZ  #U++3<CCD!LM
M3q6"
" L:AA$JKK L:AA$JKKLsP   C&W+WWFW*KWW	Y+=XY+$X??Y+Y&&Y+c           	      |   t        |t              r|sy	 |d   }	 t        || j                        }|j                  }|j                  }t        |      r&| j                  |d   |dj	                  |             nT|t        v r1 t        t        |   d   |d   |dj	                  |            |        n|d= | j                  |||       ||d<   |j                         |_        ||_        y# t        $ r t        dj	                  |            w xY w# t        $ r }t        dj	                  ||            d}~ww xY w)z/Convert a JSON representation into Any message.Nr   z0@type is missing when parsing any message at {0}
{0} at {1}rH   	{0}.valuer   )rO   r   r   r   r7   r   r#   r   r@   rA   rB   r   rD   r   r   SerializeToStringrH   r   )	r9   rH   r   r   r   r   ra   rF   rA   s	            r   _ConvertAnyMessagez_Parser._ConvertAnyMessage{  sP   %uKwh
5-h8L8LMk %//",,I+,
!!%.+"-"4"4T":<	o	%-l?9-a0%.+%%d+- .
!!%d;eGn113GMG/  K
<
C
CD
IK KK  5|**1d3445s"   C+ D +$D	D;D66D;c                     	 |j                  |       y# t        $ r }t        dj                  ||            d}~ww xY w)z?Convert a JSON representation into message with FromJsonString.r   N)FromJsonStringr[   r   r7   )r9   rH   r   r   ra   s        r   _ConvertGenericMessagez_Parser._ConvertGenericMessage  s=    5U# 5|**1d3445s    	=8=c                    t        |t              r| j                  ||j                  |       yt        |t              r| j                  ||j                  |       y|d|_        yt        |t              r||_	        yt        |t              r||_        yt        |t              r||_        yt        dj                  |t!        |      |            )z1Convert a JSON representation into Value message.Nr   z(Value {0} has unexpected type {1} at {2})rO   r   _ConvertStructMessager   r   _ConvertListValueMessager   r   rP   
bool_valuerQ   string_value_INT_OR_FLOATnumber_valuer   r7   r,   )r9   rH   r   r   s       r   _ConvertValueMessagez_Parser._ConvertValueMessage  s    %
  (<(<dC	E4	 
##E7+=+=tD	g	E4	  g	E3	"g	E=	)"gAHH
ed$ % %r   c           	         t        |t              st        dj                  ||            |j	                  d       t        |      D ]@  \  }}| j                  ||j                  j                         dj                  ||             B y)z5Convert a JSON representation into ListValue message.z+ListValue must be in [] which is {0} at {1}r   {0}[{1}]N)	rO   r   r   r7   r   r   r   r   r   )r9   rH   r   r   r   r   s         r   r   z _Parser._ConvertListValueMessage  s    eT"DKK
  x  ' @t
gnn&8&8&: * 1 1$ >@@r   c           	          t        |t              st        dj                  ||            |j	                          |D ]5  }| j                  ||   |j                  |   dj                  ||             7 y)z2Convert a JSON representation into Struct message.z,Struct must be in a dict which is {0} at {1}r   N)rO   r   r   r7   Clearr   rV   )r9   rH   r   r   r^   s        r   r   z_Parser._ConvertStructMessage  sz    eT"ELL
   MMO =
c
GNN3,? ) 0 0s ;== r   c                     |j                   j                  d   }t        |dt        ||dj	                  |                   y)z3Convert a JSON representation into Wrapper message.rH   r   r   N)r@   rN   r   r   r7   )r9   rH   r   r   r3   s        r   r   z_Parser._ConvertWrapperMessage  s=    --g6E K4F4Ft4LMOr   c           	      V   t        |t              s&t        dj                  |j                  ||            |j
                  j                  d   }|j
                  j                  d   }|D ]  }t        ||dj                  |      d      }|j                  t        j                  j                  k(  r>| j                  ||   t        ||j                        |   dj                  ||             t        ||   |dj                  ||            t        ||j                        |<    y)	af  Convert map field value for a message map field.

    Args:
      value: A JSON object to convert the map field value.
      message: A protocol message to record the converted data.
      field: The descriptor of the map field to be converted.
      path: parent path to log parse error info.

    Raises:
      ParseError: In case of convert problems.
    z3Map field {0} must be in a dict which is {1} at {2}r^   rH   z{0}.keyTr   r   N)rO   r   r   r7   rL   r/   rN   r   rW   r   r-   rX   r   r   )	r9   rH   r   r3   r   	key_fieldvalue_fieldr^   	key_values	            r   r   z_Parser._ConvertMapFieldValue  s    eT"
?
F
Fjj%'( ( ""11%8I$$33G<K 	N*3	+4+;+;D+A4Ii			!;!;!K!K	KE#J#GUZZ8C&--dI>	@ 3K#J**;*;D)*L3N$Y/	Nr   N)r   r   r   r   r:   r   r   r   r   r   r   r   r   r   r   r   r   r   r     s=    06@LD >5%$@ONr   r   c                    	 |j                   t        v rt        |       S |j                   t        v rt	        | |      S |j                   t
        j                  j                  k(  rt        | |      S |j                   t
        j                  j                  k(  r|j                  t
        j                  j                  k(  rPt        | t              r| j                  d      }n| }|ddt        |      dz  z
  z  z   }t!        j"                  |      S t$        j'                  |       rt)        d      | S |j                   t
        j                  j*                  k(  r|j,                  j.                  j1                  | d      }|~	 t3        |       }|j,                  j4                  j1                  |d      }|J|j<                  j>                  dk(  r|S t)        dj9                  | |j,                  j:                              |j@                  S y# t6        $ r0 t)        dj9                  | |j,                  j:                              w xY w# t(        $ r }t)        dj9                  ||            d}~ww xY w)	aq  Convert a single scalar field value.

  Args:
    value: A scalar value to convert the scalar field value.
    field: The descriptor of the field to convert.
    path: parent path to log parse error info.
    require_str: If True, the field value must be a str.

  Returns:
    The converted scalar field value

  Raises:
    ParseError: In case of convert problems.
  re      =   zUnpaired surrogateNz(Invalid enum value {0} for enum type {1}rd   r   )!rW   
_INT_TYPES_ConvertIntegerrs   _ConvertFloatr   r-   rq   _ConvertBoolrl   r,   rm   rO   rQ   encodelenrn   urlsafe_b64decode_UNPAIRED_SURROGATE_PATTERNsearchr   rf   rg   values_by_nameri   intrh   r[   r7   rA   rj   rk   number)	rH   r3   r   require_strencodedpadded_valuer}   r  ra   s	            r   r   r     s   (3~~#U##	<	'5%((	:55BB	B%--	:55DD	D	z11<<	<eS!LL)''S\A-=)=!>>''55 '--e4/0
0	:55BB	B??1155eTBj			1u:&77;;FDI* ZZ(*MELLU__..0 1 1! 
C  	1ELLU__..0 1 1	1 
 3
\((D1
223sS   I I 2I 0BI !I 0AI  1H
 1I :I 
9II 	I/I**I/c                 \   t        | t              r*| j                         st        dj	                  |             t        | t
              r.| j                  d      dk7  rt        dj	                  |             t        | t              rt        dj	                  |             t        |       S )zConvert an integer.

  Args:
    value: A scalar value to convert.

  Returns:
    The integer value.

  Raises:
    ParseError: If an integer couldn't be consumed.
  zCouldn't parse integer: {0} r   zCouldn't parse integer: "{0}"z2Bool value {0} is not acceptable for integer field)	rO   r{   
is_integerr   r7   rQ   findrP   r  )rH   s    r   r   r   +  s     ue&6&6&8
3::5A
BBs

32 5
5<<UC
DDt
 %%+VE]4 4 
Ur   c                    t        | t              rt        j                  |       rt	        d      t        j
                  |       r| dkD  rt	        d      t	        d      |j                  t        j                  j                  k(  r<| t        j                  kD  rt	        d      | t        j                  k  rt	        d      | dk(  rt	        d      	 t        |       S # t        $ r] | t        k(  rt        d	      cY S | t        k(  rt        d
      cY S | t         k(  rt        d      cY S t	        dj#                  |             w xY w)z!Convert an floating point number.z,Couldn't parse NaN, use quoted "NaN" insteadr   zICouldn't parse Infinity or value too large, use quoted "Infinity" insteadzKCouldn't parse -Infinity or value too small, use quoted "-Infinity" insteadzFloat value too largezFloat value too smallnanz-Couldn't parse float "nan", use "NaN" insteadz-infinfzCouldn't parse float: {0})rO   r{   rt   rx   r   ru   rW   r   r-   rz   r   
_FLOAT_MAX
_FLOAT_MINr[   rv   rw   ry   r7   )rH   r3   s     r   r   r   D  s)   uzz%FGGzz%	 9 : 	:  : ; 	;~~33AAA	))	)011	))	)011
e^
E
FFC<	 	C6]	)	5\	$5\3::5ABB	Cs   
C   E?EE+Ec                     |r&| dk(  ry| dk(  ryt        dj                  |             t        | t              st        d      | S )zConvert a boolean value.

  Args:
    value: A scalar value to convert.
    require_str: If True, value must be a str.

  Returns:
    The bool parsed.

  Raises:
    ParseError: If a boolean value couldn't be consumed.
  rI   TrJ   Fz#Expected "true" or "false", not {0}z%Expected true or false without quotes)r   r7   rO   rP   )rH   r  s     r   r   r   h  sN     	'	<CCEJKK	E4	 
<
==	,r   r   r   r   r   r   r   r   r   r   r   )zgoogle.protobuf.Anyzgoogle.protobuf.Durationzgoogle.protobuf.FieldMaskzgoogle.protobuf.ListValuezgoogle.protobuf.Structzgoogle.protobuf.Timestampr   )FF   FFNNTr   )FNd   )F)9r   
__author__rn   collectionsr   r<   rt   operatorr   resysgoogle.protobuf.internalr   google.protobufr   r   _TIMESTAMPFOMAT	frozensetr-   CPPTYPE_INT32CPPTYPE_UINT32CPPTYPE_INT64CPPTYPE_UINT64r   rr   rz   CPPTYPE_DOUBLErs   rw   rv   ry   compiler  r   	Exceptionr   r   r   r&   r)   r4   objectr   rB   r   r   r   r   r  r{   r   r   r   r   r   r   rD   r   r   r   <module>r(     sF  >
 +
  #   ! 	 
 2 & + &
22@@"22AA"22@@"22AAC D
 *44BB$44CCE F*44BB$44CCE F	(bjjMO  #

#:; 0I 0/5 /) ) $) % (HZ $) % #/L5HCv HCVJ  !&!	(F %*""%	2 eZNf ZNz73t2!CH4 602!>!9!;"?":"<"A"<">;68"?":"<946r   