
    OpfI                        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
mZ ddlmZ ddlmZ dd	lm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.e/e0fZ1 G d# d$e(          Z2d7d%Z3d& Z4d' Z5d( Z6d)d*gd+d,gd+d,gd-d.gd/d0gd+d,gd1d2gd3Z7d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)message_factory)symbol_database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__     [/var/www/html/nettyfy-visnx/env/lib/python3.11/site-packages/google/protobuf/json_format.pyr   r   6   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   :   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   >   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. 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(   B   sD    F $!%' ' '' 
		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+   n   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   _IsMapEntryr6      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_descriptorrC   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                 D    |                                 }	 |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kr5   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_namer6   r1   fields_by_name
isinstanceboolstrrN   labelr   r/   LABEL_REPEATEDis_extensionrC   r    rB   fieldscpp_typeCPPTYPE_MESSAGEcontaining_oneofdefault_value
ValueErrorr   r9   )r;   r   r@   r\   rJ   rS   v_fieldjs_mapkeyrecorded_keyrH   er5   s   `           @r   rG   z$_Printer._RegularMessageToJsonObject   s   !!F8N  ; ;,%+ 	!$$$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 N N N 
/
6
6uz1
E
EG GLMNN Is   GG% %
H/)HHc                    |j         t          j        j        k    r|                     |          S |j         t          j        j        k    ra| j        r|S |j        j        dk    rdS |j        j	        
                    |d          }||j        S |j        j        rt          d          |S |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t/          |          S |j         t0          v rt3          j        |          r|dk     rt6          S t8          S t3          j        |          rt<          S |j         t          j        j        k    r=| j         r"tC          tE          || j                             S tG          j$        |          S |S )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        )%r]   r   r/   r^   r*   CPPTYPE_ENUMr$   	enum_typerC   values_by_numbergetrS   	is_closedr   CPPTYPE_STRINGr.   
TYPE_BYTESbase64	b64encodedecodeCPPTYPE_BOOLrW   _INT64_TYPESrX   _FLOAT_TYPESmathisinf_NEG_INFINITY	_INFINITYisnan_NANCPPTYPE_FLOATr:   floatr9   r   ToShortestFloat)r;   r5   rJ   
enum_values       r   rN   z_Printer._FieldToJsonObject   s   ~3CCC&&u---	:5B	B	B		$ 		"&A	A	At?377tDDj		?$ 	$ &N O O O ,	: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.@typerJ   r   )rR   r   type_url_CreateMessageFromTypeUrlr%   ParseFromStringrJ   rB   rC   rD   rE   rF   r   rG   )r;   r   r@   r   sub_messagerH   rC   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._GenericMessageToJsonObject>  s     !!!r   c                    |                     d          }||dk    rdS |dk    r|                     |j                  S |dk    rN|j        }t	          j        |          rt          d          t	          j        |          rt          d          nt          ||          }|j	        j
        |         }|                     ||          S )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   rw   rx   ra   r{   getattrrB   rU   rN   )r;   r   whichrJ   oneof_descriptors        r   _ValueMessageToJsonObjectz"_Printer._ValueMessageToJsonObjectD  s    v&&E }--T//0BCCC"e	E		 > = > > 	>	E		 > = > > 	>> gu%%e)8?""#3U;;;r   c                 *      fd|j         D             S )zBConverts ListValue message according to Proto3 JSON Specification.c                 :    g | ]}                     |          S r   )r   )rO   rJ   r;   s     r   rQ   z:_Printer._ListValueMessageToJsonObject.<locals>.<listcomp>\  s7     ) ) ) **511 ) ) )r   )valuesr   s   ` r   r   z&_Printer._ListValueMessageToJsonObjectZ  s0    ) ) ) ) ) ) ) )r   c                 ^    |j         }i }|D ] }|                     ||                   ||<   !|S )z?Converts Struct message according to Proto3 JSON Specification.)r\   r   )r;   r   r\   retrd   s        r   _StructMessageToJsonObjectz#_Printer._StructMessageToJsonObject_  s?    ^F
C = =//s<<c#hhJr   c                 X    |                      |j        j        d         |j                  S )NrJ   )rN   rB   rU   rJ   r   s     r   rE   z$_Printer._WrapperMessageToJsonObjectg  s/    "")'2GMC C Cr   FFFNN)r   r   r   r   r<   r   r*   rG   rN   r   r   r   r   r   rE   r   r   r   r   r      s        11 &+"'"    K K K
	9 	9 	9> > >@* * *X= = =*" " "< < <,) ) )
  C C C C Cr   r   c                 "    | j         j        dk    S )Nzgoogle/protobuf/wrappers.proto)filerS   )rH   s    r   rD   rD   l  s    		 	%)I	IIr   c                 p    i }| D ]0\  }}||v r"t          d                    |                    |||<   1|S )Nz'Failed to load JSON: duplicate key {0}.)r   r9   )r@   resultrS   rJ   s       r   _DuplicateCheckerr   p  sP    &  kdEv~~@GGMMNNNF4LL	-r   c                 H   t          j                    }||j        n|}|                     d          d         }	 |                    |          }n5# t
          $ r(}t          d                    |                     |d}~ww xY wt          j	        |          } |            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	TypeErrorr9   r   GetMessageClass)r   r%   dbr   	type_namerH   rf   message_classs           r   r   r   y  s      "#+$nnS!!"%)33I>>	   
:AA(KK  "12DEE-	s   A 
B#A>>Bd   c                 :   t          | t                    s|                     d          } 	 t          j        | t
                    }nB# t          $ r5}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)
rV   rX   rs   r>   loadsr   ra   r   r9   	ParseDict)textr   ignore_unknown_fieldsr%   max_recursion_depthr@   rf   s          r   Parser     s    . 
D#		  ;;wDH	D,=	>	>	>BB	 H H H
077A??
@
@aGH	2w 5&
( 
( (s   A 
B0B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   r9   rB   rC   rS   rD   _ConvertWrapperMessagerF   r   _ConvertFieldValuePair)r;   rJ   r   pathrH   rC   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 ]=}	 |                    |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          $ rO}|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-   rT   rO   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   rQ   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   rh   {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}.)-rB   dictr\   rm   rU   _VALID_EXTENSION_NAMEmatchis_extendabler   r9   rC   
Extensions_FindExtensionByNamejoinr   r   appendr_   rS   r]   r   r/   r^   r1   r   r   rj   rk   setattr
ClearFieldr6   _ConvertMapFieldValuerY   rZ   rV   list	enumerateaddr   _ConvertScalarFieldValuer[   SetInParentrX   ra   r   )r;   r@   r   r   namesrH   fields_by_json_namerS   r5   
identifierrJ   
oneof_namer   indexitemrf   s                   r   r   z_Parser._ConvertFieldValuePair  sn    E + C C(:(AC C C C C w wv#''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-44T1==  3q66""
)   
+
2
24
;
;
 
	    
+
2
24
;
;
 
	iw ws?   C7V+&FV+0K9V++
Y&5A
W??Y&$X00Y&=$Y!!Y&c           	         t          |t                    r|sdS 	 |d         }n5# t          $ r(}t          d                    |                    |d}~ww xY w	 t          || j                  }n6# 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}rJ   	{0}.valuer   )rV   r   r   r   r9   r   r%   r   rB   rC   rD   r   rF   r   r   SerializeToStringrJ   r   )	r;   rJ   r   r   r   rf   r   rH   rC   s	            r   _ConvertAnyMessagez_Parser._ConvertAnyMessager  s   % u fwhh   :AA$GG 
<-h8LMMkk < < <|**1d3344!;<$/",I+,, 
 
!!%.+"-"4"4T":":< < < <	o	%	%-l?9-a0%.+%%d++- -    .
!!%d;;;eGn1133GMGs,   $ 
A#AAA0 0
B#:$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)FromJsonStringra   r   r9   )r;   rJ   r   r   rf   s        r   _ConvertGenericMessagez_Parser._ConvertGenericMessage  s`    <U##### < < <|**1d3344!;<s    
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})rV   r   _ConvertStructMessagestruct_valuer   _ConvertListValueMessager   r   rW   
bool_valuerX   string_value_INT_OR_FLOATr   r   r9   r.   )r;   rJ   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)	rV   r   r   r9   r   r   r   r   r   )r;   rJ   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)rV   r   r   r9   Clearr   r\   )r;   rJ   r   r   rd   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.rJ   r   r   N)rB   rU   r   r   r9   )r;   rJ   r   r   r5   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}rd   rJ   z{0}.keyTr   r   N)rV   r   r   r9   rS   r1   rU   r   r]   r   r/   r^   r   r   )	r;   rJ   r   r5   r   	key_fieldvalue_fieldrd   	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    6F F FP     @< < <% % %$@ @ @  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          $ r3}t)          d                    | |j        j                            |d}~ww xY w|;|j        j        r-t)          d                    | |j        j                            |S |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}r   ) r]   
_INT_TYPES_ConvertIntegerrv   _ConvertFloatr   r/   rt   _ConvertBoolro   r.   rp   rV   rX   encodelenrq   urlsafe_b64decode_UNPAIRED_SURROGATE_PATTERNsearchr   rj   rk   values_by_namerm   intrl   ra   r9   rC   rn   number)	rJ   r5   r   require_strencodedpadded_valuer   r  rf   s	            r   r   r     s\   (:~##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			8u::&7;;FDII** 	8 	8 	8ELLU_.0 0 1 1678	8 _& GNNu02 2 3 3 3 M! 
C	B" 
 : : :
\((D11
2
29:s^   H H )H 'BH 7*H "<H /F H 
G.GG?H H 
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)	rV   r~   
is_integerr   r9   rX   findrW   r  )rJ   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          $ r}| t          k    rt          d	          cY d
}~S | t          k    rt          d          cY d
}~S | t           k    rt          d          cY d
}~S t	          d                    |                     |d
}~w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-infNinfzCouldn't parse float: {0})rV   r~   rw   r{   r   rx   r]   r   r/   r}   r   
_FLOAT_MAX
_FLOAT_MINra   ry   rz   r|   r9   )rJ   r5   rf   s      r   r  r  <  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J<<	 	J 	J 	J6]]	)		5\\	$5\\3::5AABBI	Js<   C. .
E=8E8E=E80E=6E8E=#E88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.
  rK   TrL   Fz#Expected "true" or "false", not {0}z%Expected true or false without quotes)r   r9   rV   rW   )rJ   r  s     r   r  r  `  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)8r   
__author__rq   collectionsr   r>   rw   operatorr   regoogle.protobuf.internalr   google.protobufr   r   r   	frozensetr/   CPPTYPE_INT32CPPTYPE_UINT32CPPTYPE_INT64CPPTYPE_UINT64r  ru   r}   CPPTYPE_DOUBLErv   rz   ry   r|   compiler  r   	Exceptionr   r   r   r(   r+   r6   objectr   rD   r   r   r   r   r  r~   r   r   r   r  r  r  rF   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\ $) % #/ #/ #/ #/L5 5 5OC OC OC OC OCv OC OC OCdJ J J    " !&!	( ( ( (F %*""%	   2 eaN aN aN aN aNf aN aN aNH	7: 7: 7: 7:t  2!J !J !JH  4 602!>!9!;"?":"<"A"<">;68"?":"<946 r   