
    	^cb                        d dl mZmZmZ d dlZd dlZd dlmZ ddlm	Z	 ddl
mZmZmZmZmZ ddlmZmZmZ ej        ZdZd	Zd
Z ei           Z G d de          Z e            Z	 eddddddi fdZd Zd Zd Z d Z!	 	 	 d/dZ"erd Z#nd Z#d Z$d0dZ%d0dZ&d1dZ'd Z(d Z)d Z*d Z+d Z, G d  d!e          Z-d" e-j.        D             Z/ e% e& e'e-e/#          e/#          d$ e/D             #          Z- G d% d&e          Z0 e& e'e0                    Z0 e"dd'           G d( d)e                      Z1effd*Z2 e"dd+           G d, d-e                      Z3d. Z4dS )2    )absolute_importdivisionprint_functionN)
itemgetter   )_config)PY2	iteritemsisclassiterkeysmetadata_proxy)DefaultAlreadySetErrorFrozenInstanceErrorNotAnAttrsClassErrorz__attr_convert_{}z__attr_factory_{}z/    {attr_name} = property(itemgetter({index}))c                   6    e Zd ZdZd Zd Zd Zd Zd Zd Z	dS )	_Nothingz
    Sentinel class to indicate the lack of a value when ``None`` is ambiguous.

    All instances of `_Nothing` are equal.
    c                     | S N selfs    A/usr/lib/python3/dist-packages/mercurial/thirdparty/attr/_make.py__copy__z_Nothing.__copy__           c                     | S r   r   )r   _s     r   __deepcopy__z_Nothing.__deepcopy__"   r   r   c                 "    |j         t          k    S r   )	__class__r   r   others     r   __eq__z_Nothing.__eq__%   s    (**r   c                     | |k     S r   r   r!   s     r   __ne__z_Nothing.__ne__(   s    5=  r   c                     dS )NNOTHINGr   r   s    r   __repr__z_Nothing.__repr__+   s    yr   c                     dS )Nl   >[= r   r   s    r   __hash__z_Nothing.__hash__.   s    zr   N)
__name__
__module____qualname____doc__r   r   r#   r%   r(   r*   r   r   r   r   r      sx         
    + + +! ! !      r   r   Tc           
      b    ||dur|durt          d          t          | |||||||          S )a  
    Create a new attribute on a class.

    ..  warning::

        Does *not* do anything unless the class is also decorated with
        :func:`attr.s`!

    :param default: A value that is used if an ``attrs``-generated ``__init__``
        is used and no value is passed while instantiating or the attribute is
        excluded using ``init=False``.

        If the value is an instance of :class:`Factory`, its callable will be
        used to construct a new value (useful for mutable datatypes like lists
        or dicts).

        If a default is not set (or set manually to ``attr.NOTHING``), a value
        *must* be supplied when instantiating; otherwise a :exc:`TypeError`
        will be raised.

        The default can also be set using decorator notation as shown below.

    :type default: Any value.

    :param validator: :func:`callable` that is called by ``attrs``-generated
        ``__init__`` methods after the instance has been initialized.  They
        receive the initialized instance, the :class:`Attribute`, and the
        passed value.

        The return value is *not* inspected so the validator has to throw an
        exception itself.

        If a ``list`` is passed, its items are treated as validators and must
        all pass.

        Validators can be globally disabled and re-enabled using
        :func:`get_run_validators`.

        The validator can also be set using decorator notation as shown below.

    :type validator: ``callable`` or a ``list`` of ``callable``\ s.

    :param bool repr: Include this attribute in the generated ``__repr__``
        method.
    :param bool cmp: Include this attribute in the generated comparison methods
        (``__eq__`` et al).
    :param hash: Include this attribute in the generated ``__hash__``
        method.  If ``None`` (default), mirror *cmp*'s value.  This is the
        correct behavior according the Python spec.  Setting this value to
        anything else than ``None`` is *discouraged*.
    :type hash: ``bool`` or ``None``
    :param bool init: Include this attribute in the generated ``__init__``
        method.  It is possible to set this to ``False`` and set a default
        value.  In that case this attributed is unconditionally initialized
        with the specified default value or factory.
    :param callable convert: :func:`callable` that is called by
        ``attrs``-generated ``__init__`` methods to convert attribute's value
        to the desired format.  It is given the passed-in value, and the
        returned value will be used as the new value of the attribute.  The
        value is converted before being passed to the validator, if any.
    :param metadata: An arbitrary mapping, to be used by third-party
        components.  See :ref:`extending_metadata`.

    ..  versionchanged:: 17.1.0 *validator* can be a ``list`` now.
    ..  versionchanged:: 17.1.0
        *hash* is ``None`` and therefore mirrors *cmp* by default .
    NTF6Invalid value for hash.  Must be True, False, or None.default	validatorreprcmphashinitconvertmetadata)	TypeError_CountingAttrr1   s           r   attrr<   8   se    L D,,U1B1BD
 
 	
 	 	 	 	r   c                    d                     |           }d                     |          dg}|rEt          |          D ]4\  }}|                    t                               ||                     5n|                    d           dt          i}t          t          d                    |          dd	          |           ||         S )
z
    Create a tuple subclass to hold `Attribute`s for an `attrs` class.

    The subclass is a bare tuple with properties for names.

    class MyClassAttributes(tuple):
        __slots__ = ()
        x = property(itemgetter(0))
    z{}Attributeszclass {}(tuple):z    __slots__ = ())index	attr_namez    passr   
 exec)format	enumerateappend_tuple_property_patr   evalcompilejoin)cls_name
attr_namesattr_class_nameattr_class_templateir?   globss          r   _make_attr_tuple_classrP      s     %++H55O!!/22  /%j11 	 	LAy&&':'A'A# (B ( (    	 	"":...:&E.//V	<	<eDDD!!r   c                   
 g 
t          | j        dd                   D ]6}t          |dd          }|!
                    
fd|D                        7|$d | j                                        D             }nd t          |          D             }d t          |d	 
          D             }d 
|z   D             }t          | j	        |          } |
d t          |d 
          D             z             | _
        d}| j
        D ]y}	||	
vrt          | |	j        |	           |du r:|	j        t          u r,|	j        du r#t!          d                    |	                    |du r|	j        t          ur|	j        durd}zdS )z
    Transforms all `_CountingAttr`s on a class into `Attribute`s and saves the
    list in `__attrs_attrs__`.

    If *these* is passed, use that and don't look for them on the class.
    r   __attrs_attrs__Nc              3   $   K   | ]
}|v|V  d S r   r   ).0a	super_clss     r   	<genexpr>z#_transform_attrs.<locals>.<genexpr>   s-      HH1Qi5G5GQ5G5G5G5GHHr   c                 F    g | ]\  }}t          |t                    ||fS r   
isinstancer;   rU   namer<   s      r   
<listcomp>z$_transform_attrs.<locals>.<listcomp>   s?     7 7 7!tT }557D$< 7 7 7r   c                     g | ]	\  }}||f
S r   r   )rU   r]   cas      r   r^   z$_transform_attrs.<locals>.<listcomp>   s0     ( ( (tR ": ( ( (r   c                 L    g | ]!\  }}t                               ||           "S )r]   r`   	Attributefrom_counting_attrrU   r?   r`   s      r   r^   z$_transform_attrs.<locals>.<listcomp>   s?       Ir 	$$)$;;  r   c                     | d         j         S Nr   counteres    r   <lambda>z"_transform_attrs.<locals>.<lambda>       1 r   )keyc                     g | ]	}|j         
S r   r]   rU   rV   s     r   r^   z$_transform_attrs.<locals>.<listcomp>   s    >>>Q!&>>>r   c                 L    g | ]!\  }}t                               ||           "S rb   rc   rf   s      r   r^   z$_transform_attrs.<locals>.<listcomp>   s?     2 2 2Ir 	$$)$;;2 2 2r   c                     | d         j         S rh   ri   rk   s    r   rm   z"_transform_attrs.<locals>.<lambda>   rn   r   FTzqNo mandatory attributes allowed after an attribute with a default value or factory.  Attribute in question: {a!r})rV   )reversed__mro__getattrextend__dict__itemsr
   sortedrP   r+   rS   setattrr]   r2   r'   r7   
ValueErrorrC   )clsthesec	sub_attrsca_listnon_super_attrsrK   
AttrsClasshad_defaultrV   rW   s             @r   _transform_attrsr      s(    Ick!B$'(( I IA0$77	 HHHH	HHHHHH}7 7l((**7 7 7
( (&&( ( (  '55666  O
 ?>)o"=>>>J'jAAJ$*Y 2 2 '556662 2 2 &  C K   =Qi//C###$19#7#7AFdNNJ!  
 E!!	((e##K r   c                     t                      )z4
    Attached to frozen classes as __setattr__.
    r   r   r]   values      r   _frozen_setattrsr           

r   c                     t                      )z4
    Attached to frozen classes as __delattr__.
    r   )r   r]   s     r   _frozen_delattrsr      r   r   Fc
           	      L   	 	f	d}
| |
S  |
|           S )a  
    A class decorator that adds `dunder
    <https://wiki.python.org/moin/DunderAlias>`_\ -methods according to the
    specified attributes using :func:`attr.ib` or the *these* argument.

    :param these: A dictionary of name to :func:`attr.ib` mappings.  This is
        useful to avoid the definition of your attributes within the class body
        because you can't (e.g. if you want to add ``__repr__`` methods to
        Django models) or don't want to.

        If *these* is not ``None``, ``attrs`` will *not* search the class body
        for attributes.

    :type these: :class:`dict` of :class:`str` to :func:`attr.ib`

    :param str repr_ns: When using nested classes, there's no way in Python 2
        to automatically detect that.  Therefore it's possible to set the
        namespace explicitly for a more meaningful ``repr`` output.
    :param bool repr: Create a ``__repr__`` method with a human readable
        represantation of ``attrs`` attributes..
    :param bool str: Create a ``__str__`` method that is identical to
        ``__repr__``.  This is usually not necessary except for
        :class:`Exception`\ s.
    :param bool cmp: Create ``__eq__``, ``__ne__``, ``__lt__``, ``__le__``,
        ``__gt__``, and ``__ge__`` methods that compare the class as if it were
        a tuple of its ``attrs`` attributes.  But the attributes are *only*
        compared, if the type of both classes is *identical*!
    :param hash: If ``None`` (default), the ``__hash__`` method is generated
        according how *cmp* and *frozen* are set.

        1. If *both* are True, ``attrs`` will generate a ``__hash__`` for you.
        2. If *cmp* is True and *frozen* is False, ``__hash__`` will be set to
           None, marking it unhashable (which it is).
        3. If *cmp* is False, ``__hash__`` will be left untouched meaning the
           ``__hash__`` method of the superclass will be used (if superclass is
           ``object``, this means it will fall back to id-based hashing.).

        Although not recommended, you can decide for yourself and force
        ``attrs`` to create one (e.g. if the class is immutable even though you
        didn't freeze it programmatically) by passing ``True`` or not.  Both of
        these cases are rather special and should be used carefully.

        See the `Python documentation \
        <https://docs.python.org/3/reference/datamodel.html#object.__hash__>`_
        and the `GitHub issue that led to the default behavior \
        <https://github.com/python-attrs/attrs/issues/136>`_ for more details.
    :type hash: ``bool`` or ``None``
    :param bool init: Create a ``__init__`` method that initialiazes the
        ``attrs`` attributes.  Leading underscores are stripped for the
        argument name.  If a ``__attrs_post_init__`` method exists on the
        class, it will be called after the class is fully initialized.
    :param bool slots: Create a slots_-style class that's more
        memory-efficient.  See :ref:`slots` for further ramifications.
    :param bool frozen: Make instances immutable after initialization.  If
        someone attempts to modify a frozen instance,
        :exc:`attr.exceptions.FrozenInstanceError` is raised.

        Please note:

            1. This is achieved by installing a custom ``__setattr__`` method
               on your class so you can't implement an own one.

            2. True immutability is impossible in Python.

            3. This *does* have a minor a runtime performance :ref:`impact
               <how-frozen>` when initializing new instances.  In other words:
               ``__init__`` is slightly slower with ``frozen=True``.

            4. If a class is frozen, you cannot modify ``self`` in
               ``__attrs_post_init__`` or a self-written ``__init__``. You can
               circumvent that limitation by using
               ``object.__setattr__(self, "attribute_name", value)``.

        ..  _slots: https://docs.python.org/3.5/reference/datamodel.html#slots

    ..  versionadded:: 16.0.0 *slots*
    ..  versionadded:: 16.1.0 *frozen*
    ..  versionadded:: 16.3.0 *str*, and support for ``__attrs_post_init__``.
    ..  versionchanged::
            17.1.0 *hash* supports ``None`` as value which is also the default
            now.
    c                   	 t          | dd           t          d          
du rdu rt          d          rB$d | j                                        D             }nt          t                              }t          |            t          |           p}
du rt          |           } du r| j
        | _        du rt          |           } durdurt          d          du sdu rn%du s
du rdu rt          |           } nd | _        	du rt          | |          } |du r+t           | _        t$          | _        du rt)          |           } du rt+          | j                  }t-          |          |d	<   |D ]}|                    |d            |                    d
d            t          | dd           } t1          |           | j        | j        |          } ||| _        | S )Nr    z(attrs only works with new-style classes.FTz3__str__ can only be generated if a __repr__ exists.c                 B    g | ]\  }}t          |t                    |S r   rZ   r\   s      r   r^   z,attributes.<locals>.wrap.<locals>.<listcomp>N  s;     ? ? ?)tT(}==?4 ? ? ?r   )nsr0   	__slots__ry   r-   )rw   r:   r}   ry   rz   listr   r   _has_frozen_superclass	_add_reprr(   __str___add_cmp	_add_hashr*   	_add_initr   __setattr__r   __delattr___add_pickledicttuplepoptyper+   	__bases__r-   )r~   r   effectively_frozencls_dictca_namequalnamer5   frozenr6   r7   r4   repr_nsslotsstrr   s         r   wrapzattributes.<locals>.wrapB  sg   3T**2FGGG5==SD[[E    	0}? ?!l0022? ? ?
 x//e$$$ 4C88BF4<<CG,,,C$;;,CK$;;3--CtE 1 1d6FH   U]]t|uT\\dlsd{{v~~C..CCCL4<<C!344C%%.CO.CO}}!#&&D==CL))H$)'NNH[!" , ,Wd++++LLT***sND99H$s))CL#-BBC##+ 
r   r   )	maybe_clsr   r   r4   r5   r6   r7   r   r   r   r   s    ````````` r   
attributesr      si    j> > > > > > > > > > > > >D tIr   c                 ~    t          | j        dd          t          j        k    o| j        j        t          j        k    S )b
        Check whether *cls* has a frozen ancestor by looking at its
        __setattr__.
        r,   N)rw   r   r   r,   r+   r~   s    r   r   r     sC     t !,- B O$(8(AA		
r   c                 "    | j         t          k    S )r   )r   r   r   s    r   r   r     s    
 "222r   c                 :     t           fd|D                       S )z:
    Create a tuple of all values of *obj*'s *attrs*.
    c              3   B   K   | ]}t          |j                  V  d S r   rw   r]   rU   rV   objs     r   rX   z"_attrs_to_tuple.<locals>.<genexpr>  s/      55!af%%555555r   )r   r   attrss   ` r   _attrs_to_tupler     s(     5555u555555r   c                 F    d | j         D             fd}|| _        | S )z%
    Add a hash method to *cls*.
    Nc                 D    g | ]}|j         d u s|j         |j        d u |S )T)r6   r5   rr   s     r   r^   z_add_hash.<locals>.<listcomp>  s>     J J JFdNNqv~!%4-- :G--r   c                 >    t          t          |                     S 1
        Automatically created by attrs.
        )r6   r   )r   r   s    r   hash_z_add_hash.<locals>.hash_  s     OD%00111r   )rS   r*   )r~   r   r   s    ` r   r   r     sW     }J J-J J J2 2 2 2 2 CLJr   c                     d | j         D             fdfdfd}fd}fd}fd}fd	}| _        || _        || _        || _        || _        || _        | S )
z*
    Add comparison methods to *cls*.
    Nc                      g | ]}|j         	|S r   )r5   rr   s     r   r^   z_add_cmp.<locals>.<listcomp>  s    999q159999r   c                 $    t          |           S )z&
        Save us some typing.
        )r   r   s    r   attrs_to_tuplez _add_cmp.<locals>.attrs_to_tuple  s     sE***r   c                 ^    |j         | j         u r |            |          k    S t          S r   )r    NotImplementedr   r"   r   s     r   eqz_add_cmp.<locals>.eq  s9     ?dn,,!>$''>>%+@+@@@!!r   c                 B     | |          }|t           u rt           S | S r   )r   )r   r"   resultr   s      r   nez_add_cmp.<locals>.ne  s-     D%^##!!:r   c                 l    t          || j                  r |            |          k     S t          S r   r[   r    r   r   s     r   ltz_add_cmp.<locals>.lt  >     eT^,, 	"!>$''..*?*???!!r   c                 l    t          || j                  r |            |          k    S t          S r   r   r   s     r   lez_add_cmp.<locals>.le  >     eT^,, 	"!>$''>>%+@+@@@!!r   c                 l    t          || j                  r |            |          k    S t          S r   r   r   s     r   gtz_add_cmp.<locals>.gt  r   r   c                 l    t          || j                  r |            |          k    S t          S r   r   r   s     r   gez_add_cmp.<locals>.ge  r   r   )rS   r#   r%   __lt____le____gt____ge__)	r~   r   r   r   r   r   r   r   r   s	    `     @@r   r   r     s    }99C/999+ + + + +" " " " "    " " " " "" " " " "" " " " "" " " " " CJCJCJCJCJCJJr   c                 J    d | j         D             fd}|| _        | S )z%
    Add a repr method to *cls*.
    Nc                      g | ]}|j         	|S r   )r4   rr   s     r   r^   z_add_repr.<locals>.<listcomp>  s    :::q16::::r   c                      j         }8t          |dd          }||                    dd          d         }n|j        }ndz   |j        z   }d                    |d                     fd	D                                 S )
r   Nr-   z>.r   rR   .z{0}({1}), c              3   r   K   | ]1}|j         d z   t          t          |j                             z   V  2dS )=N)r]   r4   rw   )rU   rV   r   s     r   rX   z+_add_repr.<locals>.repr_.<locals>.<genexpr>  sV       & & fslT'$*?*?%@%@@ & & & & & &r   )r    rw   rsplitr+   rC   rI   )r   real_clsr   
class_namer   r   s   `   r   repr_z_add_repr.<locals>.repr_  s     >:x>>H#%__T155b9

%.

cH$55J  II & & & &$& & & & &
 
 	
r   )rS   r(   )r~   r   r   r   s    `` r   r   r     sM     }::C/:::
 
 
 
 
 
& CLJr   c           	         d | j         D             }t          j                    }t          |          }t	          |t
                    s|                    d          }|                    |           d                    |	                                          }t          ||t          | dd                    \  }}i }t          ||d          }	t          d |D                       }
|                    t          |
d           |d	u r
t          |d
<   t!          |	||           |d         }t#          |          d|                    d	          |ft&          j        |<   || _        | S )zR
    Add a __init__ method to *cls*.  If *frozen* is True, make it immutable.
    c                 <    g | ]}|j         s|j        t          u|S r   )r7   r2   r'   rr   s     r   r^   z_add_init.<locals>.<listcomp>)  s8     4 4 414)722 222r   zutf-8z<attrs generated init {0}>__attrs_post_init__FrB   c              3   (   K   | ]}|j         |fV  d S r   rq   rr   s     r   rX   z_add_init.<locals>.<genexpr>=  s(      00Qafa[000000r   )r'   	attr_dictT_cached_setattr__init__N)rS   hashlibsha1r4   r[   bytesencodeupdaterC   	hexdigest_attrs_to_scriptrw   rH   r   r'   _obj_setattrrG   len
splitlines	linecachecacher   )r~   r   r   r   runique_filenamescriptrO   locsbytecoder   r7   s               r   r   r   %  s   4 4+ 4 4 4E <>>DUAa HHWKKNNN299 O %*E22 MFE
 Dv77H00%00000I	LL     ~~ $0 5$
D
 	F$	(IOO$ CLJr   c                 .    d }d }|| _         || _        | S )zC
    Add pickle helpers, needed for frozen and slotted classes
    c                 ^     t           fdt           j                  D                       S )(
        Play nice with pickle.
        c              3   B   K   | ]}t          |j                  V  d S r   r   r   s     r   rX   z9_add_pickle.<locals>._slots_getstate__.<locals>.<genexpr>]  s/      IIaWS!&))IIIIIIr   )r   fieldsr    )r   s   `r   _slots_getstate__z&_add_pickle.<locals>._slots_getstate__Y  s2     IIII6#-3H3HIIIIIIr   c                     t                               | t                    }t          t	          | j                  |          D ]\  }} ||j        |           dS )r   N)r   __get__rd   zipr  r    r]   )r   state__bound_setattrrV   r   s        r   _slots_setstate__z&_add_pickle.<locals>._slots_setstate___  sa     '..sI>>F3=11599 	+ 	+HAuOAFE****	+ 	+r   )__getstate____setstate__)r~   r  r  s      r   r   r   U  s:    J J J+ + + )C(CJr   c                     t          |           st          d          t          | dd          }|#t          d                    |                     |S )a  
    Returns the tuple of ``attrs`` attributes for a class.

    The tuple also allows accessing the fields by their names (see below for
    examples).

    :param type cls: Class to introspect.

    :raise TypeError: If *cls* is not a class.
    :raise attr.exceptions.NotAnAttrsClassError: If *cls* is not an ``attrs``
        class.

    :rtype: tuple (with name accesors) of :class:`attr.Attribute`

    ..  versionchanged:: 16.2.0 Returned tuple allows accessing the fields
        by name.
    zPassed object must be a class.rS   Nz({cls!r} is not an attrs-decorated class.r   )r   r:   rw   r   rC   )r~   r   s     r   r  r  l  se    $ 3<< :8999C*D11E}"6==#=FF
 
 	
 Lr   c           	          t           j        du rdS t          | j                  D ]+}|j        }|  || |t          | |j                             ,dS )z
    Validate all attributes on *inst* that have a validator.

    Leaves all exceptions through.

    :param inst: Instance of a class with ``attrs`` attributes.
    FN)r   _run_validatorsr  r    r3   rw   r]   )instrV   vs      r   validater    sg     %''DN## . .K=AdAwtQV,,---. .r   c                    g }|du r|                     d           d }d }nd }d }g }g }i }| D ]}	|	j        r|                     |	           |	j        }
|	j                            d          }t	          |	j        t                    }|r|	j        j        rd}nd	}|	j        d
u rg|rt          
                    |	j                  }|	j        _|                      ||
|d
                    |          z                        t          
                    |	j                  }|	j        ||<   n5|                      ||
|d
                    |          z                        |	j        j        ||<   D|	j        ^|                      ||
d
                    |
                               t          
                    |	j                  }|	j        ||<   |                      ||
d
                    |
                               |	j        t          ur|s|                     d
                    ||
                     |	j        H|                      ||
|                     |	j        |t          
                    |	j                  <   g|                      ||
|                     |r|                     d
                    |                     |                     d
                    |                     t          
                    |	j                  }|	j        |                     d ||
|          z              |                     d           |                     d ||
|d
                    |          z             z              |	j        |t          
                    |	j                  <   no|                     d ||
|          z              |                     d           |                     d ||
|d
                    |          z             z              |	j        j        ||<   |                     |           |	j        H|                      ||
|                     |	j        |t          
                    |	j                  <   ~|                      ||
|                     |rt          |d<   |                     d           |D ]t}	d
                    |	j                  }d
                    |	j                  }
|                     d
                    ||
|	j                             |	j        ||<   |	||
<   u|r|                     d           d
                    d                    |          |rd                    |          nd           |fS )!z
    Return a script of an initializer for *attrs* and a dict of globals.

    The globals are expected by the generated script.

     If *frozen* is True, we cannot set the attributes directly so we use
    a cached ``object.__setattr__``.
    Tz8_setattr = _cached_setattr.__get__(self, self.__class__)c                     d| |dz  S )Nz(_setattr('%(attr_name)s', %(value_var)s)r?   	value_varr   r  s     r   
fmt_setterz$_attrs_to_script.<locals>.fmt_setter  s!    =&&A A  r   c                 H    t                               |           }d| ||dz  S )Nz2_setattr('%(attr_name)s', %(conv)s(%(value_var)s))r?   r  conv_init_convert_patrC   r?   r  	conv_names      r   fmt_setter_with_converterz3_attrs_to_script.<locals>.fmt_setter_with_converter  s7    )00;;IG&&!K K  r   c                     d| |dz  S )Nzself.%(attr_name)s = %(value)sr?   r   r   r  s     r   r  z$_attrs_to_script.<locals>.fmt_setter  s    3&7 7  r   c                 H    t                               |           }d| ||dz  S )Nz,self.%(attr_name)s = %(conv)s(%(value_var)s)r  r  r  s      r   r  z3_attrs_to_script.<locals>.fmt_setter_with_converter  s7    )00;;IA&&!E E  r   r   r   rA   FNz({0})z attr_dict['{attr_name}'].default)r?   z+{arg_name}=attr_dict['{attr_name}'].default)arg_namer?   z{arg_name}=NOTHING)r!  zif {arg_name} is not NOTHING:z    zelse:r   z#if _config._run_validators is True:z__attr_validator_{}z	__attr_{}z    {}(self, {}, self.{})zself.__attrs_post_init__()z(def __init__(self, {args}):
    {lines}
r   z
    pass)argslines)rE   r3   r]   lstripr[   r2   Factory
takes_selfr7   _init_factory_patrC   r8   r  factoryr'   r   rI   )r   r   	post_initr$  r  r  r#  attrs_to_validatenames_for_globalsrV   r?   r!  has_factory
maybe_selfinit_factory_namer  val_names                    r   r   r     s    E~~ G	
 	
 	
	 	 		 	 	 		 	 		 	 	 D  P> P>; 	($$Q'''F	6==%% G44 	19/ 	JJJ6U?? $5$<$<QV$D$D!9(LL!:!:!)GNN:,F,FF"H "H I I I !2 8 8 @ @I349%i00LL!)GNN:,F,FF" "    89y7H!"3449(LL!:!:!:)44" "   
 !2 8 8 @ @I349%i00LL!:)44" "    
 Yg%%k%KK=DD%' E     y$66y(KKLLLFGi!"3":":16"B"BCCZZ	8<<==== 	>KK,33X3FFGGGLL8 &(&335 5 5 1 8 8 @ @y$V&?&?	@H'J 'J J K K KW%%%V&?&?%z(B(BB' '     GHi!"3":":16"B"BCCVjjH&E&EEFFFW%%%Vjj%z(B(BB' '     4593D/00KK!!!y$66y(KKLLLFGi!"3":":16"B"BCCZZ	8<<==== 	-'.)$:;;;" 	- 	-A,33AF;;H#**1622ILL4;;)QV- - . . .*++h'+,i(( 31222 FYYt__&+7hmmE"""     r   c                   H    e Zd ZdZdZ	 d	dZd Zed             Zd Z	d Z
dS )
rd   z
    *Read-only* representation of an attribute.

    :attribute name: The name of the attribute.

    Plus *all* arguments of :func:`attr.ib`.
    )	r]   r2   r3   r4   r5   r6   r7   r8   r9   Nc
                 J   t                               | t                    }
 |
d|            |
d|            |
d|            |
d|            |
d|            |
d|            |
d|            |
d|            |
d	|	rt          |	          nt                     d S )
Nr]   r2   r3   r4   r5   r6   r7   r8   r9   )r   r  rd   r   _empty_metadata_singleton)r   r]   r2   r3   r4   r5   r6   r7   r8   r9   bound_setattrs              r   r   zAttribute.__init__B  s     %,,T9==fd###i)))k9---fd###eS!!!fd###fd###i)))jx $B>(#;#;#;(A	D 	D 	D 	D 	Dr   c                     t                      r   r   r   s      r   r   zAttribute.__setattr__R  s    !###r   c                 `    fdt           j        D             } | d|j        j        d|S )Nc                 :    i | ]}|d v|t          |          S )r]   r3   r2   )rw   )rU   kr`   s     r   
<dictcomp>z0Attribute.from_counting_attr.<locals>.<dictcomp>W  sE     
 
 
    wr1~~  r   r8  r   )rd   r   
_validator_default)r~   r]   r`   	inst_dicts     ` r   re   zAttribute.from_counting_attrU  sb    
 
 
 
 "
 
 
	 s  r{        	 r   c                 D     t           fd j        D                       S )r   c              3   l   K   | ].}|d k    rt          |          nt          j                  V  /dS )r9   N)rw   r   r9   )rU   r]   r   s     r   rX   z)Attribute.__getstate__.<locals>.<genexpr>g  s[       1 1 -1J,>,>WT4(((t}--1 1 1 1 1 1r   )r   r   r   s   `r   r	  zAttribute.__getstate__c  s?      1 1 1 1!%1 1 1 1 1 	1r   c                     t                               | t                    }t          | j        |          D ]:\  }}|dk    r |||            |||rt          |          nt                     ;dS )r   r9   N)r   r  rd   r  r   r   r3  )r   r  r4  r]   r   s        r   r
  zAttribute.__setstate__k  s     %,,T9==t~u55 	9 	9KD%z!!dE****dU %8N5$9$9$979 9 9 9		9 	9r   NN)r+   r,   r-   r.   r   r   r   classmethodre   r	  r
  r   r   r   rd   rd   5  s         I )-D D D D $ $ $ 
  
  [
 1 1 1
9 
9 
9 
9 
9r   rd   c                 L    g | ]!}t          |t          d dd|dk    d          "S )NTr9   r]   r2   r3   r4   r5   r6   r7   rd   r'   rU   r]   s     r   r^   r^   x  sN     ' ' '
 T7dt4:+=TK K K ' ' 'r   )r   c                      g | ]}|j         	|S r   )r6   rr   s     r   r^   r^   ~  s    
#
#
#AF
#1
#
#
#r   c            
       ~    e Zd ZdZdZ ed dD                        eddddddd	          fz   Zd
Zd Z	d Z
d ZdS )r;   a  
    Intermediate representation of attributes that uses a counter to preserve
    the order in which the attributes have been defined.

    *Internal* data structure of the attrs library.  Running into is most
    likely the result of a bug like a forgotten `@attr.s` decorator.
    )	rj   r<  r4   r5   r6   r7   r9   r;  r8   c           
   #   L   K   | ]}t          |t          d dddd          V   d S )NTrD  rE  rF  s     r   rX   z_CountingAttr.<genexpr>  sV          	tWDt	= 	= 	=     r   )rj   r<  r4   r5   r6   r7   r9   NTFrD  r   c	                    t           xj        dz  c_        t           j        | _        || _        |r+t	          |t
          t          f          rt          | | _        n|| _        || _	        || _
        || _        || _        || _        || _        d S rh   )r;   cls_counterrj   r<  r[   r   r   and_r;  r4   r5   r6   r7   r8   r9   )	r   r2   r3   r4   r5   r6   r7   r8   r9   s	            r   r   z_CountingAttr.__init__  s    !!Q&!!$0 	(Ie}== 	("I.DOO'DO			 r   c                 X    | j         || _         nt          | j         |          | _         |S )z
        Decorator that adds *meth* to the list of validators.

        Returns *meth* unchanged.

        .. versionadded:: 17.1.0
        )r;  rL  r   meths     r   r3   z_CountingAttr.validator  s-     ?""DOO"4?D99DOr   c                 j    | j         t          urt                      t          |d          | _         |S )z
        Decorator that allows to set the default for an attribute.

        Returns *meth* unchanged.

        :raises DefaultAlreadySetError: If default has been set before.

        .. versionadded:: 17.1.0
        T)r'  )r<  r'   r   r&  rN  s     r   r2   z_CountingAttr.default  s6     =''(***666r   )r+   r,   r-   r.   r   r   rd   rS   rK  r   r3   r2   r   r   r   r;   r;     s         6Ie   C	     		z44E	> 	> 	>	O K! ! !"      r   r;   )r   r7   c                   B    e Zd ZdZ e            Z e            ZddZdS )r&  a  
    Stores a factory callable.

    If passed as the default value to :func:`attr.ib`, the factory is used to
    generate a new value.

    :param callable factory: A callable that takes either none or exactly one
        mandatory positional argument depending on *takes_self*.
    :param bool takes_self: Pass the partially initialized instance that is
        being initialized as a positional argument.

    .. versionadded:: 17.1.0  *takes_self*
    Fc                 "    || _         || _        dS )z
        `Factory` is part of the default machinery so if we want a default
        value here, we have to implement it ourselves.
        N)r)  r'  )r   r)  r'  s      r   r   zFactory.__init__  s    
 $r   N)F)r+   r,   r-   r.   r<   r)  r'  r   r   r   r   r&  r&    sJ          dffGJ% % % % % %r   r&  c                    t          |t                    r|}nEt          |t          t          f          rt          d |D                       }nt	          d           t          di |t          | ||                    S )a  
    A quick way to create a new class called *name* with *attrs*.

    :param name: The name for the new class.
    :type name: str

    :param attrs: A list of names or a dictionary of mappings of names to
        attributes.
    :type attrs: :class:`list` or :class:`dict`

    :param tuple bases: Classes that the new class will subclass.

    :param attributes_arguments: Passed unmodified to :func:`attr.s`.

    :return: A new class with *attrs*.
    :rtype: type

    ..  versionadded:: 17.1.0 *bases*
    c              3   6   K   | ]}|t                      fV  d S r   )r<   rr   s     r   rX   zmake_class.<locals>.<genexpr>  s*      33DFF333333r   z(attrs argument must be a dict or a list.r   )r[   r   r   r   r:   r   r   )r]   r   basesattributes_argumentsr   s        r   
make_classrW    s    ( % D	ED%=	)	) D33U33333BCCC-:--,--d4.I.IJJJr   )r   r6   c                   ,    e Zd ZdZ e            Zd ZdS )_AndValidatorz2
    Compose many validators to a single one.
    c                 4    | j         D ]} ||||           d S r   )_validators)r   r  r<   r   r  s        r   __call__z_AndValidator.__call__  s5    ! 	! 	!AAdD%    	! 	!r   N)r+   r,   r-   r.   r<   r[  r\  r   r   r   rY  rY    s:          $&&K! ! ! ! !r   rY  c                      g }| D ]4}|                     t          |t                    r|j        n|g           5t          t	          |                    S )z
    A validator that composes multiple validators into one.

    When called on a value, it runs all wrapped validators.

    :param validators: Arbitrary number of validators.
    :type validators: callables

    .. versionadded:: 17.1.0
    )rx   r[   rY  r[  r   )
validatorsvalsr3   s      r   rL  rL    sh     D 
 
	%/	=%I%I I!!	
 	
 	
 	

 t%%%r   )
NNNTTNTFFFr   rA  )5
__future__r   r   r   r   r   operatorr   rA   r   _compatr	   r
   r   r   r   
exceptionsr   r   r   objectr   r   r  r(  rF   r3  r   r'   r<   rP   r   r   r   r   r   r   r   r   r   r   r   r  r  r   rd   r   _ar;   r&  rW  rY  rL  r   r   r   <module>rf     s-   @ @ @ @ @ @ @ @ @ @                  F F F F F F F F F F F F F F          !' ' G *N2..     v   2 (**
 D4dS S S Sl" " "82 2 2j           4848.3Z Z Z Zz  3

 

 

 

3 3 36 6 6   &K K K K\   <- - -`  .  8. . ."Y Y Yx@9 @9 @9 @9 @9 @9 @9 @9F' '%' ' ' IHYYy+++2666
#
#b
#
#
#  	C C C C CF C C CL =1122 $U###% % % % %f % % $#%4 $*) K K K KD $T"""! ! ! ! !F ! ! #"!& & & & &r   