
    =                        S r SSKJr  SSKrSSKJr  SSKJr   " S S\5      r	 " S S	\R                  5      r\R                  \	\R                  5         " S
 S\5      r " S S\5      r " S S\5      r " S S\5      rS rS r " S S\5      r " S S\5      r " S S\\5      r " S S\5      r " S S\5      r " S S\5      r\" \5      r\" \5      r\" \5      r \" \!5      r"\" \RF                  5      r$\" \%5      r& " S  S!\5      r' " S" S#\5      r( " S$ S%\5      r) " S& S'\5      r* " S( S)\5      r+ " S* S+\5      r, " S, S-\5      r- " S. S/\5      r. " S0 S1\5      r/ " S2 S3\5      r0 " S4 S5\05      r1 " S6 S7\05      r2g)8a  Validation tools for generic object structures.

This library is used for defining classes with constrained attributes.
Attributes are defined on the class which contains them using validators.
Although validators can be defined by any client of this library, a number
of standard validators are provided here.

Validators can be any callable that takes a single parameter which checks
the new value before it is assigned to the attribute.  Validators are
permitted to modify a received value so that it is appropriate for the
attribute definition.  For example, using int as a validator will cast
a correctly formatted string to a number, or raise an exception if it
can not.  This is not recommended, however.  the correct way to use a
validator that ensure the correct type is to use the Type validator.

This validation library is mainly intended for use with the YAML object
builder.  See yaml_object.py.
    )absolute_importN)
six_subset)yamlc                   2   ^  \ rS rSrSrU 4S jrS rSrU =r$ )
SortedDict-   zDRepresents a dict with a particular key order for yaml representing.c                 X   > [         [        U ]  5         Xl        U R	                  U5        g N)superr   __init__keysupdate)selfr   data	__class__s      .lib/googlecloudsdk/appengine/api/validation.pyr   SortedDict.__init__0   s!    	*d$&IKK    c                     / nU R                    H8  nU R                  U5      c  M  UR                  X R                  U5      45        M:     U$ r
   )r   getappend)r   resultkeys      r   ordered_itemsSortedDict.ordered_items5   sA    Fyy	#	"sHHSM*+  Mr   )r   )	__name__
__module____qualname____firstlineno____doc__r   r   __static_attributes____classcell__r   s   @r   r   r   -   s    L
 r   r   c                   0   ^  \ rS rSrSrSU 4S jjrSrU =r$ )
ItemDumper=   z?For dumping validation.Items. Respects SortedDict key ordering.c                    > [        US5      (       a   [        [        U ]  XR	                  5       US9$ [        [        U ]  XUS9$ )Nr   )
flow_style)hasattrr   r%   represent_mappingr   )r   tagmappingr(   r   s       r   r*   ItemDumper.represent_mapping@   sU    w((:t6
$$&: 7 ? ?T4 5 - -r    r
   )r   r   r   r   r    r*   r!   r"   r#   s   @r   r%   r%   =   s    G- -r   r%   c                       \ rS rSrSrSrg)ErrorL   z"Base class for all package errors.r.   Nr   r   r   r   r    r!   r.   r   r   r0   r0   L   s    *r   r0   c                       \ rS rSrSrSrg)AttributeDefinitionErrorP   z8An error occurred in the definition of class attributes.r.   Nr2   r.   r   r   r4   r4   P   s    @r   r4   c                   (    \ rS rSrSrSS jrS rSrg)ValidationErrorT   z4Base class for raising exceptions during validation.Nc                     [        US5      (       a3  UR                  (       a"  [        R                  " X/UR                  Q76   O[        R                  X5        Xl        X l        g)zInitialize exception.argsN)r)   r:   r0   r   messagecause)r   r;   r<   s      r   r   ValidationError.__init__W   sB    uf%**nnT0UZZ0 nnT#LJr   c                 ,    [        U R                  5      $ r
   )strr;   r   s    r   __str__ValidationError.__str__b   s    t||r   )r<   r;   r
   )r   r   r   r   r    r   rA   r!   r.   r   r   r7   r7   T   s    <	r   r7   c                   ,   ^  \ rS rSrSrU 4S jrSrU =r$ )MissingAttributef   z8Raised when a required attribute is missing from object.c                 N   > SR                  U5      n[        [        U ]  U5        g )NzMissing required value [{}].)formatr   rD   r   )r   r   msgr   s      r   r   MissingAttribute.__init__i   s#    
(
/
/
4C	
D*3/r   r.   )r   r   r   r   r    r   r!   r"   r#   s   @r   rD   rD   f   s    @0 0r   rD   c                    [         R                  " U 5      (       d  U [         R                  :X  a
  [        5       $ [	        U [
        [         R                  45      (       a  [        U [        U 5      5      $ [	        U [        5      (       a  [        U 5      $ [	        U [        [        [        45      (       a  [        [        U 5      6 $ [	        U [        5      (       a  U $ [        S[        U 5      -  5      e)a  Wrap various types as instances of a validator.

Used to allow shorthand for common validator types.  It
converts the following types to the following Validators.

  strings -> Regex
  type -> Type
  collection -> Options
  Validator -> Its self!

Args:
  validator: Object to wrap in a validator.

Returns:
  Validator instance that wraps the given value.

Raises:
  AttributeDefinitionError: if validator is not one of the above described
    types.
z%s is not a valid validator)r   is_basestringstring_typesStringValidator
isinstancer?   	text_typeRegextypeTypelisttuplesetOptions	Validatorr4   	validators    r   AsValidatorrZ   n   s    * y))	j--	-	C!5!5677DO,,	4  	?	D%-..E)$%%	9%%
"#@#&y>$2 3 3r   c                    [        U[        5      (       a  UR                  5       $ [        U[        [        45      (       a  U Vs/ s H  n[        X5      PM     sn$ [        U [        5      (       a  U R                  U5      $ U$ s  snf )a  Convert any value to simplified collections and basic types.

Args:
  validator: An instance of Validator that corresponds with 'value'.
    May also be 'str' or 'int' if those were used instead of a full
    Validator.
  value: Value to convert to simplified collections.

Returns:
  The value as a dictionary if it is a ValidatedBase object.  A list of
  items converted to simplified collections if value is a list
  or a tuple. Otherwise, just the value.
)rN   ValidatedBaseToDictrS   rT   _SimplifiedValuerW   ToValue)rY   valueitems      r   r^   r^      sr     }%%<<>%$'':?@%$Y-%@@)Y''U##	, As   Bc                   L    \ rS rSrSr\S 5       rS rS rS r	S r
S rS	 rS
rg)r\      z%Base class for all validated objects.c                     [        S5      e)a  Safely get the Validator corresponding to the given key.

This function should be overridden by subclasses

Args:
  key: The attribute or item to get a validator for.

Returns:
  Validator associated with key or attribute.

Raises:
  ValidationError: if the requested key is illegal.
z7Subclasses of ValidatedBase must override GetValidator.NotImplementedErrorclsr   s     r   GetValidatorValidatedBase.GetValidator   s      7 8 8r   c                 X    UR                  5        H  u  p#U R                  X#5        M     g)zSet multiple values on Validated instance.

All attributes will be validated before being set.

Args:
  attributes: A dict of attributes/items to set.

Raises:
  ValidationError: when no validated attribute exists on class.
N)itemsSet)r   
attributesr   r`   s       r   SetMultipleValidatedBase.SetMultiple   s%     !&&(

hhs )r   c                     [        S5      e)a,  Set a single value on Validated instance.

This method should be overridded by sub-classes.

This method can only be used to assign validated attributes/items.

Args:
  key: The name of the attributes
  value: The value to set

Raises:
  ValidationError: when no validated attribute exists on class.
z.Subclasses of ValidatedBase must override Set.re   r   r   r`   s      r   rm   ValidatedBase.Set   s     N
OOr   c                     g)a  Checks for missing or conflicting attributes.

Subclasses should override this function and raise an exception for
any errors. Always run this method when all assignments are complete.

Raises:
  ValidationError: when there are missing or conflicting attributes.
Nr.   r@   s    r   CheckInitializedValidatedBase.CheckInitialized   s    r   c                     [        S5      e)  Convert ValidatedBase object to a dictionary.

Recursively traverses all of its elements and converts everything to
simplified collections.

Subclasses should override this method.

Returns:
  A dictionary mapping all attributes to simple values or collections.
z1Subclasses of ValidatedBase must override ToDict.re   r@   s    r   r]   ValidatedBase.ToDict   s      1 2 2r   c                 R    [         R                  " U R                  5       S[        S9$ )zPrint validated object as simplified YAML.

Returns:
  Object as a simplified YAML string compatible with parsing using the
  SafeLoader.
F)default_flow_styleDumper)r   dumpr]   r%   r@   s    r   ToYAMLValidatedBase.ToYAML   s#     99T[[](-&( (r   c                     [        S5      e)zReturn all the warnings we've got, along with their associated fields.

Returns:
  A list of tuples of (dotted_field, warning), both strings.
z5Subclasses of ValidatedBase must override GetWarningsre   r@   s    r   GetWarningsValidatedBase.GetWarnings  s      5 6 6r   r.   N)r   r   r   r   r    classmethodri   ro   rm   ru   r]   r~   r   r!   r.   r   r   r\   r\      s6    -8 8"P 2	(6r   r\   c                      ^  \ rS rSrSrSrU 4S jr\S 5       rS r	S r
U 4S jrS	 rU 4S
 jrS rS rS rS rS rS rS rS rSrU =r$ )	Validatedi  aP  Base class for classes that require validation.

A class which intends to use validated fields should sub-class itself from
this class.  Each class should define an 'ATTRIBUTES' class variable which
should be a map from attribute name to its validator.  For example:

  class Story(Validated):
    ATTRIBUTES = {'title': Type(str),
                  'authors': Repeated(Type(str)),
                  'isbn': Optional(Type(str)),
                  'pages': Type(int),
                  }

Attributes that are not listed under ATTRIBUTES work like normal and are
not validated upon assignment.
Nc                 Z  > [         [        U ]  5         [        U R                  [
        5      (       d  [        SU R                  -  5      eU R                  R                  5        H2  n[        R                  XU R                  U5      R                  5        M4     U R                  U5        g)zConstructor for Validated classes.

This constructor can optionally assign values to the class via its
keyword arguments.

Raises:
  AttributeDefinitionError: when class instance is missing ATTRIBUTE
    definition or when ATTRIBUTE is of the wrong type.
z3The class %s does not define an ATTRIBUTE variable.N)r   r   r   rN   
ATTRIBUTESdictr4   r   r   object__setattr__ri   defaultro   )r   rn   r   r   s      r   r   Validated.__init__!  s     
)T#%doot,,$
?NN 
 ##%D$5$5c$:$B$BC & 	Z r   c                     XR                   ;  a  [        SU< SU R                  < S35      e[        U R                   U   5      $ )zSafely get the underlying attribute definition as a Validator.

Args:
  key: Name of attribute to get.

Returns:
  Validator associated with key or attribute value wrapped in a
  validator.
Raises:
  ValidationError: if no such attribute exists.
zUnexpected attribute 'z' for object of type .)r   r7   r   rZ   rg   s     r   ri   Validated.GetValidator7  s?     ..   s~~c*++r   c                     / nU R                   R                  5        HB  nUR                  U R                  U5      R	                  U R                  U5      X 5      5        MD     U$ r
   )r   r   extendri   r   GetUnnormalized)r   retr   s      r   r   Validated.GetWarningsK  sY    
C##%	jj""3'33


s
#S0 1 & Jr   c                     [        XU5        g)zSet a single value on Validated instance.

This method can only be used to assign validated attributes.

Args:
  key: The name of the attributes
  value: The value to set

Raises:
  ValidationError when no validated attribute exists on class.
N)setattrrr   s      r   rm   Validated.SetR  s     Dur   c                    > U R                  U5      n [        [        U ]  U5      $ ! [         a    UR
                  s $ f = f)zBGet a single value on the Validated instance, without normalizing.)ri   r   r   __getattribute__AttributeErrorr   )r   r   rY   r   s      r   r   Validated.GetUnnormalized`  sE    !!#&I9d4S99 s   ' A A c                 :    U R                  U5        [        X5      $ )zGet a single value on Validated instance.

This method can only be used to retrieve validated attributes.

Args:
  key: The name of the attributes

Raises:
  ValidationError when no validated attribute exists on class.
)ri   getattr)r   r   s     r   GetValidated.Geth  s     	c4r   c                    > [         [        U ]  U5      nUS;   a  U$  U R                  U5      n[        U[        5      (       a  UR                  X!U 5      $ U$ ! [         a    Us $ f = f)N)r   ri   r   r   )r   r   r   ri   r7   rN   
Normalizedr   )r   r   r   rY   r   s       r   r   Validated.__getattribute__v  st     	4
1#
6C
EEj##C(i )Z((]]3T**J	  js   A A'&A'c                     U R                   R                  5        H5  nU R                  U5      nU R                  U5      R	                  X!U 5        M7     g r
   )r   r   r   ri   CheckFieldInitializedrr   s      r   ru   Validated.CheckInitialized  sD    ##%""3'e
225tD &r   c                 d    Ub  U R                  U5      " X!5      n[        R                  XU5        g)aJ  Set attribute.

Setting a value on an object of this type will only work for attributes
defined in ATTRIBUTES.  To make other assignments possible it is necessary
to override this method in subclasses.

It is important that assignment is restricted in this way because
this validation is used as validation for parsing.  Absent this restriction
it would be possible for method names to be overwritten.

Args:
  key: Name of attribute to set.
  value: The attribute's new value or None to unset.

Raises:
  ValidationError: when trying to assign to an attribute
    that does not exist.
N)ri   r   r   rr   s      r   r   Validated.__setattr__  s/    & $U0e
t%(r   c                     [        U 5      $ )5Formatted view of validated object and nested values.)reprr@   s    r   rA   Validated.__str__  s    :r   c                 .   U R                   R                  5        Vs/ s H  o[        X5      4PM     nnSn/ nU H!  u  pUR                  SU< U< SU< 35        M#     SU R                  R
                  < SSR                  U5      < SU< S3$ s  snf )r   z    
=< >)r   r   r   r   r   r   join)r   attrvaluesdent
value_listr`   s         r   __repr__Validated.__repr__  s    6:oo6J6J6LM6LdWT()6LFMDJtT59:  !NN33SXXj5I4PP Ns   Bc                     [        U 5      [        U5      :w  a  gU R                  R                  5        H  n[        X5      [        X5      :w  d  M    g   g)a  Equality operator.

Comparison is done by comparing all attribute values to those in the other
instance.  Objects which are not of the same type are not equal.

Args:
  other: Other object to compare against.

Returns:
  True if validated objects are equal, else False.
FT)rQ   r   r   r   )r   otherr   s      r   __eq__Validated.__eq__  sH     DzT%[ ##%		wu2	2 & r   c                 .    U R                  U5      (       + $ )zInequality operator.r   r   r   s     r   __ne__Validated.__ne__      {{5!!!r   c                     SnU R                   R                  5        HH  n[        X5      n[        U[        5      (       a  [        U5      nU[        U5      -  [        U5      -  nMJ     U$ )zHash function for using Validated objects in sets and maps.

Hash is done by hashing all keys and values and xor'ing them together.

Returns:
  Hash of validated object.
r   )r   r   r   rN   rS   rT   hash)r   r   r   r`   s       r   __hash__Validated.__hash__  s^     F##%d e	E4	 	 eS	!DK/f	 &
 Mr   c                     0 nU R                   R                  5        HI  u  p#U R                  U5      n[        U[        5      (       a  XCR
                  :X  a  M<  [        X45      X'   MK     U$ )ao  Convert Validated object to a dictionary.

Recursively traverses all of its elements and converts everything to
simplified collections.

Returns:
  A dict of all attributes defined in this classes ATTRIBUTES mapped
  to its value.  This structure is recursive in that Validated objects
  that are referenced by this object and in lists are also converted to
  dicts.
)r   rl   r   rN   rW   r   r^   )r   r   namerY   r`   s        r   r]   Validated.ToDict  s]     F??002""4(e	9--%;L;L2L'	9	 3
 Mr   r.   )r   r   r   r   r    r   r   r   ri   r   rm   r   r   r   ru   r   rA   r   r   r   r   r]   r!   r"   r#   s   @r   r   r     sp    $ *!, , ,&E
).Q&"  r   r   c                   l   ^  \ rS rSrSrSrSrU 4S jr\S 5       r	S r
SS jrS rS	 rS
 rS rSrU =r$ )ValidatedDicti  a  Base class for validated dictionaries.

You can control the keys and values that are allowed in the dictionary
by setting KEY_VALIDATOR and VALUE_VALIDATOR to subclasses of Validator (or
things that can be interpreted as validators, see AsValidator).

For example if you wanted only capitalized keys that map to integers
you could do:

  class CapitalizedIntegerDict(ValidatedDict):
    KEY_VALIDATOR = Regex('[A-Z].*')
    VALUE_VALIDATOR = int  # this gets interpreted to Type(int)

The following code would result in an error:

  my_dict = CapitalizedIntegerDict()
  my_dict['lowercase'] = 5  # Throws a validation exception

You can freely nest Validated and ValidatedDict inside each other so:

  class MasterObject(Validated):
    ATTRIBUTES = {'paramdict': CapitalizedIntegerDict}

Could be used to parse the following yaml:
  paramdict:
    ArbitraryKey: 323
    AnotherArbitraryKey: 9931
Nc                 L   > [         [        U ]  5         U R                  U5        g)zConstruct a validated dict by interpreting the key and value validators.

Args:
  **kwds: keyword arguments will be validated and put into the dict.
N)r   r   r   r   )r   kwdsr   s     r   r   ValidatedDict.__init__  s     
-')KKr   c                 ~    [        U R                  5      " USU R                  -  5      n[        U R                  5      $ )zCheck the key for validity and return a corresponding value validator.

Args:
  key: The key that will correspond to the validator we are returning.
z	key in %s)rZ   KEY_VALIDATORr   VALUE_VALIDATORrg   s     r   ri   ValidatedDict.GetValidator  s5     c''
(kCLL.H
ICs**++r   c                 Z    [         R                  XU R                  U5      " X!5      5        g)a7  Set an item.

Only attributes accepted by GetValidator and values that validate
with the validator returned from GetValidator are allowed to be set
in this dictionary.

Args:
  key: Name of item to set.
  value: Items new value.

Raises:
  ValidationError: when trying to assign to a value that does not exist.
N)r   __setitem__ri   rr   s      r   r   ValidatedDict.__setitem__  s$     	T 1 1# 6u BCr   c                 X    [         R                  XU R                  U5      " X!5      5      $ )zTrap setdefaultss to ensure all key/value pairs are valid.

See the documentation for setdefault on dict for usage details.

Raises:
  ValidationError: if the specified key is illegal or the
  value invalid.
)r   
setdefaultri   rr   s      r   r   ValidatedDict.setdefault.  s%     ??4d&7&7&<U&HIIr   c           	         [        US5      (       aB  [        [        US5      5      (       a(  0 nU H  nU R                  U5      " X   U5      X4'   M!     O,U VVs/ s H  u  pEX@R                  U5      " XT5      4PM     nnn0 nU H  nU R                  U5      " X$   U5      Xd'   M!     [        R
                  " X40 UD6  gs  snnf )zTrap updates to ensure all key/value pairs are valid.

See the documentation for update on dict for usage details.

Raises:
  ValidationError: if any of the specified keys are illegal or
    values invalid.
r   N)r)   callabler   ri   r   r   )r   r   r   newotherkvnewkwdss          r   r   ValidatedDict.update9  s     uf(75&+A"B"Bh!''*58Q7  AFFfq1''*101hFG$$Q'3gj  	KK*'* Gs   $B?c                     X U'   g)a  Set a single value on Validated instance.

This method checks that a given key and value are valid and if so
puts the item into this dictionary.

Args:
  key: The name of the attributes
  value: The value to set

Raises:
  ValidationError: when no validated attribute exists on class.
Nr.   rr   s      r   rm   ValidatedDict.SetO  s     Ir   c                     / nU R                  5        H5  u  p#UR                  U R                  U5      R                  X2U 5      5        M7     U$ r
   )rl   r   ri   r   )r   r   r   r`   s       r   r   ValidatedDict.GetWarnings^  sB    
Czz|	jj""4(44U$GH $Jr   c                 x    0 nU R                  5        H#  u  p#U R                  U5      n[        XC5      X'   M%     U$ )rx   )rl   ri   r^   )r   r   r   r`   rY   s        r   r]   ValidatedDict.ToDictd  s>     Fzz|##D)i%i7fl $ Mr   r.   r
   )r   r   r   r   r    r   r   r   r   ri   r   r   r   rm   r   r]   r!   r"   r#   s   @r   r   r     sR    8 -/ , ,D 	J+, r   r   c                   L    \ rS rSrSr\rSS jrSS jrSS jr	S r
S rS	 rS
rg)rW   iz  a  Validator base class.

Though any callable can be used as a validator, this class encapsulates the
case when a specific validator needs to hold a particular state or
configuration.

To implement Validator sub-class, override the validate method.

This class is permitted to change the ultimate value that is set to the
attribute if there is a reasonable way to perform the conversion.
Nc                     Xl         g)zzConstructor.

Args:
  default: Default assignment is made during initialization and will
    not pass through validation.
Nr   )r   r   s     r   r   Validator.__init__  s	     Lr   c                 $    U R                  X5      $ )z.Main interface to validator is call mechanism.)Validater   r`   r   s      r   __call__Validator.__call__  s    ==$$r   c                     U$ )zValidate this field. Override to customize subclass behavior.

Args:
  value: Value to validate.
  key: Name of the field being validated.

Returns:
  Value if value is valid, or a valid representation of value.
r.   r   s      r   r   Validator.Validate  s	     Lr   c                      Uc  [        U5      eg)a  Check for missing fields or conflicts between fields.

Default behavior performs a simple None-check, but this can be overridden.
If the intent is to allow optional fields, then use the Optional validator
instead.

Args:
  value: Value to validate.
  key: Name of the field being validated.
  obj: The object to validate against.

Raises:
  ValidationError: when there are missing or conflicting fields.
N)rD   r   r`   r   objs       r   r   Validator.CheckFieldInitialized  s     }S!! r   c                     U$ )a  Convert 'value' to a simplified collection or basic type.

Subclasses of Validator should override this method when the dumped
representation of 'value' is not simply <type>(value) (e.g. a regex).

Args:
  value: An object of the same type that was returned from Validate().

Returns:
  An instance of a builtin type (e.g. int, str, dict, etc).  By default
  it returns 'value' unmodified.
r.   r   r`   s     r   r_   Validator.ToValue  s	     Lr   c                     AAA/ $ )a  Return any warnings on this attribute.

Validates the value with an eye towards things that aren't fatal problems.

Args:
  value: Value to validate.
  key: Name of the field being validated.
  obj: The object to validate against.

Returns:
  A list of tuples (context, warning) where
    - context is the field (or dotted field path, if a sub-field)
    - warning is the string warning text
r.   r   s       r   r   Validator.GetWarnings  s     	sCIr   r   r
   z???)r   r   r   r   r    r   expected_typer   r   r   r   r_   r   r!   r.   r   r   rW   rW   z  s,    
 -%
"$r   rW   c                   "    \ rS rSrSrSS jrSrg)rM   i  zpVerifies property is a valid text string.

In python 2: inherits from basestring
In python 3: inherits from str
c                 l    [        U[        R                  5      (       d  [        SU< SU< S35      eU$ )NValue  for z is not a valid text string.)rN   r   rL   r7   r   s      r   r   StringValidator.Validate  s3    eZ4455S  Lr   r.   Nr   )r   r   r   r   r    r   r!   r.   r   r   rM   rM     s    r   rM   c                   <   ^  \ rS rSrSrSU 4S jjrS rS rSrU =r	$ )rR   i  a  Verifies property is of expected type.

Can optionally convert value if it is not of the expected type.

It is possible to specify a required field of a specific type in shorthand
by merely providing the type.  This method is slightly less efficient than
providing an explicit type but is not significant unless parsing a large
amount of information:

  class Person(Validated):
    ATTRIBUTES = {'name': unicode,
                  'age': int,
                  }

However, in most instances it is best to use the type constants:

  class Person(Validated):
    ATTRIBUTES = {'name': TypeUnicode,
                  'age': TypeInt,
                  }
c                 D   > [         [        U ]  U5        Xl        X l        g)ak  Initialize Type validator.

Args:
  expected_type: Type that attribute should validate against.
  convert: Cause conversion if value is not the right type.
    Conversion is done by calling the constructor of the type
    with the value as its first parameter.
  default: Default assignment is made during initialization and will
    not pass through validation.
N)r   rR   r   r   convert)r   r   r  r   r   s       r   r   Type.__init__  s     
$w'&Lr   c           
         [        XR                  5      (       dN  U R                  (       a   U R                  U5      $ [	        SU< SU< SU R                  R
                  < 35      eU$ ! [         a2  n[	        SU< SU< SU R                  R
                  < S3U5      eSnAf[         a1  n[	        SU< SU< SU R                  R
                  < 3U5      eSnAff = f)a  Validate that value has the correct type.

Args:
  value: Value to validate.
  key: Name of the field being validated.

Returns:
  value if value is of the correct type. value is coverted to the correct
  type if the Validator is configured to do so.

Raises:
  ValidationError: if value is not of the right type and the validator
    is either configured not to convert or cannot convert.
r   r   z  could not be converted to type r   Nz is not of the expected type )rN   r   r  
ValueErrorr7   r   	TypeError)r   r`   r   es       r   r   Type.Validate  s     e//00			?##E*
* d0099;< 	< l  	?d0099;<=? ?  	?d0099;<=? ?	?s#   A+ +
C 5-B""C /,CC c                     A[        U R                  [        5      (       a.  UR                  5        VVs/ s H  u  pEU< SU< 3U4PM     snn$ / $ s  snnf )Nr   )
issubclassr   r\   r   )r   r`   r   r   subkeywarnings         r   r   Type.GetWarnings.  sW    $$$m44%*%6%6%8:%8/& v&0%8: :I:s   A)r  r   )TN)
r   r   r   r   r    r   r   r   r!   r"   r#   s   @r   rR   rR     s    ,!F r   rR   c                   <   ^  \ rS rSrSrSU 4S jjrU 4S jrSrU =r$ )ExeciB  a*  Coerces the value to accommodate Docker CMD/ENTRYPOINT requirements.

Validates the value is a string, then tries to modify the string (if
necessary) so that the command represented will become PID 1 inside the
Docker container. See Docker documentation on "docker kill" for more info:
https://docs.docker.com/engine/reference/commandline/kill/

If the command already starts with `exec` or appears to be in "exec form"
(starts with `[`), no further action is needed. Otherwise, prepend the
command with `exec` so that it will become PID 1 on execution.
c                 4   > [         [        U ]  [        SUS9  g)z9Initialize parent, a converting type validator for `str`.T)r  r   N)r   r  r   r?   )r   r   r   s     r   r   Exec.__init__O  s    	$sD'Br   c                    > [         [        U ]  X5      nUR                  S5      (       d  UR                  S5      (       a  U$ SU-   $ )zFValidate according to parent behavior and coerce to start with `exec`.[execzexec )r   r  r   
startswith)r   r`   r   r   s      r   r   Exec.ValidateS  sH     $&u2E 0 0 8 8l u_r   r.   r
   	r   r   r   r   r    r   r   r!   r"   r#   s   @r   r  r  B  s    
C r   r  c                   2   ^  \ rS rSrSrU 4S jrS rSrU =r$ )rV   ia  a'  Limit field based on pre-determined values.

Options are used to make sure an enumerated set of values are the only
one permitted for assignment.  It is possible to define aliases which
map multiple string values to a single original.  An example of usage:

  class ZooAnimal(validated.Class):
    ATTRIBUTES = {
      'name': str,
      'kind': Options('platypus',                   # No aliases
                      ('rhinoceros', ['rhino']),    # One alias
                      ('canine', ('dog', 'puppy')), # Two aliases
                      )
c                   >^	 SU;   a  US   nOSn0 m	U	4S jnU H  n[        U[        5      (       a
  U" XU5        M"  [        U[        [        45      (       a_  [	        U5      S:w  a  [        S5      eUu  pgU" Xf5        [        U[        [        45      (       d  [        S5      eU H  nU" X5        M     M  [        S5      e   [        [        U ]#  U5        T	U l	        g)z>Initialize options.

Args:
  options: List of allowed values.
r   Nc                 x   > [        U [        5      (       d  [        S5      eU T;   a  [        SU -  5      eUTU '   g)zSet new alias on alias_map.

Raises:
  AttributeDefinitionError: when option already exists or if alias is
    not of type str.
z&All option values must be of type str.z1Option '%s' already defined for options property.N)rN   r?   r4   )aliasoriginal	alias_maps     r   AddAlias"Options.__init__.<locals>.AddAlias}  sK     s##&46 	6I&?%GI 	I!ir      zAlias is defined as a list or tuple with two items.  The first is the original option, while the second is a list or tuple of str aliases.

  Example:
      ('original', ('alias1', 'alias2'z#Alias lists must be a list or tuplez?All options must be of type str or of the form (str, [str...]).)
rN   r?   rS   rT   lenr4   r   rV   r   options)r   r#  kwr   r  optionr  aliasesr  r  r   s            @r   r   Options.__init__q  s     B9ggI"  	FC	 	  ftUm,,v;!( *4 5 5 #$'D%=11()NO
OE
5
#  ' (I J 	J/ 2 
'4!'*DLr   c           	          [        U5      nXR                  ;  a"  [        SU< SU< SU R                  < S35      eU R                  U   $ )zValidate options.

Returns:
  Original value for provided alias.

Raises:
  ValidationError: when value is not one of predefined values.
Value '' for z not in r   )r?   r#  r7   r   s      r   r   Options.Validate  sC     JELL $c4<<9 : :<<r   )r#  r  r#   s   @r   rV   rV   a  s    6p r   rV   c                   4    \ rS rSrSrS	S jrS rS rS rSr	g)
Optionali  a   Definition of optional attributes.

Optional values are attributes which can be set to None or left
unset.  All values in a basic Validated class are set to None
at initialization.  Failure to assign to non-optional values
will result in a validation error when calling CheckInitialized.
Nc                 f    [        U5      U l        U R                  R                  U l        X l        g)a  Initializer.

This constructor will make a few guesses about the value passed in
as the validator:

  - If the validator argument is a type, it automatically creates a Type
    validator around it.

  - If the validator argument is a list or tuple, it automatically
    creates an Options validator around it.

Args:
  validator: Optional validation condition.

Raises:
  AttributeDefinitionError: if validator is not callable.
N)rZ   rY   r   r   )r   rY   r   s      r   r   Optional.__init__  s'    $ !+DN55DLr   c                 $    U R                  X5      $ )a&  Optionally require a value.

Normal validators do not accept None.  This will accept none on
behalf of the contained validator.

Args:
  value: Value to be validated as optional.
  key: Name of the field being validated.

Returns:
  None if value is None, else results of contained validation.
rX   r   s      r   r   Optional.Validate  s     >>%%%r   c                 D    Uc  g U R                   R                  XU5        g r
   )rY   r   r   s       r   r   Optional.CheckFieldInitialized  s    }NN((S9r   c                 @    Uc  gU R                   R                  U5      $ )z9Convert 'value' to a simplified collection or basic type.N)rY   r_   r   s     r   r_   Optional.ToValue  s    }>>!!%((r   )r   r   rY   r
   )
r   r   r   r   r    r   r   r   r_   r!   r.   r   r   r-  r-    s    ,&:
)r   r-  c                   N   ^  \ rS rSrSr\R                  S4U 4S jjrS rSr	U =r
$ )rP   i  aa  Regular expression validator.

Regular expression validator always converts value to string.  Note that
matches must be exact.  Partial matches will not validate.  For example:

  class ClassDescr(Validated):
    ATTRIBUTES = { 'name': Regex(r'[a-zA-Z_][a-zA-Z_0-9]*'),
                   'parent': Type(type),
                   }

Alternatively, any attribute that is defined as a string is automatically
interpreted to be of type Regex.  It is possible to specify unicode regex
strings as well.  This approach is slightly less efficient, but usually
is not significant unless parsing large amounts of data:

  class ClassDescr(Validated):
    ATTRIBUTES = { 'name': r'[a-zA-Z_][a-zA-Z_0-9]*',
                   'parent': Type(type),
                   }

  # This will raise a ValidationError exception.
  my_class(name='AName with space', parent=AnotherClass)
Nc                   > [         [        U ]  U5        [        U[        R
                  5      (       a  [        R                  " U5      (       a  [        S[        U5      -  5      e[        U[        R
                  5      (       a  [        R                  " SU-  5      U l
        O[        S[        U5      -  5      eX l        g)zInitialized regex validator.

Args:
  regex: Regular expression string to use for comparison.
  string_type: Type to be considered a string.
  default: Default value.

Raises:
  AttributeDefinitionError: if string_type is not a kind of string.
z*Regex fields must be a string type not %s.z^(?:%s)$z-Regular expression must be string.  Found %s.N)r   rP   r   r  r   rL   rK   r4   r?   rN   recompiler   )r   regexstring_typer   r   s       r   r   Regex.__init__  s     
%({J$;$;<<  --$
6[9I
IK K%0011

:-.dg$
9CJ
FH H %r   c           	         [        U R                  [        5      (       a  [        U5      nO[	        U5      nU R
                  R                  U5      c,  [        SU< SU< SU R
                  R                  < S35      eU$ )a   Does validation of a string against a regular expression.

Args:
  value: String to match against regular expression.
  key: Name of the field being validated.

Raises:
  ValidationError: when value does not match regular expression or
    when value does not match provided string type.
r)  r*  z does not match expression '')	r  r   r?   TYPE_STRTYPE_UNICODEr8  matchr7   patternr   r`   r   
cast_values       r   r   Regex.Validate$  sg     $$$c**E?j&jww}}Z ((-sDGGOOE F Fr   )r   r8  )r   r   r   r   r    r   rO   r   r   r!   r"   r#   s   @r   rP   rP     s$    0 )3(<(<d %0 r   rP   c                   ^    \ rS rSrSrS rS rS rS r\	S 5       r
S rS	 rS
 rS rS rSrg)_RegexStrValuei:  a  Simulates the regex object to support recompilation when necessary.

Used by the RegexStr class to dynamically build and recompile regular
expression attributes of a validated object.  This object replaces the normal
object returned from re.compile which is immutable.

When the value of this object is a string, that string is simply used as the
regular expression when recompilation is needed.  If the state of this object
is a list of strings, the strings are joined in to a single 'or' expression.
c                 6    Xl         X l        SU l        X0l        g)a  Initialize recompilable regex value.

Args:
  attribute: Attribute validator associated with this regex value.
  value: Initial underlying python value for regex string.  Either a single
    regex string or a list of regex strings.
  key: Name of the field.
N)_RegexStrValue__attribute_RegexStrValue__value_RegexStrValue__regex_RegexStrValue__key)r   	attributer`   r   s       r   r   _RegexStrValue.__init__F  s     !LDLJr   c                     [        U R                  R                  [        5      (       a  [	        U5      nO[        U5      nUR                  SS5      nUR                  SS5      nU$ )z}Convert a value to appropriate string.

Returns:
  String version of value with all carriage returns and line feeds removed.
r    )r  rI  r   r?   r?  r@  replace)r   r`   rD  s      r   
__AsString_RegexStrValue.__AsStringT  sZ     $""00#66E?j&j##D"-J##D"-Jr   c                    [        U R                  [        5      (       a  U R                  nSnOU R                  /nSn/ nU H#  nUR                  U R	                  U5      5        M%     U(       a  SR                  S U 5       5      $ US   $ )zBuild regex string from state.

Returns:
  String version of regular expression.  Sequence objects are constructed
  as larger regular expression where each regex in the list is joined with
  all the others as single 'or' expression.
TF|c              3   ,   #    U  H
  nS U-  v   M     g7f)z%sNr.   ).0ra   s     r   	<genexpr>._RegexStrValue.__BuildRegex.<locals>.<genexpr>w  s     9jddTkjs   r   )rN   rJ  rS   r   _RegexStrValue__AsStringr   )r   r   sequence
regex_listra   s        r   __BuildRegex_RegexStrValue.__BuildRegexc  s}     $,,%%<<jhLL>jhJ-.  XX9j999]r   c           	          U R                  5       n [        R                  " U5      $ ! [        R                   a'  n[	        SU< SU R
                  < SU< 3U5      eSnAff = f)zmBuild regular expression object from state.

Returns:
  Compiled regular expression based on internal value.
r)  r*  z does not compile: N)_RegexStrValue__BuildRegexr8  r9  errorr7   rL  )r   r:  r  s      r   	__Compile_RegexStrValue.__Compile{  sZ     E7ZZ88 7"DJJ3457 77s   ( A#"AA#c                 "    U R                  5       $ )z=Compiled regular expression as described by underlying value._RegexStrValue__Compiler@   s    r   r:  _RegexStrValue.regex  s     >>r   c                 L    [         R                  " U R                  5       U5      $ )zMatch against internal regular expression.

Args:
  value: String to match against regular expression.

Returns:
  Regular expression object built from underlying value.
)r8  rA  ra  r   s     r   rA  _RegexStrValue.match  s     88D%%'//r   c                 $    U R                  5         g)z"Ensure that regex string compiles.Nrf  r@   s    r   r   _RegexStrValue.Validate  s    NNr   c                 "    U R                  5       $ )z;Regular expression string as described by underlying value.)ra  r@   s    r   rA   _RegexStrValue.__str__  s    r   c                     [        U[        5      (       a!  U R                  5       UR                  5       :H  $ [        U 5      U:H  $ )z:Comparison against other regular expression string values.)rN   rG  ra  r?   r   s     r   r   _RegexStrValue.__eq__  s;    %(( E$6$6$888t9r   c                 .    U R                  U5      (       + $ )z8Inequality operator for regular expression string value.r   r   s     r   r   _RegexStrValue.__ne__  r   r   )__attribute__key__regex__valueN)r   r   r   r   r    r   r[  ra  rg  propertyr:  rA  r   rA   r   r   r!   r.   r   r   rG  rG  :  sH    	07  	0"r   rG  c                   T   ^  \ rS rSrSr\R                  S4U 4S jjrS rS r	Sr
U =r$ )RegexStri  a  Validates that a string can compile as a regex without errors.

Use this validator when the value of a field should be a regex.  That
means that the value must be a string that can be compiled by re.compile().
The attribute will then be a compiled re object.
Nc                 6  > Ub+  [        XS5      n[        R                  " [        U5      5        [        [
        U ]  U5        [        U[        R                  5      (       a  [        R                  " U5      (       a  [        S[        U5      -  5      eXl        g)zInitialized regex validator.

Args:
  string_type: Type to be considered a string.
  default: Default value.

Raises:
  AttributeDefinitionError: if string_type is not a kind of string.
Nz-RegexStr fields must be a string type not %s.)rG  r8  r9  r?   r   ry  r   r  r   rL   rK   r4   r   )r   r;  r   r   s      r   r   RegexStr.__init__  s     td3gjjW	(D"7+ {J$;$;<<  --$
9C<L
LN N %r   c                 l    [        U[        5      (       a  U$ [        XU5      nUR                  5         U$ )a  Validates that the string compiles as a regular expression.

Because the regular expression might have been expressed as a multiline
string, this function also strips newlines out of value.

Args:
  value: String to compile as a regular expression.
  key: Name of the field being validated.

Raises:
  ValueError when value does not compile as a regular expression.  TypeError
  when value does not match provided string type.
)rN   rG  r   r   s      r   r   RegexStr.Validate  s1     %((l4,E	NNLr   c                     [        U5      $ )z*Returns the RE pattern for this validator.)r?   r   s     r   r_   RegexStr.ToValue  s    u:r   r   )r   r   r   r   r    r   rO   r   r   r_   r!   r"   r#   s   @r   ry  ry    s)     ",!5!5t %0( r   ry  c                   :   ^  \ rS rSrSr\S4U 4S jjrS rSrU =r	$ )Rangei  a  Validates that numbers fall within the correct range.

In theory this class can be emulated using Options, however error
messages generated from that class will not be very intelligible.
This class essentially does the same thing, but knows the intended
integer range.

Also, this range class supports floats and other types that implement
ordinality.

The range is inclusive, meaning 3 is considered in the range
in Range(1,3).
Nc           
        > [         [        U ]  U5        UnU[        R                  ;   a  [        R                  nUc  Uc  [        S5      eUbL  [        X5      (       d<  [        S[        U5      < S[        [        U5      5      < S[        U5      < S35      eUbL  [        X%5      (       d<  [        S[        U5      < S[        [        U5      5      < S[        U5      < S35      eXl	        X l
        X0l        [        U5      U l        g)a  Initializer for range.

At least one of minimum and maximum must be supplied.

Args:
  minimum: Minimum for attribute.
  maximum: Maximum for attribute.
  range_type: Type of field.  Defaults to int.

Raises:
  AttributeDefinitionError: if the specified parameters are incorrect.
Nz Must specify minimum or maximum.zMinimum value must be of type z, instead it is z (z).zMaximum value must be of type )r   r  r   r   integer_typesr4   rN   r?   rQ   minimummaximumr   rR   _type_validator)r   r  r  
range_typer   min_max_typer   s         r   r   Range.__init__  s     
%(LZ-----l7?$%GHH:g#D#D$z?CW.G>? ? :g#D#D$z?CW.G>? ? LL#
+Dr   c           
         U R                   R                  X5      nU R                  c0  X0R                  :  a!  [	        SU< SU< SU R                  < 35      eU R                  c0  X0R                  :  a!  [	        SU< SU< SU R                  < 35      eU R                  b  X0R                  :  d  U R                  b>  X0R                  :  a/  [	        SU< SU< SU R                  < SU R                  < 35      eU$ )a  Validate that value is within range.

Validates against range-type then checks the range.

Args:
  value: Value to validate.
  key: Name of the field being validated.

Raises:
  ValidationError: when value is out of range.  ValidationError when value
  is not of the same range type.
r)  r*  z less than z greater than z is out of range z - )r  r   r  r  r7   rC  s       r   r   Range.Validate  s     %%..u:J||
\\ 9$c4<<9 : :		*||";$c4<<9 : : <<#
\\(A<<#
\\(A$c4<<G H Hr   )r  r   r  r  )
r   r   r   r   r    intr   r   r!   r"   r#   s   @r   r  r    s     36t ,B r   r  c                   <   ^  \ rS rSrSrSU 4S jjrS rS rSrU =r	$ )Repeatedi0  a  Repeated field validator.

Indicates that attribute is expected to be a repeated value, ie,
a sequence.  This adds additional validation over just Type(list)
in that it retains information about what can be stored in the list by
use of its constructor field.
c                 N   > [         [        U ]  U5        Xl        [        U l        g)znInitializer for repeated field.

Args:
  constructor: Type used for verifying elements of sequence attribute.
N)r   r  r   constructorrS   r   )r   r  r   r   s      r   r   Repeated.__init__9  s"     
(D"7+"Dr   c           
         [        U[        5      (       d  [        SU< SU< S35      e[        U5       H  u  p4[        U R                  [
        5      (       a  U R                  R                  XB5      X'   MC  [        X@R                  5      (       a  M_  [        S[        U5      < SU< SU R                  R                  < S35      e   U$ )a  Do validation of sequence.

Value must be a list and all elements must be of type 'constructor'.

Args:
  value: Value to validate.
  key: Name of the field being validated.

Raises:
  ValidationError: if value is None, not a list or one of its elements is
    the wrong type.
r)  r*  z! should be a sequence but is not.Value element ' must be type r   )	rN   rS   r7   	enumerater  rW   r   r?   r   )r   r`   r   idxra   s        r   r   Repeated.ValidateC  s     eT"").5 6 6 u%		D$$i	0	0%%..t9
$ 0 011IsD,,557 8 	8	 & Lr   c           
         Uc  [        U5      e[        U5       H  u  pE[        U R                  [        5      (       a;  U R                  R                  XRU 5        U R                  R                  XR5      X'   M_  [        XPR                  5      (       a  M{  [        S[        U5      < SU< SU R                  R                  < S35      e   g )Nr  r*  r  r   )
rD   r  rN   r  rW   r   r   r7   r?   r   )r   r`   r   r   r  ra   s         r   r   Repeated.CheckFieldInitialized]  s    }S!!u%		D$$i	0	0..t$? %%..t9
$ 0 011IsD,,557 8 	8 &r   )r  r   r
   )
r   r   r   r   r    r   r   r   r!   r"   r#   s   @r   r  r  0  s    48 8r   r  c                   6   ^  \ rS rSrSrSrU 4S jrS rSrU =r	$ )	TimeValueik  z5Validates time values with units, such as 1h or 3.5d.zImust be a non-negative number followed by a time unit, such as 1h or 3.5dc                 @   > [         [        U ]  5         [        U l        g r
   )r   r  r   r?   r   )r   r   s    r   r   TimeValue.__init__q  s    	)T#%Dr   c           
         [        U[        R                  5      (       d&  [        SU< SU< S[        R
                  < S35      eU(       d"  [        SU< S[        R
                  < S35      eUS   S;  a  [        SU< SU< S	35      e [        US
S 5      nUS:  a&  [        SU< SU< S[        R
                  < S35      eU$ ! [         a'    [        SU< SU< S[        R
                  < S35      ef = f)zValidate a time value.

Args:
  value: Value to validate.
  key: Name of the field being validated.

Raises:
  ValidationError: if value is not a time value with the expected format.
r)  r*  z is not a string ()z
Value for z is empty (smhdzS must end with a time unit, one of s (seconds), m (minutes), h (hours), or d (days)Nz is not a valid time value (r   z is negative ()rN   r   rL   r7   r  _EXPECTED_SYNTAXfloatr  )r   r`   r   ts       r   r   TimeValue.Validateu  s     eZ4455$c9+E+EG H H"I$>$>@ A ARy-2C9 : :H
cr

a 	1u$c9+E+EG H HL  H$c9+E+EG H HHs   C	 	1C:r  )
r   r   r   r   r    r  r   r   r!   r"   r#   s   @r   r  r  k  s    =+ r   r  c                   $    \ rS rSrSrS rS rSrg)r   i  zlNormalizes a field on lookup, but serializes with the original value.

Only works with fields on Validated.
c                 $    U R                  X5      $ r
   rX   r   s      r   r   Normalized.Validate  s    >>%%%r   c                     [        S5      e)z7Returns the normalized value. Subclasses must override.zSubclasses must override `Get`!re   r   s       r   r   Normalized.Get  s    
?
@@r   r.   N)r   r   r   r   r    r   r   r!   r.   r   r   r   r     s    
&Ar   r   c                   <   ^  \ rS rSrSrSU 4S jjrS rS rSrU =r	$ )	Preferredi  zA non-deprecated field when there's a deprecated one.

For use with Deprecated. Only works as a field on Validated.

Both fields will work for value access. It's an error to set both the
deprecated and the corresponding preferred field.
c                 `   > [         [        U ]  SS9  [        U5      U l        Xl        X0l        g)zInitializer for Preferred.

Args:
  deprecated: The name of the corresponding deprecated field
  validator: The validator for the actual value of this field.
  default: The default value for this field.
Nr   )r   r  r   rZ   rY   
deprecatedsynthetic_default)r   r  rY   r   r   s       r   r   Preferred.__init__  s0     
)T#D#1 +DN O %r   c                     UR                  U R                  5      nUb'  Ub$  [        SR                  X R                  5      5      eUb  g U R                  (       d  U R
                  R                  XU5        g g )NzMOnly one of the two fields [{}] (preferred) and [{}] (deprecated) may be set.)r   r  r7   rG   r  rY   r   r   r`   r   r   deprecated_values        r   r   Preferred.CheckFieldInitialized  su    **4??;-9 AAG #__B67 7 #!!
nn**5s; "r   c                 d    Ub  U$ UR                  U R                  5      nUb  U$ U R                  $ r
   )r   r  r  r  s        r   r   Preferred.Get  s:    l**4??;#!!!r   )r  r  rY   r
   )
r   r   r   r   r    r   r   r   r!   r"   r#   s   @r   r  r    s    %	<" "r   r  c                   B   ^  \ rS rSrSrSU 4S jjrS rS rS rSr	U =r
$ )	
Deprecatedi  zA deprecated field.

For use with Preferred. Only works as a field on Validated.

Both fields will work for value access. It's an error to set both the
deprecated and the corresponding preferred field.
c                 `   > [         [        U ]  SS9  [        U5      U l        Xl        X0l        g)zInitializer for Deprecated.

Args:
  preferred: The name of the preferred field.
  validator: The validator for the actual value of this field.
  default: The default value for this field.
Nr   )r   r  r   r-  rY   	preferredr  )r   r  rY   r   r   s       r   r   Deprecated.__init__  s.     
*d$T$2i(DNN$r   c                 >    AUb  USU< SU R                   < S34/$ / $ )NzField z is deprecated; use z	 instead.)r  r   s       r   r   Deprecated.GetWarnings  s3    
7:DNN
KM N N Ir   c                 d    UR                  U R                  5      nUb  U$ Ub  U$ U R                  $ r
   )r   r  r  )r   r`   r   r   preferred_values        r   r   Deprecated.Get  s9    ))$..9O"		l###r   c                     g r
   r.   r   s       r   r    Deprecated.CheckFieldInitialized  s    r   )r  r  rY   r
   )r   r   r   r   r    r   r   r   r   r!   r"   r#   s   @r   r  r    s!    %$	 	r   r  )3r    
__future__r   r8  "googlecloudsdk.appengine._internalr   ruamelr   r   r   
SafeDumperr%   add_representerrepresent_dict	Exceptionr0   r4   r7   rD   rZ   r^   r   r\   r   r   rW   rM   rR   bool	TYPE_BOOLr  TYPE_INT	TYPE_LONGr?   r?  rO   r@  r  
TYPE_FLOATr  rV   r-  rP   rG  ry  r  r  r  r   r  r  r.   r   r   <module>r     s  0 ' 	 9   - -   
))++I +Au Ae $0 0"3J2]6F ]6@\ \~HM4 H^Y Yxi N9 Nb J	9
 I	9J(()%[
4 >Ui Up7)y 7)tDI DNn"V n"b6y 6rII IX88y 88v&	 &RA A)"
 )"X(	 (	r   