
    ?R2dP                        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        j        ej        j        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%	 	 	 	 	 	 	 	 d4dZ&	 	 	 	 	 d5dZ'd Z( G d de)          Z*d Z+d Z,d Z-	 	 	 d6d!Z.	 	 	 d6d"Z/e0e1fZ2 G d# d$e)          Z3d7d%Z4d& Z5d' Z6d( Z7d)d*gd+d,gd+d,gd-d.gd/d0gd+d,gd1d2gd3Z8dS )8at  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dS )Errorz'Top-level module error for json_format.N__name__
__module____qualname____doc__     =/usr/lib/python3/dist-packages/google/protobuf/json_format.pyr   r   N   s        ////r   r   c                       e Zd ZdZdS )SerializeToJsonErrorz&Thrown if serialization to JSON fails.Nr   r   r   r   r   r   R   s        ....r   r   c                       e Zd ZdZdS )
ParseErrorz Thrown in case of parsing error.Nr   r   r   r   r   r   V   s        ((((r   r   F   Tc	                 Z    t          |||||          }	|	                    | |||          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   sD    D $!%' ' '' 
		gvy,	G	GGr   c                 T    t          |||||          }|                    |           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*      s=    8 $!%' ' '' 
	%	%g	.	..r   c                     | j         t          j        j        k    o)| j        j        o| j                                        j        S N)typer   FieldDescriptorTYPE_MESSAGEmessage_typehas_options
GetOptions	map_entry)fields    r   _IsMapEntryr5      s?    
*
2?
? 4


(4


'
'
)
)
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dS )r   z)JSON format printer for protocol message.FNc                     || _         || _        || _        || _        |rd                    |          | _        d S d | _        d S )Nz.{}g)r   r    r#   r$   formatfloat_format)selfr   r    r#   r$   r   s         r   __init__z_Printer.__init__   sU     +ID''BD$"8D*D  --88ddr   c                 \    |                      |          }t          j        ||||          S )N)r!   r"   r%   )r)   jsondumps)r:   r   r!   r"   r%   jss         r   r   z_Printer.ToJsonString   s;    		"	"7	+	+B:
6Y\K K K Kr   c                     |j         }|j        }t          |          r|                     |          S |t          v r* t          t          |         d         |          |           S i }|                     ||          S )zEConverts message to an object according to Proto3 JSON Specification.r   )
DESCRIPTOR	full_name_IsWrapperMessage_WrapperMessageToJsonObject_WKTJSONMETHODSr   _RegularMessageToJsonObject)r:   r   message_descriptorrB   r?   s        r   r)   z_Printer._MessageToJsonObject   s     +",I+,, 7--g666O##A\/)4Q7AA$GGG	B++GR888r   c                 B    |                                 }	 |D ]\  } j        rj        }nj        }t	                    rjj        j        d         }i }|D ]M}t          |t                    r|rd}	nd}	nt          |          }	 
                    |||                   ||	<   N|||<   j        t          j        j        k    r fd|D             ||<   j        r$dj        z  } 
                    |          ||<    
                    |          ||<    j        r|j        }
|
j        D ]j        t          j        j        k    rj        t          j        j        k    sj        r> j        rj        }nj        }||v rYt	                    ri ||<   nj        t          j        j        k    rg ||<    
                    j                  ||<   n:# t0          $ r-}t3          d                    j        |                    d}~ww xY w|S )z?Converts normal message according to Proto3 JSON Specification.valuetruefalsec                 <    g | ]}                     |          S r   )_FieldToJsonObject).0kr4   r:   s     r   
<listcomp>z8_Printer._RegularMessageToJsonObject.<locals>.<listcomp>   s9     & & & --eQ77 & & &r   z[%s]z#Failed to serialize {0} field: {1}.N)
ListFieldsr    name	json_namer5   r0   fields_by_name
isinstanceboolstrrM   labelr   r.   LABEL_REPEATEDis_extensionrB   r   rA   fieldscpp_typeCPPTYPE_MESSAGEcontaining_oneofdefault_value
ValueErrorr   r8   )r:   r   r?   r[   rI   rR   v_fieldjs_mapkeyrecorded_keyrG   er4   s   `           @r   rF   z$_Printer._RegularMessageToJsonObject   s   !!F8G  ; ;,%+ 	!$$$u 	;&5g>'& 	% 	%c#t$$ & '%& XXl#'#:#:s$% $%F<  "T(([J6EEE& & & & &$& & &"T(( 	;%/)$,,UE::"T((,,UE::"T(( 
	, K$/'. 	K 	KE{j8GGG~!;!KKK$ L- #:DD?DRZZ KBtHH{j8GGGBtHH..ue6IJJBtHH G G G 
/
6
6uz1
E
EG G GG Is   GG% %
H/(HHc                    |j         t          j        j        k    r|                     |          S |j         t          j        j        k    re| j        r|S |j        j        dk    rdS |j        j	        
                    |d          }||j        S |j        j        dk    r|S t          d          |j         t          j        j        k    rC|j        t          j        j        k    r't%          j        |                              d          S |S |j         t          j        j        k    rt-          |          S |j         t.          v rt1          |          S |j         t2          v rt5          j        |          r|dk     rt8          S t:          S t5          j        |          rt>          S |j         t          j        j         k    r=| j!        r"tE          tG          || j!                            S tI          j%        |          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        )&r\   r   r.   r]   r)   CPPTYPE_ENUMr#   	enum_typerB   values_by_numbergetrR   filesyntaxr   CPPTYPE_STRINGr-   
TYPE_BYTESbase64	b64encodedecodeCPPTYPE_BOOLrV   _INT64_TYPESrW   _FLOAT_TYPESmathisinf_NEG_INFINITY	_INFINITYisnan_NANCPPTYPE_FLOATr9   floatr8   r   ToShortestFloat)r:   r4   rI   
enum_values       r   rM   z_Printer._FieldToJsonObject  s   ~3CCC&&u---	:5B	B	B		$ 		"&A	A	At?377tDDj		:((," $L M M 	M	:5D	D	D	z1<	<	<&&--g666	:5B	B	B%[[	<	'	'ZZ	<	'	'	E		 3;;

	E		 	:5C	C	C 	6veT%67788
8.u55
5Lr   c                    |                                 si S t                      }|j        }||d<   t          || j                  }|                    |j                   |j        }|j        }t          |          r| 
                    |          |d<   |S |t          v r/ t          t          |         d         |          |           |d<   |S |                     ||          S )z<Converts Any message according to Proto3 JSON Specification.@typerI   r   )rQ   r   type_url_CreateMessageFromTypeUrlr$   ParseFromStringrI   rA   rB   rC   rD   rE   r   rF   )r:   r   r?   r   sub_messagerG   rB   s          r   _AnyMessageToJsonObjectz _Printer._AnyMessageToJsonObject?  s     i	BHBwK+Hd6JKKK...$/",I+,, 44[AAbkiO##.L!;A!>!,. ..24 4bki++K<<<r   c                 *    |                                 S )z8Converts message according to Proto3 JSON Specification.)r   r:   r   s     r   _GenericMessageToJsonObjectz$_Printer._GenericMessageToJsonObjectT  s     !!!r   c                    |                     d          }||dk    rdS |dk    r|                     |j                  S |dk    r|j        }nt	          ||          }|j        j        |         }|                     ||          S )z>Converts Value message according to Proto3 JSON Specification.kindN
null_value
list_valuestruct_value)
WhichOneof_ListValueMessageToJsonObjectr   r   getattrrA   rT   rM   )r:   r   whichrI   oneof_descriptors        r   _ValueMessageToJsonObjectz"_Printer._ValueMessageToJsonObjectZ  s    v&&E }--T//0BCCC"eegu%%e)8?""#3U;;;r   c                 *      fd|j         D             S )zBConverts ListValue message according to Proto3 JSON Specification.c                 :    g | ]}                     |          S r   )r   )rN   rI   r:   s     r   rP   z:_Printer._ListValueMessageToJsonObject.<locals>.<listcomp>l  s7     ) ) ) **511 ) ) )r   )valuesr   s   ` r   r   z&_Printer._ListValueMessageToJsonObjectj  s0    ) ) ) ) ) ) ) )r   c                 ^    |j         }i }|D ] }|                     ||                   ||<   !|S )z?Converts Struct message according to Proto3 JSON Specification.)r[   r   )r:   r   r[   retrc   s        r   _StructMessageToJsonObjectz#_Printer._StructMessageToJsonObjecto  s?    ^F
C = =//s<<c#hhJr   c                 X    |                      |j        j        d         |j                  S )NrI   )rM   rA   rT   rI   r   s     r   rD   z$_Printer._WrapperMessageToJsonObjectw  s/    "")'2GMC C Cr   FFFNN)r   r   r   r   r;   r   r)   rF   rM   r   r   r   r   r   rD   r   r   r   r   r      s        11 &+"'"    K K K
	9 	9 	9> > >@) ) )V= = =*" " "< < < ) ) )
  C C C C Cr   r   c                 "    | j         j        dk    S )Nzgoogle/protobuf/wrappers.proto)rn   rR   )rG   s    r   rC   rC   |  s    		 	%)I	IIr   c                 p    i }| D ]0\  }}||v r"t          d                    |                    |||<   1|S )Nz'Failed to load JSON: duplicate key {0}.)r   r8   )r?   resultrR   rI   s       r   _DuplicateCheckerr     sP    &  kdEv~~@GGMMNNNF4LL	-r   c                 @   t          j                    }||j        n|}|                     d          d         }	 |                    |          }n0# t
          $ r# t          d                    |                     w xY w|                    |          } |            S )z"Creates a message from a type URL.N/z0Can not find message descriptor by type_url: {0})	r   DefaultpoolsplitFindMessageTypeByNameKeyError	TypeErrorr8   GetPrototype)r   r$   dbr   	type_namerG   message_classs          r   r   r     s      "#+$nnS!!"%)M33I>>	 M M M
:AA(KKM M MM //"455-	s   A -A>d   c                 8   t          | t                    s|                     d          } 	 t          j        | t
                    }nA# t          $ r4}t          d                    t          |                              d}~ww xY wt          |||||          S )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.
  ri   )object_pairs_hookzFailed to load JSON: {0}.N)
rU   rW   rt   r=   loadsr   r`   r   r8   	ParseDict)textr   ignore_unknown_fieldsr$   max_recursion_depthr?   re   s          r   Parser     s    . 
D#		  ;;wDA	D,=	>	>	>BB	 A A A
077A??
@
@@A	2w 5&
( 
( (s   A 
B/BBc                 V    t          |||          }|                    | |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     s4    ( (/;NOO&"---	.r   c                   N    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dS )r   z(JSON format parser for protocol message.c                 >    || _         || _        || _        d| _        d S )Nr   )r   r$   r   recursion_depth)r:   r   r$   r   s       r   r;   z_Parser.__init__  s(    !6D*D2DDr   c                    | xj         dz  c_         | j         | j        k    r't          d                    | j                            |j        }|j        }|s|j        }t          |          r|                     |||           nM|t          v r- t          t          |         d         |||          |            n|                     |||           | xj         dz  c_         dS )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   r8   rA   rB   rR   rC   _ConvertWrapperMessagerE   r   _ConvertFieldValuePair)r:   rI   r   pathrG   rB   s         r   r   z_Parser.ConvertMessage  s	    	Ad666ELL

"$ $ % % % +",I %$d+,, 8
!!%$7777	o	%	%Gl?9-a0%$GGMMMM
!!%$777Ar   c                    g }|j         }t          d |j        D                       }|D ]9}	 |                    |d          }|s|j                            |d          }|st
                              |          r|j        s(t          d	                    |j
        |                    |dd         }	|j                            |	          }|sJd                    |	                    d          dd                   }	|j                            |	          }|sA| j        rt          d	                    |j
        ||d |j        D                                 ||v r.t          d		                    |j         j
        ||                    |                    |           ||         }
|j        U|
S|j        j        }||v r.t          d
	                    |j         j
        ||                    |                    |           |
|j        t(          j        j        k    r-|j        j
        dk    rt1          ||j                  }d|_        n[|j        t(          j        j        k    r'|j        j
        dk    rt9          ||j        d           n|                    |j                   t=          |          rH|                    |j                   |                     |
||d	                    ||                     n|j         t(          j        j!        k    r|                    |j                   tE          |
tF                    s$t          d	                    ||
|                    |j        t(          j        j        k    rtI          |
          D ]\  }}t1          ||j                  %                                }|4|j         j
        dk    r$t          d	                    |||                    | &                    ||d	                    |||                     nztI          |
          D ]w\  }}|$t          d	                    |||                    t1          ||j                                      tO          ||d	                    |||                               xn|j        t(          j        j        k    rj|j(        r|j        |         }nt1          ||j                  }|)                                 | &                    |
|d	                    ||                     nn|j(        r.tO          |
|d	                    ||                    |j        |<   n9t9          ||j        tO          |
|d	                    ||                               # t          $ rM}|r*|j        #t          d	                    ||                    t          tU          |                    d}~wtV          $ r(}t          d	                    ||                    d}~wtX          $ r(}t          d	                    ||                    d}~ww xY wdS )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   (   K   | ]}|j         |fV  d S r,   rS   rN   fs     r   	<genexpr>z1_Parser._ConvertFieldValuePair.<locals>.<genexpr>  sE       C C#$ !"Q/ C C C C C Cr   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}"c                     g | ]	}|j         
S r   r   r   s     r   rP   z2_Parser._ConvertFieldValuePair.<locals>.<listcomp>$  s    CCCAAKCCCr   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   rg   {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}.)-rA   dictr[   rm   rT   _VALID_EXTENSION_NAMEmatchis_extendabler   r8   rB   
Extensions_FindExtensionByNamejoinr   r   appendr^   rR   r\   r   r.   r]   r0   r   r   rj   rk   setattr
ClearFieldr5   _ConvertMapFieldValuerX   rY   rU   list	enumerateaddr   _ConvertScalarFieldValuerZ   SetInParentrW   r`   r   )r:   r?   r   r   namesrG   fields_by_json_namerR   r4   
identifierrI   
oneof_namer   indexitemre   s                   r   r   z_Parser._ConvertFieldValuePair  sY    E + C C(:(AC C C C C qL qLpL#''d33 	D$377dCC% 	H.44T:: 	H#1 9BII&0$8 89 9 9 AbDz*$99*EE% H *"2"23"7"7"<==J&;;JGGE 	F' =>Df%/tCC);)BCCC?E ?EF F F
 5== 44:F&1;T45I 5IJ J J 	T4!-%2C-2*5   <<BF!(!3!=z!%=' ='( ( ( ,,z
"
"
"=n
 : JJJ$.2III!'5:66K%&K""*"<"IIIO-1LLLGUZ++++uz***
 u .	H


UZ
(
(
(

$
$UGU%.%5%5dD%A%AC C C C[J6EEE


UZ
(
(
(E4(( E **0&ud*C*CE E E^z9III(// 	L 	Lt#GUZ88<<>>k,(26MMM  "HHN%)4I8 I89 9 9 !!$"0"7"7dE"J"JL L L L	L  )// N Nt  "HHN%)4I8 I89 9 9 guz**11*E>#8#8tU#K#KM MN N N NN ^z9III 7!,U3KK!'5:66K

!
!
#
#
#


e[)2B2B42N2N
O
O
O
O H(@ui..tT::)< )<Gu%% ()2)9)9$)E)EG GH H H  # # # 	#U+3<CCD!LLMM
M3q66""
" L L L:AA$JJKKK L L L:AA$JJKKKLaqL qLs?   C7V+&FV+0K9V++
Y"5AW==Y"
#X--Y":#YY"c           	         t          |t                    r|sdS 	 |d         }n0# t          $ r# t          d                    |                    w xY w	 t          || j                  }n5# t          $ r(}t          d                    ||                    d}~ww xY w|j        }|j	        }t          |          r1|                     |d         |d                    |                     nn|t          v rF t          t          |         d         |d         |d                    |                    |            n|d= |                     |||           ||d<   |                                |_        ||_        dS )z/Convert a JSON representation into Any message.Nr   z0@type is missing when parsing any message at {0}
{0} at {1}rI   	{0}.valuer   )rU   r   r   r   r8   r   r$   r   rA   rB   rC   r   rE   r   r   SerializeToStringrI   r   )	r:   rI   r   r   r   r   re   rG   rB   s	            r   _ConvertAnyMessagez_Parser._ConvertAnyMessage{  s   % u fKwhh K K K
<
C
CD
I
IK K KK5-h8LMMkk 5 5 5|**1d334445$/",I+,, 
 
!!%.+"-"4"4T":":< < < <	o	%	%-l?9-a0%.+%%d++- -    .
!!%d;;;eGn1133GMGs!   $ -AA+ +
B5#BBc                     	 |                     |           dS # t          $ r(}t          d                    ||                    d}~ww xY w)z?Convert a JSON representation into message with FromJsonString.r   N)FromJsonStringr`   r   r8   )r:   rI   r   r   re   s        r   _ConvertGenericMessagez_Parser._ConvertGenericMessage  s^    5U##### 5 5 5|**1d334445s    
A#AAc                    t          |t                    r|                     ||j        |           dS t          |t                    r|                     ||j        |           dS |	d|_        dS t          |t                    r	||_	        dS t          |t                    r	||_        dS t          |t                    r	||_        dS t          d                    |t!          |          |                    )z1Convert a JSON representation into Value message.Nr   z(Value {0} has unexpected type {1} at {2})rU   r   _ConvertStructMessager   r   _ConvertListValueMessager   r   rV   
bool_valuerW   string_value_INT_OR_FLOATnumber_valuer   r8   r-   )r:   rI   r   r   s       r   _ConvertValueMessagez_Parser._ConvertValueMessage  s   % %
  (<dCCCCC	E4	 	  %
##E7+=tDDDDD	g	E4	 	  % g	E3		 %"g	E=	)	) %"gAHH
ed$ $ % % %r   c           	      N   t          |t                    s#t          d                    ||                    |                    d           t          |          D ]G\  }}|                     ||j                                        d                    ||                     HdS )z5Convert a JSON representation into ListValue message.z+ListValue must be in [] which is {0} at {1}r   {0}[{1}]N)	rU   r   r   r8   r   r   r   r   r   )r:   rI   r   r   r   r   s         r   r   z _Parser._ConvertListValueMessage  s    eT"" DKK
    x    '' @ @t
gn&8&8&:&: * 1 1$ > >@ @ @ @@ @r   c           	          t          |t                    s#t          d                    ||                    |                                 |D ]>}|                     ||         |j        |         d                    ||                     ?dS )z2Convert a JSON representation into Struct message.z,Struct must be in a dict which is {0} at {1}r   N)rU   r   r   r8   Clearr   r[   )r:   rI   r   r   rc   s        r   r   z_Parser._ConvertStructMessage  s    eT"" ELL
     MMOOO = =
c
GN3,? ) 0 0s ; ;= = = =
Fr   c                     |j         j        d         }t          |dt          ||d                    |                               dS )z3Convert a JSON representation into Wrapper message.rI   r   r   N)rA   rT   r   r   r8   )r:   rI   r   r   r4   s        r   r   z_Parser._ConvertWrapperMessage  sX    -g6E K4F4Ft4L4LMMMO O O O Or   c           	      l   t          |t                    s)t          d                    |j        ||                    |j        j        d         }|j        j        d         }|D ]}t          ||d                    |          d          }|j        t          j
        j        k    rK|                     ||         t          ||j                  |         d                    ||                     t          ||         |d                    ||                    t          ||j                  |<   dS )	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}rc   rI   z{0}.keyTr   r   N)rU   r   r   r8   rR   r0   rT   r   r\   r   r.   r]   r   r   )	r:   rI   r   r4   r   	key_fieldvalue_fieldrc   	key_values	            r   r   z_Parser._ConvertMapFieldValue  sV    eT"" (
?
F
Fj%' '( ( ( "1%8I$3G<K 	N 	N*3	+4+;+;D+A+A4I Ii		!;!K	K	KE#J#GUZ88C&--dI>>	@ 	@ 	@ 	@ 3K#J**;*;D)*L*L3N 3N 3N$$Y//	N 	Nr   N)r   r   r   r   r;   r   r   r   r   r   r   r   r   r   r   r   r   r   r     s        00    6@L @L @LD     >5 5 5% % %$@ @ @  O O ON N N N 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    r\t          | t                    r|                     d          }n| }|ddt          |          dz  z
  z  z   }t!          j        |          S t$                              |           rt)          d          | S |j         t
          j        j        k    r|j        j                            | d          }|	 t3          |           }|j        j                            |d          }n;# t6          $ r. t)          d                    | |j        j                            w xY w|?|j        j        dk    r|S t)          d                    | |j        j                            |j         S dS # t(          $ r(}t)          d                    ||                    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.
  ri      =   zUnpaired surrogateNz(Invalid enum value {0} for enum type {1}rh   r   )!r\   
_INT_TYPES_ConvertIntegerrw   _ConvertFloatr   r.   ru   _ConvertBoolrp   r-   rq   rU   rW   encodelenrr   urlsafe_b64decode_UNPAIRED_SURROGATE_PATTERNsearchr   rj   rk   values_by_namerm   intrl   r`   r8   rB   rn   ro   number)	rI   r4   r   require_strencodedpadded_valuer   r  re   s	            r   r   r     sT   (3~##U###	<	'	'5%(((	:5B	B	B%---	:5D	D	D	z1<	<	<eS!! 	LL))'''S\\A-=)=!>>'555 '--e44 	1/00
0	:5B	B	B?155eTBBj			1u::&7;;FDII** 	1 	1 	1ELLU_.0 0 1 1 1	1 Z(**MELLU_.0 0 1 1 1! 
C	B" 
 3 3 3
\((D11
2
223sR   H H )H 'BH 7*H "<H /F H 8GH 3H 
I#IIc                    t          | t                    r6|                                 s"t          d                    |                     t          | t
                    r;|                     d          dk    r"t          d                    |                     t          | t                    r"t          d                    |                     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)	rU   r   
is_integerr   r8   rW   findrV   r  )rI   s    r   r  r  +  s     u Ce&6&6&8&8 C
3::5AA
B
BBs E

32 5 5
5<<UCC
D
DDt 4
 %%+VE]]4 4 4 
Ur   c                    t          | t                    rt          j        |           rt	          d          t          j        |           r$| dk    rt	          d          t	          d          |j        t          j        j	        k    r>| t          j        k    rt	          d          | t          j        k     rt	          d          | dk    rt	          d          	 t          |           S # t          $ rw | 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                    |                     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})rU   r   rx   r|   r   ry   r\   r   r.   r~   r   
_FLOAT_MAX
_FLOAT_MINr`   rz   r{   r}   r8   )rI   r4   s     r   r  r  D  s   u 2z% HFGGGz% ;	 9 : : 	:  : ; ; 	;~3AAA	)	)	)0111	)	)	)0111
e^^
E
F
FFC<<	 	C 	C 	C6]]	)		5\\	$5\\3::5AABBB	Cs   C. .$E/E/0E/#E/c                     |r2| dk    rdS | dk    rdS t          d                    |                     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.
  rJ   TrK   Fz#Expected "true" or "false", not {0}z%Expected true or false without quotes)r   r8   rU   rV   )rI   r  s     r   r  r  h  sn      LT	'		U<CCEJJK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   )FFr   FFNNTr   )FNr   )F)9r   
__author__rr   collectionsr   r=   rx   operatorr   resysgoogle.protobuf.internalr   google.protobufr   r   _TIMESTAMPFOMAT	frozensetr.   CPPTYPE_INT32CPPTYPE_UINT32CPPTYPE_INT64CPPTYPE_UINT64r  rv   r~   CPPTYPE_DOUBLErw   r{   rz   r}   compiler  r   	Exceptionr   r   r   r'   r*   r5   objectr   rC   r   r   r   r   r  r   r   r   r   r  r  r  rE   r   r   r   <module>r.     s  >
 
 +
  # # # # # #   ! ! ! ! ! ! 				 



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