
    /P@iI                     f   d Z dZddlZddlmZ ddlZddlZddlmZ ddl	Z	ddl
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"                  j0                  ej"                  j2                  g      Zd
ZdZdZ e	j<                  d      Z e	j<                  d      Z  G d de!      Z" G d de"      Z# G d de"      Z$	 	 	 	 	 	 	 	 d0dZ%	 	 	 	 	 d1dZ&d Z' G d de(      Z)d Z*d Z+d Z,	 	 	 d2dZ-	 	 	 d2dZ.e/e0fZ1 G d d e(      Z2d3d!Z3d" Z4d# Z5d$ Z6d%d&gd'd(gd'd(gd)d*gd+d,gd'd(gd-d.gd/Z7y)4at  Contains routines for printing protocol messages in JSON format.

Simple usage example:

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

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

  Args:
    message: The protocol buffers message instance to serialize.
    including_default_value_fields: If True, singular primitive fields,
        repeated fields, and map fields will always be serialized.  If
        False, only serialize non-empty fields.  Singular message fields
        and oneof fields are not affected by this option.
    preserving_proto_field_name: If True, use the original proto field
        names as defined in the .proto file. If False, convert the field
        names to lowerCamelCase.
    indent: The JSON object will be pretty-printed with this indent level.
        An indent level of 0 or negative will only insert newlines. 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   s7    F $!%'' 
		gvy,	GGr   c                 D    t        |||||      }|j                  |       S )a  Converts protobuf message to a dictionary.

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

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

  Returns:
    A dict representation of the protocol buffer message.
  r   )r   _MessageToJsonObject)r   r   r    r#   r$   r   r&   s          r   MessageToDictr*   n   s0    8 $!%'' 
	%	%g	..r   c                     | j                   t        j                  j                  k(  xr< | j                  j
                  xr$ | j                  j                         j                  S N)typer   FieldDescriptorTYPE_MESSAGEmessage_typehas_options
GetOptions	map_entry)fields    r   _IsMapEntryr5      sP    
**
22??
? 4



(
(4



'
'
)
3
35r   c                   ^    e Zd ZdZ	 	 	 	 	 ddZd Zd Zd Zd Zd Z	d	 Z
d
 Zd Zd Zd Zy)r   z)JSON format printer for protocol message.Nc                 |    || _         || _        || _        || _        |rdj	                  |      | _        y d | _        y )Nz.{}g)r   r    r#   r$   formatfloat_format)selfr   r    r#   r$   r   s         r   __init__z_Printer.__init__   sA     +ID''BD$"8D*D --8ddr   c                 V    | j                  |      }t        j                  ||||      S )N)r!   r"   r%   )r)   jsondumps)r:   r   r!   r"   r%   jss         r   r   z_Printer.ToJsonString   s.    		"	"7	+B::
6Y\K Kr   c                     |j                   }|j                  }t        |      r| j                  |      S |t        v r t        t        |   d   |      |       S i }| j                  ||      S )zEConverts message to an object according to Proto3 JSON Specification.r   )
DESCRIPTOR	full_name_IsWrapperMessage_WrapperMessageToJsonObject_WKTJSONMETHODSr   _RegularMessageToJsonObject)r:   r   message_descriptorrB   r?   s        r   r)   z_Printer._MessageToJsonObject   sq     ++",,I+,--g66O#A\/)4Q7A$GG	B++GR88r   c                    |j                         }	 |D ]+  \  }}| j                  r|j                  }n|j                  }t	        |      rc|j
                  j                  d   }i }|D ]=  }	t        |	t              r|	rd}
nd}
nt        |	      }
| j                  |||	         ||
<   ? |||<   |j                  t        j                  j                  k(  r$|D cg c]  }| j                  ||       c}||<   |j                  r&d|j                   z  }| j                  ||      ||<   | j                  ||      ||<   . | j"                  r|j$                  }|j&                  D ]  }|j                  t        j                  j                  k7  r'|j(                  t        j                  j*                  k(  s|j,                  r^| j                  r|j                  }n|j                  }||v rt	        |      ri ||<   |j                  t        j                  j                  k(  rg ||<   | j                  ||j.                        ||<    |S c c}w # t0        $ r+}t3        dj5                  j                  |            |d}~ww xY w)z?Converts normal message according to Proto3 JSON Specification.valuetruefalsez[%s]z#Failed to serialize {0} field: {1}.N)
ListFieldsr    name	json_namer5   r0   fields_by_name
isinstanceboolstr_FieldToJsonObjectlabelr   r.   LABEL_REPEATEDis_extensionrB   r   rA   fieldscpp_typeCPPTYPE_MESSAGEcontaining_oneofdefault_value
ValueErrorr   r8   )r:   r   r?   rW   r4   rI   rM   v_fieldjs_mapkeyrecorded_keykrG   es                 r   rF   z$_Printer._RegularMessageToJsonObject   si   !F8N  ;,%++$$u&&55g>'& 	%c#t$%& Xl#'#:#:s$%F< 	% "T([[J66EEE  %& --eQ7 &"T(%//)$,,UE:"T(,,UE:"T(9;> 
	,	,$//'.. 	KE{{j88GGG~~!;!;!K!KK$$--::D??DRZBtH{{j88GGGBtH..ue6I6IJBtH%	K0 IG&>  N 
/
6
6uzz1
EGLMNNs+   CI I2EI I 	J	&JJ	c                    |j                   t        j                  j                  k(  r| j	                  |      S |j                   t        j                  j
                  k(  r| j                  r|S |j                  j                  dk(  ry|j                  j                  j                  |d      }||j                  S |j                  j                  rt        d      |S |j                   t        j                  j                  k(  rM|j                  t        j                  j                   k(  r$t#        j$                  |      j'                  d      S |S |j                   t        j                  j(                  k(  rt+        |      S |j                   t,        v rt/        |      S |j                   t0        v rt3        j4                  |      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        jH                  |      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        )%rX   r   r.   rY   r)   CPPTYPE_ENUMr#   	enum_typerB   values_by_numbergetrM   	is_closedr   CPPTYPE_STRINGr-   
TYPE_BYTESbase64	b64encodedecodeCPPTYPE_BOOLrQ   _INT64_TYPESrR   _FLOAT_TYPESmathisinf_NEG_INFINITY	_INFINITYisnan_NANCPPTYPE_FLOATr9   floatr8   r   ToShortestFloat)r:   r4   rI   
enum_values       r   rS   z_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veT%6%678
8..u5
5Lr   c                    |j                         si S t               }|j                  }||d<   t        || j                        }|j                  |j                         |j                  }|j                  }t        |      r| j                  |      |d<   |S |t        v r! t        t        |   d   |      |       |d<   |S | j                  ||      S )z<Converts Any message according to Proto3 JSON Specification.@typerI   r   )rL   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+Hd6J6JKK.$//",,I+,44[AbkiO#.L!;A!>!,..24bki++K<<r   c                 "    |j                         S )z8Converts message according to Proto3 JSON Specification.)r   r:   r   s     r   _GenericMessageToJsonObjectz$_Printer._GenericMessageToJsonObject>  s     !!r   c                    |j                  d      }||dk(  ry|dk(  r| j                  |j                        S |dk(  rL|j                  }t	        j
                  |      rt        d      t	        j                  |      rt        d      t        ||      }|j                  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   rs   rt   r\   rw   getattrrA   rO   rS   )r:   r   whichrI   oneof_descriptors        r   _ValueMessageToJsonObjectz"_Printer._ValueMessageToJsonObjectD  s    v&E }-//0B0BCC""e	E	 = > 	>	E	 = > 	> gu%e))88?""#3U;;r   c                 ^    |j                   D cg c]  }| j                  |       c}S c c}w )zBConverts ListValue message according to Proto3 JSON Specification.)valuesr   )r:   r   rI   s      r   r   z&_Printer._ListValueMessageToJsonObjectZ  s3     !) **51 ) ) )s   *c                 ^    |j                   }i }|D ]  }| j                  ||         ||<    |S )z?Converts Struct message according to Proto3 JSON Specification.)rW   r   )r:   r   rW   retr_   s        r   _StructMessageToJsonObjectz#_Printer._StructMessageToJsonObject_  s<    ^^F
C =//s<c#h=Jr   c                 h    | j                  |j                  j                  d   |j                        S )NrI   )rS   rA   rO   rI   r   s     r   rD   z$_Printer._WrapperMessageToJsonObjectg  s1    ""))'2GMMC Cr   FFFNN)r   r   r   r   r;   r   r)   rF   rS   r   r   r   r   r   rD   r   r   r   r   r      sQ    1 &+"'" K
	9>@*X=*"<,)
Cr   r   c                 4    | j                   j                  dk(  S )Nzgoogle/protobuf/wrappers.proto)filerM   )rG   s    r   rC   rC   l  s    		 	 	%	%)I	IIr   c                 d    i }| D ](  \  }}||v rt        dj                  |            |||<   * |S )Nz'Failed to load JSON: duplicate key {0}.)r   r8   )r?   resultrM   rI   s       r   _DuplicateCheckerr   p  sH    & kdEv~@GGMNNF4L 
-r   c                 &   t        j                         }||j                  n|}| j                  d      d   }	 |j	                  |      }t        j                  |      } |       S # t
        $ r }t        dj                  |             |d}~ww xY w)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   r   GetMessageClass)r   r$   dbr   	type_namerG   rb   message_classs           r   r   r   y  s     "#+$nnS!"%)33I>
 "112DE-	 
 
:AA(Ks   A' '	B0BBc                    t        | t              s| j                  d      } 	 t        j                  | t
              }t        |||||      S # t        $ r)}t        dj                  t        |                  |d}~ww xY w)al  Parses a JSON representation of a protocol message into a message.

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

  Returns:
    The same message passed as argument.

  Raises::
    ParseError: On JSON parsing problems.
  re   )object_pairs_hookzFailed to load JSON: {0}.N)
rP   rR   ro   r=   loadsr   r\   r   r8   	ParseDict)textr   ignore_unknown_fieldsr$   max_recursion_depthr?   rb   s          r   Parser     s    . 
D#	;;wDH	D,=	>B 
2w 5&
( ( 
 H
077A?
@aGHs   A 	A?$A::A?c                 F    t        |||      }|j                  | |d       |S )a8  Parses a JSON dictionary representation into a message.

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

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

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

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

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

    Raises:
      ParseError: In case of problems converting.
    c              3   8   K   | ]  }|j                   |f  y wr,   )rN   ).0fs     r   	<genexpr>z1_Parser._ConvertFieldValuePair.<locals>.<genexpr>  s#      C#$ !"Q/ Cs   Nz0Message type {0} does not have extensions at {1}r   r   .zaMessage type "{0}" has no field named "{1}" at "{2}".
 Available Fields(except extensions): "{3}"zBMessage type "{0}" should not have multiple "{1}" fields at "{2}".zHMessage type "{0}" should not have multiple "{1}" oneof fields at "{2}".google.protobuf.Valuer   rd   {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   dictrW   ri   rO   _VALID_EXTENSION_NAMEmatchis_extendabler   r8   rB   
Extensions_FindExtensionByNamejoinr   r   rN   appendrZ   rM   rX   r   r.   rY   r0   r   r   rf   rg   setattr
ClearFieldr5   _ConvertMapFieldValuerT   rU   rP   list	enumerateaddr   _ConvertScalarFieldValuerV   SetInParentrR   r\   r   )r:   r?   r   r   namesrG   fields_by_json_namerM   r4   
identifierr   rI   
oneof_namer   indexitemrb   s                    r   r   z_Parser._ConvertFieldValuePair  s	    E ++ C(:(A(AC C w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%//t);)B)BCAAKKC?EF F
 5= 44:F&11;;T45IJ J 	T4!!-%2C--22*5  <<BF!(!3!3!=!=z!%='( ( ,,z
"=nn
 : : J JJ$$..2II!'5::6K%&K"*"<"<"I"IIOO--1LLGUZZ+uzz*
 u


UZZ
(

$
$UGU%.%5%5dD%AC[[J66EEE


UZZ
(E4( **0&ud*CE E^^z99III(/ 	Lt#GUZZ8<<>k,((226MM  "HHN%)4I89 9 !!$"0"7"7dE"JL	L  )/ Nt  "HHN%)4I89 9 guzz*11*E>#8#8tU#KMNN ^^z99III!,,U3K!'5::6K

!
!
#


e[)2B2B42N
O(@ui..tT:)<Gu% ()2)9)9$)EGHKw8 DZ  *U++3-44T1= 3q6"
) 
+
2
24
;
	  
+
2
24
;
	sP   C&W+WWFW*KWW	Y/?XY/&YY/Y**Y/c           	         t        |t              r|sy	 |d   }	 t        || j                        }|j                  }|j                  }t        |      r&| j                  |d   |dj	                  |             nT|t        v r1 t        t        |   d   |d   |dj	                  |            |        n|d= | j                  |||       ||d<   |j                         |_        ||_        y# t        $ r }t        dj	                  |            |d}~ww xY w# t        $ r!}t        dj	                  ||            |d}~ww xY w)z/Convert a JSON representation into Any message.Nr~   z0@type is missing when parsing any message at {0}
{0} at {1}rI   	{0}.valuer   )rP   r   r   r   r8   r   r$   r   rA   rB   rC   r   rE   r   r   SerializeToStringrI   r   )	r:   rI   r   r   r   rb   r   rG   rB   s	            r   _ConvertAnyMessagez_Parser._ConvertAnyMessager  sQ   %uwh<-h8L8LMk %//",,I+,
!!%.+"-"4"4T":<	o	%-l?9-a0%.+%%d+- .
!!%d;eGn113GMG1  :AA$G  <|**1d34!;<s.   C+ D +	D4DD	E D<<Ec                     	 |j                  |       y# t        $ r!}t        dj                  ||            |d}~ww xY w)z?Convert a JSON representation into message with FromJsonString.r   N)FromJsonStringr\   r   r8   )r:   rI   r   r   rb   s        r   _ConvertGenericMessagez_Parser._ConvertGenericMessage  s?    <U# <|**1d34!;<s    	>9>c                    t        |t              r| j                  ||j                  |       yt        |t              r| j                  ||j                  |       y|d|_        yt        |t              r||_	        yt        |t              r||_        yt        |t              r||_        yt        dj                  |t!        |      |            )z1Convert a JSON representation into Value message.Nr   z(Value {0} has unexpected type {1} at {2})rP   r   _ConvertStructMessagestruct_valuer   _ConvertListValueMessager   r   rQ   
bool_valuerR   string_value_INT_OR_FLOATr   r   r8   r-   )r:   rI   r   r   s       r   _ConvertValueMessagez_Parser._ConvertValueMessage  s    %
  (<(<dC	E4	 
##E7+=+=tD	g	E4	  g	E3	"g	E=	)"gAHH
ed$ % %r   c           	         t        |t              st        dj                  ||            |j	                  d       t        |      D ]@  \  }}| j                  ||j                  j                         dj                  ||             B y)z5Convert a JSON representation into ListValue message.z+ListValue must be in [] which is {0} at {1}r   {0}[{1}]N)	rP   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
gnn&8&8&: * 1 1$ >@@r   c           	          t        |t              st        dj                  ||            |j	                          |D ]5  }| j                  ||   |j                  |   dj                  ||             7 y)z2Convert a JSON representation into Struct message.z,Struct must be in a dict which is {0} at {1}r   N)rP   r   r   r8   Clearr   rW   )r:   rI   r   r   r_   s        r   r   z_Parser._ConvertStructMessage  sz    eT"ELL
   MMO =
c
GNN3,? ) 0 0s ;== r   c                     |j                   j                  d   }t        |dt        ||dj	                  |                   y)z3Convert a JSON representation into Wrapper message.rI   r   r   N)rA   rO   r   r   r8   )r:   rI   r   r   r4   s        r   r   z_Parser._ConvertWrapperMessage  s=    --g6E K4F4Ft4LMOr   c           	      V   t        |t              s&t        dj                  |j                  ||            |j
                  j                  d   }|j
                  j                  d   }|D ]  }t        ||dj                  |      d      }|j                  t        j                  j                  k(  r>| j                  ||   t        ||j                        |   dj                  ||             t        ||   |dj                  ||            t        ||j                        |<    y)	af  Convert map field value for a message map field.

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

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

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

  Returns:
    The converted scalar field value

  Raises:
    ParseError: In case of convert problems.
  re      =   zUnpaired surrogateNz(Invalid enum value {0} for enum type {1}r   ) rX   
_INT_TYPES_ConvertIntegerrr   _ConvertFloatr   r.   rp   _ConvertBoolrk   r-   rl   rP   rR   encodelenrm   urlsafe_b64decode_UNPAIRED_SURROGATE_PATTERNsearchr   rf   rg   values_by_nameri   intrh   r\   r8   rB   rj   number)	rI   r4   r   require_strencodedpadded_valuer|   r  rb   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/0
0	:55BB	B??1155eTBj			8u:&77;;FDI* __&&GNNu002 3 3 M! 
C  	8ELLU__..0 1678	8 
 :
\((D1
29:s`   I I 2I 0BI !I 0AI  1H 1AI :I 	I0I  II 	I2I--I2c                 \   t        | t              r*| j                         st        dj	                  |             t        | t
              r.| j                  d      dk7  rt        dj	                  |             t        | t              rt        dj	                  |             t        |       S )zConvert an integer.

  Args:
    value: A scalar value to convert.

  Returns:
    The integer value.

  Raises:
    ParseError: If an integer couldn't be consumed.
  zCouldn't parse integer: {0} r   zCouldn't parse integer: "{0}"z2Bool value {0} is not acceptable for integer field)	rP   rz   
is_integerr   r8   rR   findrQ   r  )rI   s    r   r   r   #  s     ue&6&6&8
3::5A
BBs

32 5
5<<UC
DDt
 %%+VE]4 4 
Ur   c                    t        | t              rt        j                  |       rt	        d      t        j
                  |       r| dkD  rt	        d      t	        d      |j                  t        j                  j                  k(  r<| t        j                  kD  rt	        d      | t        j                  k  rt	        d      | dk(  rt	        d      	 t        |       S # t        $ rk}| 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j#                  |             |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})rP   rz   rs   rw   r   rt   rX   r   r.   ry   r   
_FLOAT_MAX
_FLOAT_MINr\   ru   rv   rx   r8   )rI   r4   rb   s      r   r   r   <  s,   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<   
C   	E)E<EEEE.E4EEc                     |r&| dk(  ry| dk(  ryt        dj                  |             t        | t              st        d      | S )zConvert a boolean value.

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

  Returns:
    The bool parsed.

  Raises:
    ParseError: If a boolean value couldn't be consumed.
  rJ   TrK   Fz#Expected "true" or "false", not {0}z%Expected true or false without quotes)r   r8   rP   rQ   )rI   r  s     r   r   r   `  sN     	'	<CCEJKK	E4	 
<
==	,r   r   r   r   r   r   r   r   r   r   r   )zgoogle.protobuf.Anyzgoogle.protobuf.Durationzgoogle.protobuf.FieldMaskzgoogle.protobuf.ListValuezgoogle.protobuf.Structzgoogle.protobuf.Timestampr   )FF   FFNNTr   )FNd   )F)8r   
__author__rm   collectionsr   r=   rs   operatorr   regoogle.protobuf.internalr   google.protobufr   r   r   	frozensetr.   CPPTYPE_INT32CPPTYPE_UINT32CPPTYPE_INT64CPPTYPE_UINT64r   rq   ry   CPPTYPE_DOUBLErr   rv   ru   rx   compiler  r   	Exceptionr   r   r   r'   r*   r5   objectr   rC   r   r   r   r   r  rz   r   r   r   r   r   r   rE   r   r   r   <module>r&     sA  
 +
  #   ! 	 2 & + + 
22@@"22AA"22@@"22AAC D
 *44BB$44CCE F*44BB$44CCE F	(bjjMO  #

#:; 0I 0/5 /) ) $) % )H\ $) % #/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   