
                         |   S r SrSSKrSSKJr  SSKrSSKrSSKJr  SSK	r	SSK
r
SSKJr  SSKJr  SSKJr  SS	KJr  S
r\" \R&                  R(                  \R&                  R*                  \R&                  R,                  \R&                  R.                  /5      r\" \R&                  R,                  \R&                  R.                  /5      r\" \R&                  R4                  \R&                  R6                  /5      rSrSrSr\	R@                  " S5      r!\	R@                  " S5      r" " S S\#5      r$ " S S\$5      r% " S S\$5      r&        S1S jr'     S2S jr(S r) " S S\*5      r+S r,S r-S r.   S3S jr/   S3S jr0\1\24r3 " S  S!\*5      r4S4S" jr5S# r6S$ r7S% r8S&S'/S(S)/S(S)/S*S+/S,S-/S(S)/S.S//S0.r9g)5at  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)message_factory)symbol_databasez%Y-%m-%dT%H:%M:%SInfinityz	-InfinityNaNu.   [-](?![-])|(?<![-])[-]z\[[a-zA-Z0-9\._]*\]$c                       \ rS rSrSrSrg)ErrorO   z'Top-level module error for json_format. N__name__
__module____qualname____firstlineno____doc____static_attributes__r       N/root/google-cloud-sdk/lib/third_party/cloudsdk/google/protobuf/json_format.pyr   r   O   s    /r   r   c                       \ rS rSrSrSrg)SerializeToJsonErrorS   z&Thrown if serialization to JSON fails.r   Nr   r   r   r   r   r   S   s    .r   r   c                       \ rS rSrSrSrg)
ParseErrorW   z Thrown in case of parsing error.r   Nr   r   r   r   r   r   W   s    (r   r   c	                 @    [        UUUUUS9n	U	R                  XXH5      $ )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. If the
      indent level is None, no newlines will be inserted.
  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,   [   s3    F $!%'' 
		gy	GGr   c                 >    [        UUUUUS9nUR                  U 5      $ )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                     U R                   [        R                  R                  :H  =(       aA    U R                  R
                  =(       a$    U R                  R                  5       R                  $ N)typer   FieldDescriptorTYPE_MESSAGEmessage_typehas_options
GetOptions	map_entry)fields    r   _IsMapEntryr:      sP    
**
22??
? 4



(
(4



'
'
)
3
35r   c                   h    \ rS rSrSr     SS jrS rS rS rS r	S	 r
S
 rS rS rS rS rSrg)r!      z)JSON format printer for protocol message.Nc                 ~    Xl         X l        X0l        X@l        U(       a  SR	                  U5      U l        g S U l        g )Nz.{}g)r$   r%   r(   r)   formatfloat_format)selfr$   r%   r(   r)   r    s         r   __init___Printer.__init__   s9     +I''B$"8* --8ddr   c                 N    U R                  U5      n[        R                  " XRX4S9$ )N)r&   r'   r*   )r.   jsondumps)r@   r#   r&   r'   r*   jss         r   r"   _Printer.ToJsonString   s*    		"	"7	+B::
YK Kr   c                     UR                   nUR                  n[        U5      (       a  U R                  U5      $ U[        ;   a  [        [        U   S   U5      " U 5      $ 0 nU R                  X5      $ )zEConverts message to an object according to Proto3 JSON Specification.r   )
DESCRIPTOR	full_name_IsWrapperMessage_WrapperMessageToJsonObject_WKTJSONMETHODSr   _RegularMessageToJsonObject)r@   r#   message_descriptorrJ   rF   s        r   r.   _Printer._MessageToJsonObject   sp     ++",,I+,,--g66O#/)4Q7A$GG	B++G88r   c                    UR                  5       n U GHD  u  pEU R                  (       a  UR                  nOUR                  n[	        U5      (       am  UR
                  R                  S   n0 nU HF  n	[        U	[        5      (       a  U	(       a  Sn
OSn
O[        U	5      n
U R                  XuU	   5      X'   MH     XU'   M  UR                  [        R                  R                  :X  a&  U Vs/ s H  nU R                  XK5      PM     snX&'   M  UR                  (       a%  SUR                   -  nU R                  XE5      X&'   GM1  U R                  XE5      X&'   GMG     U R"                  (       Ga  UR$                  nUR&                   H  nUR                  [        R                  R                  :w  a(  UR(                  [        R                  R*                  :X  d  UR,                  (       a  Mf  U R                  (       a  UR                  nOUR                  nXb;   a  M  [	        U5      (       a  0 X&'   M  UR                  [        R                  R                  :X  a  / X&'   M  U R                  XDR.                  5      X&'   M     U$ s  snf ! [0         a+  n[3        SR5                  WR                  U5      5      UeSnAff = f)z?Converts normal message according to Proto3 JSON Specification.valuetruefalsez[%s]z#Failed to serialize {0} field: {1}.N)
ListFieldsr%   name	json_namer:   r5   fields_by_name
isinstanceboolstr_FieldToJsonObjectlabelr   r3   LABEL_REPEATEDis_extensionrJ   r$   rI   fieldscpp_typeCPPTYPE_MESSAGEcontaining_oneofdefault_value
ValueErrorr   r>   )r@   r#   rF   r`   r9   rR   rV   v_fieldjs_mapkeyrecorded_keykrO   es                 r   rN   $_Printer._RegularMessageToJsonObject   sK   !F8N ,%++$$u&&55g>'&c#t$$%& Xl#'#:#:s$%F   T([[J66EEE  %&$! --e7$&"(%//)$,,U:"(,,U:"(9 !> 
	,	,	,$//'..E{{j88GGG~~!;!;!K!KK$$--::D??DZBH{{j88GGGBH..u6I6IJBH% /0 IG&>  N 
/
6
6uzz1
EGLMNNs+   CJ
 -JE;J
 J
 

J?&J::J?c                    UR                   [        R                  R                  :X  a  U R	                  U5      $ UR                   [        R                  R
                  :X  a  U R                  (       a  U$ UR                  R                  S:X  a  gUR                  R                  R                  US5      nUb  UR                  $ UR                  R                  (       a  [        S5      eU$ UR                   [        R                  R                  :X  aO  UR                  [        R                  R                   :X  a%  ["        R$                  " U5      R'                  S5      $ U$ UR                   [        R                  R(                  :X  a  [+        U5      $ UR                   [,        ;   a  [/        U5      $ UR                   [0        ;   a  [2        R4                  " U5      (       a  US:  a  [6        $ [8        $ [2        R:                  " U5      (       a  [<        $ UR                   [        R                  R>                  :X  aE  U R@                  (       a  [C        [E        X R@                  5      5      $ [F        RH                  " U5      $ U$ )z<Converts field value according to Proto3 JSON Specification.google.protobuf.NullValueNzKEnum field contains an integer value which can not mapped to an enum value.utf-8g        )%ra   r   r3   rb   r.   CPPTYPE_ENUMr(   	enum_typerJ   values_by_numbergetrV   	is_closedr   CPPTYPE_STRINGr2   
TYPE_BYTESbase64	b64encodedecodeCPPTYPE_BOOLrZ   _INT64_TYPESr[   _FLOAT_TYPESmathisinf_NEG_INFINITY	_INFINITYisnan_NANCPPTYPE_FLOATr?   floatr>   r   ToShortestFloat)r@   r9   rR   
enum_values       r   r\   _Printer._FieldToJsonObject  s   ~~33CCC&&u--	:55BB	B		$	$		"	"&A	A??3377tDj		??$$$ &N O O ,	: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ve%6%678
8..u5
5Lr   c                    UR                  5       (       d  0 $ [        5       nUR                  nX2S'   [        X0R                  5      nUR                  UR                  5        UR                  nUR                  n[        U5      (       a  U R                  U5      US'   U$ U[        ;   a!  [        [        U   S   U5      " U 5      US'   U$ U R                  XB5      $ )z<Converts Any message according to Proto3 JSON Specification.@typerR   r   )rU   r   type_url_CreateMessageFromTypeUrlr)   ParseFromStringrR   rI   rJ   rK   rL   rM   r   rN   )r@   r#   rF   r   sub_messagerO   rJ   s          r   _AnyMessageToJsonObject _Printer._AnyMessageToJsonObjectB  s    i	BHwK+H6J6JKK.$//",,I+,,44[AbkiO# !;A!>!,..24bki++K<<r   c                 "    UR                  5       $ )z8Converts message according to Proto3 JSON Specification.)r"   r@   r#   s     r   _GenericMessageToJsonObject$_Printer._GenericMessageToJsonObjectW  s     !!r   c                    UR                  S5      nUb  US:X  a  gUS:X  a  U R                  UR                  5      $ US:X  aY  UR                  n[        R
                  " U5      (       a  [        S5      e[        R                  " U5      (       a  [        S5      eO[        X5      nUR                  R                  U   nU R                  XC5      $ )z>Converts Value message according to Proto3 JSON Specification.kindN
null_value
list_valuenumber_valuezTFail to serialize Infinity for Value.number_value, which would parse as string_valuezOFail to serialize NaN for Value.number_value, which would parse as string_value)
WhichOneof_ListValueMessageToJsonObjectr   r   r}   r~   re   r   getattrrI   rX   r\   )r@   r#   whichrR   oneof_descriptors        r   _ValueMessageToJsonObject"_Printer._ValueMessageToJsonObject]  s    v&E }-//0B0BCC""e	E		 = > 	>	E		 = > 	> 
 g%e))88?""#3;;r   c                 d    UR                    Vs/ s H  nU R                  U5      PM     sn$ s  snf )zBConverts ListValue message according to Proto3 JSON Specification.)valuesr   )r@   r#   rR   s      r   r   &_Printer._ListValueMessageToJsonObjects  s8     !)' **51') ) )s   -c                 ^    UR                   n0 nU H  nU R                  X$   5      X4'   M     U$ )z?Converts Struct message according to Proto3 JSON Specification.)r`   r   )r@   r#   r`   retrh   s        r   _StructMessageToJsonObject#_Printer._StructMessageToJsonObjectx  s3    ^^F
C//<ch Jr   c                 h    U R                  UR                  R                  S   UR                  5      $ )NrR   )r\   rI   rX   rR   r   s     r   rL   $_Printer._WrapperMessageToJsonObject  s1    ""))'2GMMC Cr   )r)   r?   r$   r%   r(   FFFNN)r   r   r   r   r   rA   r"   r.   rN   r\   r   r   r   r   r   rL   r   r   r   r   r!   r!      sQ    1 &+"'" K
	9>@*X=*"<,)
Cr   r!   c                 4    U R                   R                  S:H  $ )Nzgoogle/protobuf/wrappers.proto)filerV   )rO   s    r   rK   rK     s    		 	 	%	%)I	IIr   c                 f    0 nU  H(  u  p#X!;   a  [        SR                  U5      5      eX1U'   M*     U$ )Nz'Failed to load JSON: duplicate key {0}.)r   r>   )rF   resultrV   rR   s       r   _DuplicateCheckerr     s=    &kd~@GGMNN4L  
-r   c                 .   [         R                  " 5       nUc  UR                  OUnU R                  S5      S   n UR	                  U5      n[        R                  " U5      nU" 5       $ ! [
         a   n[        SR                  U 5      5      UeSnAff = f)z"Creates a message from a type URL.N/z0Can not find message descriptor by type_url: {0})
r   DefaultpoolsplitFindMessageTypeByNameKeyError	TypeErrorr>   r   GetMessageClass)r   r)   dbr   	type_namerO   rk   message_classs           r   r   r     s     "#+$nnS!"%)33I>
 "112DE-	 
 
:AA(Ks   A* *
B4BBc                    [        U [        5      (       d  U R                  S5      n  [        R                  " U [
        S9n[        XQX#U5      $ ! [         a)  n[        SR                  [        U5      5      5      UeSnAff = f)aP  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.
ro   )object_pairs_hookzFailed to load JSON: {0}.N)
rY   r[   ry   rD   loadsr   re   r   r>   	ParseDict)textr#   ignore_unknown_fieldsr)   max_recursion_depthrF   rk   s          r   Parser     s~    . 
D#		;;wDH	D,=	>B 
2 5&
( ( 
 H
077A?
@aGHs   A 
B$A<<Bc                 B    [        X#U5      nUR                  XS5        U$ )a   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                   T    \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS rSrg)r   i  z(JSON format parser for protocol message.c                 6    Xl         X l        X0l        SU l        g )Nr   )r   r)   r   recursion_depth)r@   r   r)   r   s       r   rA   _Parser.__init__  s    !6*2Dr   c                    U =R                   S-  sl         U R                   U R                  :  a$  [        SR                  U R                  5      5      eUR                  nUR
                  nU(       d  UR                  n[        U5      (       a  U R                  XU5        O:U[        ;   a  [        [        U   S   XU5      " U 5        OU R                  XU5        U =R                   S-  sl         g)zConvert 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   r>   rI   rJ   rV   rK   _ConvertWrapperMessagerM   r   _ConvertFieldValuePair)r@   rR   r#   pathrO   rJ   s         r   r   _Parser.ConvertMessage  s     	Ad666ELL

"
"$ % % ++",,I$$d+,,
!!%$7	o	%?9-a0%$GM
!!%$7Ar   c                 t   / nUR                   n[        S UR                   5       5      nU GH  n UR                  US5      nU(       d  UR                  R                  US5      nU(       d  [
        R                  U5      (       a  UR                  (       d%  [        SR                  UR                  U5      5      eUSS n	UR                  R                  U	5      nU(       d>  SR                  U	R                  S5      SS 5      n	UR                  R                  U	5      nU(       d^  U R                  (       a  GM  [        SR                  UR                  XsUR                   V
s/ s H  oR                   PM     sn
5      5      eXt;   a/  [        SR                  UR                   R                  Xs5      5      eUR#                  U5        X   nUR$                  b_  Ub\  UR$                  R&                  nX;   a0  [        S	R                  UR                   R                  UU5      5      eUR#                  U5        Uc  UR(                  [*        R,                  R.                  :X  a7  UR0                  R                  S
:X  a  [3        X(R&                  5      nSUl        OtUR(                  [*        R,                  R6                  :X  a1  UR8                  R                  S:X  a  [;        X(R&                  S5        OUR=                  UR&                  5        GM  [?        U5      (       a@  UR=                  UR&                  5        U RA                  XUSR                  X75      5        GM9  URB                  [*        R,                  RD                  :X  Gaz  UR=                  UR&                  5        [G        U[H        5      (       d  [        SR                  X{U5      5      eUR(                  [*        R,                  R.                  :X  a  [K        U5       H  u  p[3        X(R&                  5      RM                  5       nUc5  UR                   R                  S
:w  a  [        SR                  X7U5      5      eU RO                  XSR                  X7U5      5        M     GMi  [K        U5       Ha  u  pUc  [        SR                  X7U5      5      e[3        X(R&                  5      R#                  [Q        XSR                  X7U5      5      5        Mc     GM  UR(                  [*        R,                  R.                  :X  aj  URR                  (       a  UR                  U   nO[3        X(R&                  5      nURU                  5         U RO                  XSR                  X75      5        GMn  URR                  (       a+  [Q        XSR                  X75      5      UR                  U'   GM  [;        X(R&                  [Q        XSR                  X75      5      5        GM     gs  sn
f ! [         aJ  nW(       a)  UR$                  c  [        SR                  UU5      5      Ue[        [W        U5      5      UeSnAf[X         a!  n[        SR                  UU5      5      UeSnAf[Z         a!  n[        SR                  UU5      5      UeSnAff = f)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   >   #    U  H  nUR                   U4v   M     g 7fr1   )rW   ).0fs     r   	<genexpr>1_Parser._ConvertFieldValuePair.<locals>.<genexpr>  s!      C(A1 !"Q/(As   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   rn   {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}.).rI   dictr`   rs   rX   _VALID_EXTENSION_NAMEmatchis_extendabler   r>   rJ   
Extensions_FindExtensionByNamejoinr   r   rW   appendrc   rV   ra   r   r3   rb   r5   r   r   rp   rq   setattr
ClearFieldr:   _ConvertMapFieldValuer]   r^   rY   list	enumerateaddr   _ConvertScalarFieldValuer_   SetInParentr[   re   r   )r@   rF   r#   r   namesrO   fields_by_json_namerV   r9   
identifierr   rR   
oneof_namer   indexitemrk   s                    r   r   _Parser._ConvertFieldValuePair  s    E ++ C(:(A(AC Cv#''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%//);)B)BC)BAKK)BC?EF F
 = 44:F&11;;T5IJ J 	T!!-%2C--22*  <<BF!(!3!3!=!=z!%='( ( ,,z
"=nn
 : : J JJ$$..2II!'::6K%&K"*"<"<"I"IIOO--1LLGZZ+uzz*
 u


UZZ
(

$
$UU%.%5%5d%AC[[J66EEE


UZZ
(E4(( **0&d*CE E^^z99III(/#GZZ8<<>k,((226MM  "HHN%)I89 9 !!$"0"7"7E"JL  0  )/  "HHN%)I89 9 gzz*11*>#8#8U#KMN  0 ^^z99III!,,U3K!'::6K

!
!
#


e)2B2B42N
O(@i..t:)<Gu% ()2)9)9$)EGHK 8 DZ  *U++3-44T1= 3q6"
) 
+
2
24
;
	  
+
2
24
;
	sr   D	X>*X(X=FXAX&D-XA0X	BX9X/XX
Z7AY  Z7-Z		Z7Z22Z7c                    [        U[        5      (       a  U(       d  g US   n [        X@R                  5      nUR                  nUR                  n[        U5      (       a&  U R                  US   USR	                  U5      5        OTU[        ;   a1  [        [        U   S   US   USR	                  U5      5      " U 5        OUS	 U R                  XU5        XAS'   UR                  5       Ul        XBl        g! [         a   n[        SR	                  U5      5      UeSnAff = f! [         a   n[        SR	                  XS5      5      UeSnAff = f)z/Convert a JSON representation into Any message.Nr   z0@type is missing when parsing any message at {0}
{0} at {1}rR   	{0}.valuer   )rY   r   r   r   r>   r   r)   r   rI   rJ   rK   r   rM   r   r   SerializeToStringrR   r   )	r@   rR   r#   r   r   rk   r   rO   rJ   s	            r   _ConvertAnyMessage_Parser._ConvertAnyMessage  sI   %uwh<-h8L8LMk %//",,I+,,
!!%.+"-"4"4T":<	o	%?9-a0%.+%%d+- .
!!%d;Gn113GM1  :AA$G  <|**134!;<s.   C8 D% 8
D"DD"%
E/E

Ec                      UR                  U5        g! [         a   n[        SR                  XC5      5      UeSnAff = f)z?Convert a JSON representation into message with FromJsonString.r   N)FromJsonStringre   r   r>   )r@   rR   r#   r   rk   s        r   _ConvertGenericMessage_Parser._ConvertGenericMessage  s=    <U# <|**134!;<s    
>9>c                    [        U[        5      (       a  U R                  XR                  U5        g[        U[        5      (       a  U R                  XR                  U5        gUc  SUl        g[        U[        5      (       a  Xl	        g[        U[        5      (       a  Xl        g[        U[        5      (       a  Xl        g[        SR                  U[!        U5      U5      5      e)z1Convert a JSON representation into Value message.Nr   z(Value {0} has unexpected type {1} at {2})rY   r   _ConvertStructMessagestruct_valuer   _ConvertListValueMessager   r   rZ   
bool_valuer[   string_value_INT_OR_FLOATr   r   r>   r2   )r@   rR   r#   r   s       r   _ConvertValueMessage_Parser._ConvertValueMessage  s    %
  (<(<dC	E4	 	 
##E+=+=tD	g	E4	 	  	E3		"	E=	)	)"AHH
ed$ % %r   c           	         [        U[        5      (       d  [        SR                  X5      5      eUR	                  S5        [        U5       H>  u  pEU R                  XRR                  R                  5       SR                  X45      5        M@     g)z5Convert a JSON representation into ListValue message.z+ListValue must be in [] which is {0} at {1}r   {0}[{1}]N)	rY   r   r   r>   r   r   r  r   r   )r@   rR   r#   r   r   r   s         r   r   _Parser._ConvertListValueMessage  sx    eT""DKK
  x  '
nn&8&8&: * 1 1$ >@ (r   c           	          [        U[        5      (       d  [        SR                  X5      5      eUR	                  5         U H4  nU R                  X   UR                  U   SR                  X45      5        M6     g)z2Convert a JSON representation into Struct message.z,Struct must be in a dict which is {0} at {1}r   N)rY   r   r   r>   Clearr  r`   )r@   rR   r#   r   rh   s        r   r   _Parser._ConvertStructMessage  sr    eT""ELL
   MMO

GNN3,? ) 0 0 ;=  r   c                 ~    UR                   R                  S   n[        US[        XSR	                  U5      S95        g)z3Convert a JSON representation into Wrapper message.rR   r   r   N)rI   rX   r   r   r>   )r@   rR   r#   r   r9   s        r   r   _Parser._ConvertWrapperMessage  s;    --g6E K4F4Ft4LMOr   c           	      R   [        U[        5      (       d%  [        SR                  UR                  X5      5      eUR
                  R                  S   nUR
                  R                  S   nU H  n[        XuSR                  U5      S5      nUR                  [        R                  R                  :X  a<  U R                  X   [        X#R                  5      U   SR                  XH5      5        M  [        X   USR                  XH5      S9[        X#R                  5      U'   M     g)	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}rh   rR   z{0}.keyTr  r  N)rY   r   r   r>   rV   r5   rX   r   ra   r   r3   rb   r   r   )	r@   rR   r#   r9   r   	key_fieldvalue_fieldrh   	key_values	            r   r   _Parser._ConvertMapFieldValue  s    eT""
?
F
Fjj%'( ( ""11%8I$$33G<K*3+4+;+;D+A4Ii			!;!;!K!K	KEJ#GZZ8C&--d>	@ 3KJ**;*;D*L3N$Y/ r   )r)   r   r   r   N)r   r   r   r   r   rA   r   r   r   r   r  r  r   r   r   r   r   r   r   r   r     s=    06FP @<%$@ONr   r   c                     UR                   [        ;   a  [        U 5      $ UR                   [        ;   a  [	        X5      $ UR                   [
        R                  R                  :X  a  [        X5      $ UR                   [
        R                  R                  :X  a  UR                  [
        R                  R                  :X  aV  [        U [        5      (       a  U R                  S5      nOU nUSS[        U5      S-  -
  -  -   n[         R"                  " U5      $ [$        R'                  U 5      (       a  [)        S5      eU $ UR                   [
        R                  R*                  :X  a  UR,                  R.                  R1                  U S5      nUc   [3        U 5      nUR,                  R4                  R1                  US5      nUcK  UR,                  R<                  (       a.  [)        SR9                  XR,                  R:                  5      5      eU$ UR>                  $ g! [6         a4  n[)        SR9                  XR,                  R:                  5      5      UeSnAff = f! [(         a   n[)        SR9                  X5      5      UeSnAff = f)a]  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.
ro      =   zUnpaired surrogateNz(Invalid enum value {0} for enum type {1}r   ) ra   
_INT_TYPES_ConvertIntegerr|   _ConvertFloatr   r3   rz   _ConvertBoolru   r2   rv   rY   r[   encodelenrw   urlsafe_b64decode_UNPAIRED_SURROGATE_PATTERNsearchr   rp   rq   values_by_namers   intrr   re   r>   rJ   rt   number)	rR   r9   r   require_strencodedpadded_valuer   r#  rk   s	            r   r   r     s   (:~~#U##	<	'5((	:55BB	B%--	:55DD	D	z11<<	<eS!!LL)''S\A-=)=!>>''55 '--e44/0
0	:55BB	B??1155eTBj			8u:&77;;FDI* __&&GNN002 3 3 M! 
C  	8ELL__..0 1678	8 
 :
\((1
29:sa   I I  2I 3B%I &I  AI 1H AI I 
I(/III 
J	)JJ	c                    [        U [        5      (       a/  U R                  5       (       d  [        SR	                  U 5      5      e[        U [
        5      (       a/  U R                  S5      S:w  a  [        SR	                  U 5      5      e[        U [        5      (       a  [        SR	                  U 5      5      e[        U 5      $ )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)	rY   r   
is_integerr   r>   r[   findrZ   r"  )rR   s    r   r  r  <  s     ue&6&6&8&8
3::5A
BBs

32 5
5<<UC
DDt
 %%+VE]4 4 
Ur   c                    [        U [        5      (       a  [        R                  " U 5      (       a  [	        S5      e[        R
                  " U 5      (       a  U S:  a  [	        S5      e[	        S5      eUR                  [        R                  R                  :X  a>  U [        R                  :  a  [	        S5      eU [        R                  :  a  [	        S5      eU S:X  a  [	        S5      e [        U 5      $ ! [         an  nU [        :X  a  [        S	5      s S
nA$ U [        :X  a  [        S5      s S
nA$ U [         :X  a  [        S5      s S
nA$ [	        SR#                  U 5      5      UeS
nAff = f)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-infNinfzCouldn't parse float: {0})rY   r   r}   r   r   r~   ra   r   r3   r   r   
_FLOAT_MAX
_FLOAT_MINre   r   r   r   r>   )rR   r9   rk   s      r   r  r  U  s5   uzz%FGGzz%	 9 : 	:  : ; 	;~~33AAA	))	)011	))	)011
e^
E
FFJ<	 	J6]	)	5\	$5\3::5ABI	Js<   +
C6 6
E. E)E.E).E.4E)E.E))E.c                     U(       a(  U S:X  a  gU S:X  a  g[        SR                  U 5      5      e[        U [        5      (       d  [        S5      eU $ )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.
rS   TrT   Fz#Expected "true" or "false", not {0}z%Expected true or false without quotes)r   r>   rY   rZ   )rR   r$  s     r   r  r  y  sQ     	'	<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):r   
__author__rw   collectionsr   rD   r}   operatorr   resys!cloudsdk.google.protobuf.internalr   cloudsdk.google.protobufr   r   r   _TIMESTAMPFOMAT	frozensetr3   CPPTYPE_INT32CPPTYPE_UINT32CPPTYPE_INT64CPPTYPE_UINT64r  r{   r   CPPTYPE_DOUBLEr|   r   r   r   compiler  r   	Exceptionr   r   r   r,   r/   r:   objectr!   rK   r   r   r   r   r"  r   r  r   r   r  r  r  rM   r   r   r   <module>rD     sE  >
 +
  #   ! 	 
 ; / 4 4 &
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	 jjMO  

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