
    w              	          S r SSKrSSKrSSKrSSKrSSKrSSKJr  SSKJr  SSKJ	r	  SSK
Jr  \R                  " SSS	/5      r\R                  " S
SS/5      r " S S\5      r " S S\R                  " S/ SQ5      5      r0 r0 r0 r0 rS rS rS rS rS rS:S jrS rS rS r S;S jrS r S r!S;S jr"S r#S  r$S! r%S" r& " S# S$\	RN                  5      r(S% r)S& r*S' r+S( r,S) r-S* r.S+ r/S, r0S- r1\" \.\/5      " \Rd                  5        0 r30 r4 S:S. jr5 S:S/ jr6S<S0 jr7S<S1 jr8  S=S2 jr9S3 r:S4 r;S5 r<S6 r=S7 r>S8 r?S>S9 jr@g)?z@Common code for converting proto to other formats, such as JSON.    N)message_types)messages)	protojson)
exceptions_CodecencoderdecoderCodecResultvaluecompletec                   $    \ rS rSrSrSrSrSrSrg)EdgeType$   z'The type of transition made by an edge.          N)	__name__
__module____qualname____firstlineno____doc__SCALARREPEATEDMAP__static_attributes__r       3lib/third_party/apitools/base/py/encoding_helper.pyr   r   $   s    1FH
Cr   r   c                   "    \ rS rSrSrSrS rSrg)	ProtoEdge+   a  A description of a one-level transition from a message to a value.

Protobuf messages can be arbitrarily nested as fields can be defined with
any "message" type. This nesting property means that there are often many
levels of proto messages within a single message instance. This class can
unambiguously describe a single step from a message to some nested value.

Properties:
  type_: EdgeType, The type of transition represented by this edge.
  field: str, The name of the message-typed field.
  index: Any, Additional data needed to make the transition. The semantics
      of the "index" property change based on the value of "type_":
        SCALAR: ignored.
        REPEATED: a numeric index into "field"'s list.
        MAP: a key into "field"'s mapping.
r   c                     U R                   [        R                  :X  a  U R                  $ SR	                  U R                  U R
                  5      $ )Nz{}[{}])type_r   r   fieldformatindex)selfs    r   __str__ProtoEdge.__str__?   s5    ::(::??4::tzz::r   N)r   r   r   r   r   	__slots__r(   r   r   r   r   r    r    +   s      I;r   r    )r#   r$   r&   c                    ^  U 4S jnU$ )z;Register field_name as a container for unrecognized fields.c                    > T[         U '   U $ N)_UNRECOGNIZED_FIELD_MAPPINGS)cls
field_names    r   Register'MapUnrecognizedFields.<locals>.RegisterO   s    ,6$S)
r   r   )r0   r1   s   ` r   MapUnrecognizedFieldsr3   M   s     Or   c                    ^ ^ UU 4S jnU$ )z9Register a custom encoder/decoder for this message class.c                 *   > [        TTS9[        U '   U $ N)r   r	   )r   _CUSTOM_MESSAGE_CODECS)r/   r	   r   s    r   r1   ,RegisterCustomMessageCodec.<locals>.RegisterW   s    &,Wg&Ns#
r   r   r   r	   r1   s   `` r   RegisterCustomMessageCodecr:   U   s     Or   c                    ^ ^ UU 4S jnU$ )z1Register a custom encoder/decoder for this field.c                 *   > [        TTS9[        U '   U $ r6   )r   _CUSTOM_FIELD_CODECS)r$   r	   r   s    r   r1   *RegisterCustomFieldCodec.<locals>.Register_   s    &,Wg&NU#r   r   r9   s   `` r   RegisterCustomFieldCodecr?   ]   s     Or   c                    ^ ^ UU 4S jnU$ )z>Register a custom encoder/decoder for all fields of this type.c                 *   > [        TTS9[        U '   U $ r6   )r   _FIELD_TYPE_CODECS)
field_typer	   r   s    r   r1   (RegisterFieldTypeCodec.<locals>.Registerg   s    )/W*.:&r   r   r9   s   `` r   RegisterFieldTypeCodecrE   e   s     Or   c                 >    [        [        U 5      [        U 5      5      $ )zMake a deep copy of a message.)JsonToMessagetypeMessageToJsonmessages    r   CopyProtoMessagerL   n   s    gg(>??r   c                 `    [         R                  5       R                  U 5      n[        X U5      $ )z"Convert the given message to JSON.)_ProtoJsonApiToolsGetencode_message_IncludeFields)rK   include_fieldsresults      r   rI   rI   s   s(    ##%44W=F&>::r   c                 H    [         R                  5       R                  X5      $ )z9Convert the given JSON to a message of type message_type.)rN   rO   decode_message)message_typerK   s     r   rG   rG   y   s    !!#22<IIr   c                 B    [        U[        R                  " U 5      5      $ )z?Convert the given dictionary to a message of type message_type.rG   jsondumps)drV   s     r   DictToMessager\      s    tzz!}55r   c                 @    [         R                  " [        U 5      5      $ )z*Convert the given message to a dictionary.rY   loadsrI   rJ   s    r   MessageToDictr`          ::mG,--r   c                     U R                  5       nU(       a  [        U5      n/ nU H#  u  pVUR                  UR                  XVS95        M%     U" US9$ )z>Convert the given dictionary to an AdditionalProperty message.keyr   )additionalProperties)itemssortedappendAdditionalProperty)
propertiesadditional_property_type
sort_itemsrf   map_rd   r   s          r   DictToAdditionalPropertyMessagern      s_     EuD
,?? @ " 	#  $>>r   c                 B    [        U [        R                  " U5      5      $ )zAConvert the given python value to a message of type message_type.rX   )rV   r   s     r   PyValueToMessagerp      s    tzz%'899r   c                 @    [         R                  " [        U 5      5      $ )z,Convert the given message to a python value.r^   rJ   s    r   MessageToPyValuerr      ra   r   c                 ^  ^^ TR                  SS5      nS n[        U [        5      (       aS  SnU  H2  nU(       a  USSUS-   -  -   -  nU[        U4SU0U" T5      D6S	-   -  nM4     U(       a  USSU-  -   -  nUS
-  nU$ [        U [        R
                  5      (       a  [        U 5      R                  S-   nTR                  S5      (       d  U R                  S-   U-   n[        U R                  5        Vs/ s H  owR                  PM     sn5      nU Hg  n	U R                  U	5      nU(       a  USSUS-   -  -   -  n[        XR                  5      n
XWR                  S-   [        U
4SU0U" T5      D6-   S	-   -  nMi     U(       a  USSU-  -   -  nUS-  nU$ [        U [        R                  5      (       a*  TR                  S5      (       a  [!        U 5      S:  a  U SS n [        U ["        R"                  5      (       a   " UU4S jS["        R$                  5      m["        R"                  " U R&                  U R(                  U R*                  U R,                  U R.                  U R0                  U R2                  T" U R$                  R5                  S5      5      5      n [7        U 5      $ s  snf )a  Return a repr-style string for a protorpc message.

protorpc.Message.__repr__ does not return anything that could be considered
python code. Adding this function lets us print a protorpc message in such
a way that it could be pasted into code later, and used to compare against
other things.

Args:
  msg: protorpc.Message, the message to be repr'd.
  multiline: bool, True if the returned string should have each field
      assignment on its own line.
  **kwargs: {str:str}, Additional flags for how to format the string.

Known **kwargs:
  shortstrings: bool, True if all string values should be
      truncated at 100 characters, since when mocking the contents
      typically don't matter except for IDs, and IDs are usually
      less than 100 characters.
  no_modules: bool, True if the long module name should not be printed with
      each type.

Returns:
  str, A string of valid python (assuming the right imports have been made)
  that recreates the message passed into this function.

indentr   c                 L    [        U 5      n U R                  SS5      S-   U S'   U $ )Nrt   r      )dictget)kwargss    r   IndentKwargs#MessageToRepr.<locals>.IndentKwargs   s*    f!::h2Q6xr   [
 rv   	multiline,](
no_modules.=)shortstringsd   Nc                   8   >^  \ rS rSrUU 4S jrU4S jrSrU =r$ )$MessageToRepr.<locals>.SpecialTZInfo   c                 .   > [         TU ]  5         Xl        g r-   )super__init__offset)r'   r   SpecialTZInfo	__class__s     r   r   -MessageToRepr.<locals>.SpecialTZInfo.__init__   s    mT35$r   c                 t   > S[        U R                  5      -   S-   nTR                  S5      (       d  SU-   nU$ )NzTimeZoneOffset(r   r   z apitools.base.protorpclite.util.)reprr   rx   )r'   sry   s     r   __repr__-MessageToRepr.<locals>.SpecialTZInfo.__repr__   s9    %T[[(99C?zz,//:Q>Ar   )r   )r   r   r   r   r   r   r   __classcell__)r   r   ry   s   @r   r   r      s    % r   r   )rx   
isinstancelistMessageToReprr   MessagerH   r   r   rg   
all_fieldsnamefield_by_namegetattrsixstring_typeslendatetimetzinfoyearmonthdayhourminutesecondmicrosecond	utcoffsetr   )msgr   ry   rt   rz   r   itemr$   namesr   r   r   s     `        @r   r   r      s   < ZZ!$F
 #tDTC6A:...C )C-9&-ACEHI IA 
 f$$A	S#x''((I$zz,''$q(A0@A0@u

0@ABD%%d+ETC6A:...C,Ec!M%D!*%D.:6.B%D DFIJ JA  f$$A	S#s''((::n%%#c(S.ds)C#x(())
	 
	HOO 
	 HHcii#((CJJ

OO]3::+?+?+BCE 9G Bs   6J*c                 h    U H+  nU[        U 5      ;  a  [        SU-  5      e[        X5      n M-     U $ )Nzno field "%s")dirKeyErrorr   )rK   
field_pathr$   s      r   	_GetFieldr      s9    G$?U233')  Nr   c                 N    US S  H  nU R                  U0 5      n M     X US   '   g )N)
setdefault)dictblobr   r   r$   s       r   	_SetFieldr     s0    CR&&ub1 !$Z^r   c           
      ~   Uc  U $ [         R                  " U 5      nU HR  n [        XR                  S5      5      nSn[	        U[
        5      (       a  / n[        X4R                  S5      U5        MT     [         R                  " U5      $ ! [         a(    [        R                  " SU< S[        U5      < 35      ef = f)z0Add the requested fields to the encoded message.Nr   zNo field named z in message of type )rY   r_   r   splitr   r   r   r   InvalidDataErrorrH   r   rZ   )encoded_messagerK   rR   rS   r0   r   	nullvalues          r   rQ   rQ   	  s    ZZ(F$
	0g'7'7'<=EI%&&	
 	&**3/; % ::f  	0--W/0 0	0s   3B

2B<c                     [        [        R                  U 5      US 5      [        [        R                  [	        U 5      5      US 5      /nU Vs/ s H	  o3c  M  UPM     sn$ s  snf r-   )r   r=   rx   rB   rH   )r$   attrrS   xs       r   _GetFieldCodecsr     sW    $((/t<"&&tE{3T4@F /v!Av///s   A!A!c                   d   ^  \ rS rSrSrSr\S 5       rU 4S jrU 4S jr	U 4S jr
U 4S jrS	rU =r$ )
rN   i$  z&JSON encoder used by apitools clients.Nc                 L    U R                   c  U " 5       U l         U R                   $ r-   )	_INSTANCE)r/   s    r   rO   _ProtoJsonApiTools.Get)  s    == ECM}}r   c                    > U[         ;   a  [         U   R                  U5      $ [        X5      n[        [        U ]  X5      n[        X25      n[        X25      n[        X25      $ r-   )	r7   r	   _DecodeCustomFieldNamesr   rN   rU   _ProcessUnknownEnums_ProcessUnknownMessages_DecodeUnknownFields)r'   rV   r   rS   r   s       r   rU   !_ProtoJsonApiTools.decode_message/  sd    11)%go67(G)4?"%f>(A#F<<r   c                 f  > [        US5       H,  nU" X5      nUR                  nUR                  (       d  M*  Us  $    [        U[        R
                  5      (       a2  U R                  UR                  [        R                  " U5      5      nU$ [        U[        R                  5      (       a3  [        UR                  US9=(       d    Un [        [        U ]?  X5      nU$ [        [        U ]?  X5      nU$ ! [        R                    a&    [        U["        R$                  5      (       d  e Sn U$ f = f)zDecode the given JSON value.

Args:
  field: a messages.Field for the field we're decoding.
  value: a python value we'd like to decode.

Returns:
  A value suitable for assignment to field.
r	   	json_nameN)r   r   r   r   r   MessageFieldrU   rV   rY   rZ   	EnumFieldGetCustomJsonEnumMappingrH   r   rN   decode_fieldDecodeErrorr   r   )r'   r$   r   r	   rS   field_valuer   s         r   r   _ProtoJsonApiTools.decode_field:  s*    'ui8GU*FLLE	 9
 eX2233--""DJJu$57K  x1122,

e- 605 ##&;;@.H    "D77<*D  '' #!%)9)9::" #s   C6 66D0/D0c                   >^  [        U[        R                  5      (       a  SSR                  U 4S jU 5       5      -  $ [	        U5      [
        ;   a!  [
        [	        U5         R                  U5      $ [        U5      n[        [        T ]+  U5      n[        X5      n[        R                  " [        R                  " U5      SS9$ )Nz[%s]z, c              3   F   >#    U  H  nTR                  U5      v   M     g 7fr-   )rP   ).0r   r'   s     r   	<genexpr>4_ProtoJsonApiTools.encode_message.<locals>.<genexpr>]  s&      '9071 (,':':1'='=07s   !T)	sort_keys)r   r   	FieldListjoinrH   r7   r   _EncodeUnknownFieldsr   rN   rP   _EncodeCustomFieldNamesrY   rZ   r_   )r'   rK   rS   r   s   `  r   rP   !_ProtoJsonApiTools.encode_message[  s    gx1122TYY '907'9 9 : : =22)$w-8@@II&w/)4?H(9zz$**V,==r   c                   > [        US5       H,  nU" X5      nUR                  nUR                  (       d  M*  Us  $    [        U[        R
                  5      (       az  UR                  (       aB  U Vs/ s H4  n[        UR                  UR                  S9=(       d    UR                  PM6     nnO[        UR                  UR                  S9nU(       a  U$ [        U[        R                  5      (       aD  [        U[        R                  5      (       d%  [        R                  " U R                  U5      5      n[         ["        U ]K  X5      $ s  snf )zEncode the given value as JSON.

Args:
  field: a messages.Field for the field we're encoding.
  value: a value for field.

Returns:
  A python value suitable for json.dumps.
r   python_name)r   r   r   r   r   r   repeatedr   rH   r   r   r   DateTimeFieldrY   r_   rP   r   rN   encode_field)r'   r$   r   r   rS   eremapped_valuer   s          r   r   _ProtoJsonApiTools.encode_fieldi  s    'ui8GU*FLLE	 9
 eX//00~~GL"NGL! #;JJAFF#4 #>78vv#>GL  "N ":JJEJJ"8%%uh3344um&A&ABBJJt2259:E';EII"Ns   2;Er   )r   r   r   r   r   r   classmethodrO   rU   r   rP   r   r   r   )r   s   @r   rN   rN   $  s9    0I 
	=B>J Jr   rN   c                    [         R                  [        U 5      5      nUc  U $ U R                  U5      n[	        U[
        R                  5      (       d  [        R                  " S5      eUR                  n[	        UR                  [
        R                  5      (       a"  [        U [        R                  " U5      U5      nO[        X5      n[        XU5        [        U S0 5        U $ )z;Rewrite unknown fields in message into message.destination.z>Unrecognized fields must be mapped to a compound message type._Message__unrecognized_fields)r.   rx   rH   r   r   r   r   r   InvalidDataFromServerErrorrV   r   _DecodeUnknownMessagesrY   r_   _DecodeUnrecognizedFieldssetattr)rK   r   destination
pair_field	pair_type
new_valuess         r   r   r     s    .224=AK&&{3Jj("7"78833 	 ''I )//8#8#899+TZZ0)=
 /wB
G*- G4b9Nr   c                 n   UR                   R                  n/ nU R                  5        Vs/ s H  oUR                  PM     nn[        R
                  " U5       HT  u  pxXv;   a  M  [        X85      n	UR                   R                  (       a  [        U	5      n	U" XyS9n
UR                  U
5        MV     U$ s  snf )z<Process unknown fields in encoded_message of a message type.rc   )
r   rH   r   r   r   	iteritemsrp   r   _AsMessageListrh   )rK   r   r   rC   r   r   all_field_namesr   
value_dictr   new_pairs              r   r   r     s    %%JJ'.'9'9';<';!vv';O<MM/:" 8??##"5)E3(# ;  =s   B2c                 "   / n[         R                  5       nU R                  5        H  nU R                  U5      u  pVUR	                  S5      n[        U[        R                  5      (       a   [        XQR                  R                  5      nOUR                  UR                  U5      n [        U5      n	U" XS9n
UR#                  U
5        M     U$ ! [         a2    [        R                  " 5       R                  UR                   U5      n	 NXf = f)z'Process unrecognized fields in message.r   rc   )rN   rO   all_unrecognized_fieldsget_unrecognized_field_infor   r   r   r   r\   r   rV   r   strUnicodeEncodeErrorr   	ProtoJsonrd   rh   )rK   r   r   codecunknown_fieldr   _
value_typedecoded_valuenew_pair_keyr   s              r   r   r     s    J""$E 88:
 66}E,,W5
j("7"788)%1M1MNM!..(M	.}-L C(#% ;&  " 	.$..0==}.L	.s   *C9DDc                     [         R                  " 5       nUR                  [        U 5      UR	                  U 5      5      $ r-   )r   r  rU   rH   rP   )rK   r  s     r   !_CopyProtoMessageVanillaProtoJsonr
    s2    !EWu/C/CG/LMMr   c                    [         R                  [        U 5      5      nUc  U $ [        U 5      nU R	                  U5      n[        U[        R                  5      (       d  [        R                  " SU-  5      eUR                  nUR	                  S5      nUR                  n[        X5      n[        R                  5       nU H:  n	UR                  XYR                   5      n
UR#                  U	R$                  X5        M<     ['        X!/ 5        U$ )z6Remap unknown fields in message out of message.source.zInvalid pairs field %sr   )r.   rx   rH   r
  r   r   r   r   r   InvalidUserInputErrorrV   variantr   rN   rO   r   r   set_unrecognized_fieldrd   r   )rK   sourcerS   pairs_field
pairs_typevalue_fieldvalue_variantpairsr  pairencoded_values              r   r   r     s    )--d7m<F~ /w7F''/Kk8#8#899..${24 	4))J**73K''MG$E""$E**;

C%%dhhM  FBMr   c                      U R                   (       a'  U Vs/ s H  n[        R                  " U5      PM     nnO[        R                  " U5      nSn[	        X4S9$ s  snf ! [         a    UnSn Nf = f)z,Encode the bytes in value as urlsafe base64.TFr   r   )r   base64urlsafe_b64encode	TypeErrorr
   )r$   r   byterS   r   s        r   _SafeEncodeBytesr    sr    >>AFGf..t4FGF--e4F V77 H  s!   A   AA  A   A10A1c                      [         R                  " [        U5      5      nSn[	        X#S9$ ! [         a    UnSn Nf = f)z+Decode the urlsafe base64 value into bytes.TFr  )r  urlsafe_b64decoder   r  r
   )unused_fieldr   rS   r   s       r   _SafeDecodeBytesr!    sH    ))#e*5 V77  s   !, ==c                 ,   U(       d  U $ [         R                  " [        R                  " U5      5      nU R	                  5        H  n[        U[        R                  5      (       d  M$  UR                  U;   d  M6  U R                  UR                  5      nUR                  (       a$  [        U5      [        X#R                     5      :w  d  Ub  M  U R                  UR                  X#R                     [        R                  R                  5        M     U $ )a:  Add unknown enum values from encoded_message as unknown fields.

ProtoRPC diverges from the usual protocol buffer behavior here and
doesn't allow unknown fields. Throwing on unknown fields makes it
impossible to let servers add new enum values and stay compatible
with older clients, which isn't reasonable for us. We simply store
unrecognized enum values as unknown fields, and all is well.

Args:
  message: Proto message we've decoded thus far.
  encoded_message: JSON string we're decoding.

Returns:
  message, with any unknown enums stored as unrecognized fields.
)rY   r_   r   
ensure_strr   r   r   r   r   get_assigned_valuer   r   r  VariantENUM)rK   r   decoded_messager$   r   s        r   r   r     s      jj!@AO##%uh0011

o-..uzz:ECJ#ojj6Q2R$RM..JJ

 ;X=M=M=R=RT & Nr   c                    U(       d  U $ [         R                  " [        R                  " U5      5      nU R	                  5        Vs/ s H  o3R
                  PM     sn[        U R                  5       5      -   nUR                  5        Vs/ s H  nX4;  d  M
  UPM     nnU H0  nU R                  XbU   [        R                  R                  5        M2     U $ s  snf s  snf )a  Store any remaining unknown fields as strings.

ProtoRPC currently ignores unknown values for which no type can be
determined (and logs a "No variant found" message). For the purposes
of reserializing, this is quite harmful (since it throws away
information). Here we simply add those as unknown fields of type
string (so that they can easily be reserialized).

Args:
  message: Proto message we've decoded thus far.
  encoded_message: JSON string we're decoding.

Returns:
  message, with any remaining unrecognized fields saved.
)rY   r_   r   r#  r   r   r   r   keysr  r   r%  STRING)rK   r   r'  r   message_fieldsmissing_fieldsr0   s          r   r   r     s      jj!@AO&-&8&8&:;&:ff&:;d'')?+ +N!0!5!5!7 2!7A0 !7N 2$
&&z:3N'/'7'7'>'>	@ % N <2s   C
	CCc                 $   [        U [        R                  5      (       d  [        R                  " SU -  5      eXR                  5       ;  a  [        R                  " SU< SU < 35      e[        R                  U 0 5      n[        SXU5        X$U'   g)a  Add a custom wire encoding for a given enum value.

This is primarily used in generated code, to handle enum values
which happen to be Python keywords.

Args:
  enum_type: (messages.Enum) An enum type
  python_name: (basestring) Python name for this value.
  json_name: (basestring) JSON name to be used on the wire.
  package: (NoneType, optional) No effect, exists for legacy compatibility.
z.Cannot set JSON enum mapping for non-enum "%s"zEnum value z not a value for type enumN)

issubclassr   Enumr   TypecheckErrorr   r   _JSON_ENUM_MAPPINGSr   _CheckForExistingMappings)	enum_typer   r   packagefield_mappingss        r   AddCustomJsonEnumMappingr7  E  s     i//''<yHJ 	J//++))7BINP 	P(33IrBNfiiH"+;r   c                 >   [        U [        R                  5      (       d  [        R                  " SU -  5      e U R                  U5      n[        R                  U 0 5      n[        SXU5        X%U'   g! [         a    [        R                  " SU< SU < 35      ef = f)a  Add a custom wire encoding for a given message field.

This is primarily used in generated code, to handle enum values
which happen to be Python keywords.

Args:
  message_type: (messages.Message) A message type
  python_name: (basestring) Python name for this value.
  json_name: (basestring) JSON name to be used on the wire.
  package: (NoneType, optional) No effect, exists for legacy compatibility.
z2Cannot set JSON field mapping for non-message "%s"zField z not recognized for type r$   N)r/  r   r   r   r1  r   r   r   _JSON_FIELD_MAPPINGSr   r3  )rV   r   r   r5  r  r6  s         r   AddCustomJsonFieldMappingr:  ]  s     lH$4$455''!-./ 	/,&&{3
 *44\2FNg|)L"+;  ,))\+, 	,,s   A3 3)Bc                 "    [        U SX[        S9$ )z=Return the appropriate remapping for the given enum, or None.r.  r   r   mappings)_FetchRemappingr2  )r4  r   r   s      r   r   r   y  s    9f'2$79 9r   c                 "    [        U SX[        S9$ )z>Return the appropriate remapping for the given field, or None.r$   r<  )r>  r9  )rV   r   r   s      r   GetCustomJsonFieldMappingr@    s    <'2$8: :r   c                    U(       a   U(       a  [         R                  " SU-  5      eU(       d"  U(       d  [         R                  " SU< S35      eUR                  U 0 5      nU(       a\  U(       a  UR                  U5      $ U(       a=  U[        UR	                  5       5      ;   a   U Vs/ s H  nXV   U:X  d  M  UPM     snS   $ gs  snf )z>Common code for fetching a key or value from a remapping dict.z>Cannot specify both python_name and json_name for %s remappingz1Must specify either python_name or json_name for z
 remappingr   N)r   r   rx   r   values)	type_namemapping_typer   r   r=  field_remappingsks          r   r>  r>    s     y))!-./ 	/ 9))  	   ||Ir2#''44D!1!8!8!:;;#3 =#3a+.); #3 ==>@ @=s   *C:Cc           	          U S:X  a  [         nOU S:X  a  [        nW" XS9nUb(  XS:w  a#  [        R                  " SU < SU< SU< S35      eU" XS	9nUb)  XR:w  a#  [        R                  " SU < SU< SU< S35      egg)
z5Validate that no mappings exist for the given values.r$   r.  r   NzCannot add mapping for z "z", already mapped to ""r   )r@  r   r   r   )rD  rV   r   r   getter	remappings         r   r3  r3    s     w*		)|=I!7))k967 	7 |9I!9))i45 	5 ":r   c                 "   [        [        R                  [        U 5      0 5      R	                  5       5      nU(       aQ  [
        R                  " U5      nU H  u  pEXA;   d  M  UR                  U5      X5'   M!     [
        R                  " U5      nU$ r-   )	r   r9  rx   rH   rf   rY   r_   poprZ   )rK   r  rE  r  r   r   s         r   r   r     su    044T']BG"UW&

=1&6"K++8+<+<[+I( '7 

=1r   c                    [         R                  U 0 5      nU(       ah  [        R                  " U5      n[	        UR                  5       5       H  u  pEXS;   d  M  UR                  U5      X4'   M!     [        R                  " U5      nU$ r-   )r9  rx   rY   r_   r   rf   rL  rZ   )rV   r   rE  r'  r   r   s         r   r   r     sr    +//bA**_5&*+;+A+A+C&D"K+/>/B/B9/M, 'E **_5r   c                    ^ SSK Jm  U4S jnU" U 5      (       d  [        S5      e[        U TR                  5      (       a  U R
                  n [        U TR                  5      (       a  U R                  n U $ )z1Convert the provided list-as-JsonValue to a list.r   )extra_typesc                    > [        U TR                  5      (       a  g[        U TR                  5      (       a  U R                  (       a  gg)z6Return True if msg is a repeated value as a JsonValue.TF)r   	JsonArray	JsonValuearray_value)r   rO  s    r   _IsRepeatedJsonValue,_AsMessageList.<locals>._IsRepeatedJsonValue  s8    c;0011c;0011coor   z"invalid argument to _AsMessageList)apitools.base.pyrO  
ValueErrorr   rR  rS  rQ  entries)r   rT  rO  s     @r   r   r     sc     -  $$=>>#{,,--oo#{,,--kkJr   c                     U R                  UR                  5      n[        U[        R                  5      (       d  g UR                  S5      nUR                  $ ! [         a     gf = f)z3Returns whether the "field" is actually a map-type.Fre   )r$  r   r   r   r   r   r   r   )rK   r$   r   additional_propertiess       r   _IsMapr[    se    &&uzz2EeX--... % 3 34J K %---  s   A 
A'&A'c              #      #    [        X5      (       d   eU R                  UR                  5      nUR                  S5      nU H  nUR                  UR                  4v   M     g7f)z/Yields the (key, value) pair of the map values.re   N)r[  r$  r   rd   r   )rK   r$   map_messagerZ  kv_pairs        r   	_MapItemsr_    s[     '!!!!,,UZZ8K':: (kk7==(( )s   A#A%c              #      #    [        U [        R                  5      (       d  gU R                  5       nU(       a  X4v   gU R	                  5        GH8  nU R                  UR                  5      nUR                  (       aZ  [        U5       HI  u  pV[        [        R                  UR                  U5      n[        XaU4-   5      nU H
  u  pX4v   M     MK     M  [        X5      (       aZ  [        X5       HI  u  p[        [        R                  UR                  U5      n[        XaU4-   5      nU H
  u  pX4v   M     MK     M  [        [        R                   UR                  S5      n[        XAU4-   5      nU H
  u  pX4v   M     GM;     g7f)a  Yields the locations of unrecognized fields within "message".

If a sub-message is found to have unrecognized fields, that sub-message
will not be searched any further. We prune the search of the sub-message
because we assume it is malformed and further checks will not yield
productive errors.

Args:
  message: The Message instance to search.
  _edges: Internal arg for passing state.

Yields:
  (edges_to_message, field_names):
    edges_to_message: List[ProtoEdge], The edges (relative to "message")
        describing the path to the sub-message where the unrecognized
        fields were found.
    field_names: List[Str], The names of the field(s) that were
        unrecognized in the sub-message.
N)r   r   r   r   r   r$  r   r   	enumerater    r   r   UnrecognizedFieldIterr[  r_  r   r   )rK   _edgesfield_namesr$   r   ir   repeated_edgeiter_r   yrd   map_edgescalar_edges                 r   rb  rb    sL    ( gx//00113K!! ##%**5::6>>$U+ )(*;*;UZZ K-dm=M4MN#FQ$J $ ,
 G##&w6	$X\\5::sC-dh[4HI#FQ$J $ 7 $HOOUZZFK)%;.1HIEd
  # &s   FFr-   )F)NN)NNN)r   )Ar   r  collectionsr   rY   r   apitools.base.protorpcliter   r   r   rV  r   
namedtupler   r
   objectr   r    r.   r7   r=   rB   r3   r:   r?   rE   rL   rI   rG   r\   r`   rn   rp   rr   r   r   r   rQ   r   r  rN   r   r   r   r
  r   r  r!  r   r   
BytesFieldr2  r9  r7  r:  r   r@  r>  r3  r   r   r   r[  r_  rb  r   r   r   <module>rp     s  " G     
 4 / 0 ' 
		9i*@	A$$]Wj4IJv ;&&{'BD ;8  "    @
;J6
. 05
?:
.
Xv%&0`J,, `JH2 4N
088<: ')9 :8;N;N O
    &*,2 '+,89: JN!,5&	2
.)1r   