HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib/python3/dist-packages/attr/__pycache__/_make.cpython-38.pyc
U

]�]��@s�ddlmZmZmZddlZddlZddlZddlZddlZddl	Z	ddl
mZddlm
Z
ddlmZmZmZmZmZmZddlmZmZmZmZmZejZdZd	Zd
Z dZ!dZ"ei�Z#e�Z$Gd
d�de�Z%e%�Z&e&ddddddddddddf
dd�Z'dd�Z(e(ddddg�Z)dd�Z*dd�Z+dd�Z,dd �Z-d!d"�Z.d#d$�Z/Gd%d&�d&e�Z0d'Z1d(d)�Z2dbd*d�Z3e3Z4e�r|d+d,�Z5nd-d,�Z5d.d/�Z6d0d1�Z7d2d3�Z8d4d5�Z9d6d7�Z:d8d9�Z;d:d;�Z<dcd<d=�Z=e�>�Z?d>d?�Z@ddd@dA�ZAdBdC�ZBdDdE�ZCdFdG�ZDdHdI�ZEdJdK�ZFdLdM�ZGdNdO�ZHGdPdQ�dQe�ZIdRdS�eIjJD�ZKe9e=eAeIeKdT�eKdT�dUdS�eKD�dT�ZIGdVdW�dWe�ZLe=eAeL��ZLe3ddddX�GdYdZ�dZe��ZMeffd[d\�ZNe3ddd]�Gd^d_�d_e��ZOd`da�ZPdS)e�)�absolute_import�division�print_functionN)�
itemgetter�)�_config)�PY2�isclass�	iteritems�metadata_proxy�ordered_dict�set_closure_cell)�DefaultAlreadySetError�FrozenInstanceError�NotAnAttrsClassError�PythonTooOldError�UnannotatedAttributeErrorz__attr_converter_{}z__attr_factory_{}z=    {attr_name} = _attrs_property(_attrs_itemgetter({index})))ztyping.ClassVarz
t.ClassVarZClassVarZ_attrs_cached_hashcs,eZdZdZdZ�fdd�Zdd�Z�ZS)�_Nothingz�
    Sentinel class to indicate the lack of a value when ``None`` is ambiguous.

    ``_Nothing`` is a singleton. There is only ever one of it.
    Ncs"tjdkrtt|��|�t_tjS�N)r�
_singleton�super�__new__��cls��	__class__��,/usr/lib/python3/dist-packages/attr/_make.pyr:s
z_Nothing.__new__cCsdS)N�NOTHINGr��selfrrr�__repr__?sz_Nothing.__repr__)�__name__�
__module__�__qualname__�__doc__rrr!�
__classcell__rrrrr1srTFc

Cs�t|||�\}}|dk	r0|dk	r0|dk	r0td��|	dk	r`|tk	rHtd��t|	�sXtd��t|	�}|dkrli}t|||d||||||
||d�S)a
    Create a new attribute on a class.

    ..  warning::

        Does *not* do anything unless the class is also decorated with
        `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 `Factory`, its callable will be
        used to construct a new value (useful for mutable data types 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 `TypeError`
        will be raised.

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

    :type default: Any value

    :param callable factory: Syntactic sugar for
        ``default=attr.Factory(callable)``.

    :param validator: `callable` that is called by ``attrs``-generated
        ``__init__`` methods after the instance has been initialized.  They
        receive the initialized instance, the `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
        `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 repr: Include this attribute in the generated ``__repr__``
        method. If ``True``, include the attribute; if ``False``, omit it. By
        default, the built-in ``repr()`` function is used. To override how the
        attribute value is formatted, pass a ``callable`` that takes a single
        value and returns a string. Note that the resulting string is used
        as-is, i.e. it will be used directly *instead* of calling ``repr()``
        (the default).
    :type repr: a ``bool`` or a ``callable`` to use a custom function.
    :param bool eq: If ``True`` (default), include this attribute in the
        generated ``__eq__`` and ``__ne__`` methods that check two instances
        for equality.
    :param bool order: If ``True`` (default), include this attributes in the
        generated ``__lt__``, ``__le__``, ``__gt__`` and ``__ge__`` methods.
    :param bool cmp: Setting to ``True`` is equivalent to setting ``eq=True,
        order=True``. Deprecated in favor of *eq* and *order*.
    :param hash: Include this attribute in the generated ``__hash__``
        method.  If ``None`` (default), mirror *eq*'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 converter: `callable` that is called by
        ``attrs``-generated ``__init__`` methods to converter 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 `extending_metadata`.
    :param type: The type of the attribute.  In Python 3.6 or greater, the
        preferred method to specify the type is using a variable annotation
        (see `PEP 526 <https://www.python.org/dev/peps/pep-0526/>`_).
        This argument is provided for backward compatibility.
        Regardless of the approach used, the type will be stored on
        ``Attribute.type``.

        Please note that ``attrs`` doesn't do anything with this metadata by
        itself. You can use it as part of your own code or for
        `static type checking <types>`.
    :param kw_only: Make this attribute keyword-only (Python 3+)
        in the generated ``__init__`` (if ``init`` is ``False``, this
        parameter is ignored).

    .. versionadded:: 15.2.0 *convert*
    .. versionadded:: 16.3.0 *metadata*
    .. versionchanged:: 17.1.0 *validator* can be a ``list`` now.
    .. versionchanged:: 17.1.0
       *hash* is ``None`` and therefore mirrors *eq* by default.
    .. versionadded:: 17.3.0 *type*
    .. deprecated:: 17.4.0 *convert*
    .. versionadded:: 17.4.0 *converter* as a replacement for the deprecated
       *convert* to achieve consistency with other noun-based arguments.
    .. versionadded:: 18.1.0
       ``factory=f`` is syntactic sugar for ``default=attr.Factory(f)``.
    .. versionadded:: 18.2.0 *kw_only*
    .. versionchanged:: 19.2.0 *convert* keyword argument removed
    .. versionchanged:: 19.2.0 *repr* also accepts a custom callable.
    .. deprecated:: 19.2.0 *cmp* Removal on or after 2021-06-01.
    .. versionadded:: 19.2.0 *eq* and *order*
    NTF�6Invalid value for hash.  Must be True, False, or None.z=The `default` and `factory` arguments are mutually exclusive.z*The `factory` argument must be a callable.)�default�	validator�repr�cmp�hash�init�	converter�metadata�type�kw_only�eq�order)�_determine_eq_order�	TypeErrorr�
ValueError�callable�Factory�
_CountingAttr)
r(r)r*r+r,r-r/r0r.�factoryr1r2r3rrr�attribIs:z���r;cCsxd�|�}d�|�dg}|rDt|�D]\}}|�tj||d��q$n
|�d�ttd�}ttd�|�dd	�|�||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{}Attributeszclass {}(tuple):z    __slots__ = ())�index�	attr_namez    pass)Z_attrs_itemgetterZ_attrs_property�
��exec)	�format�	enumerate�append�_tuple_property_patr�property�eval�compile�join)Zcls_name�
attr_namesZattr_class_nameZattr_class_template�ir=�globsrrr�_make_attr_tuple_class�s

��

rL�_Attributes�attrs�
base_attrsZbase_attrs_mapcCst|��t�S)z�
    Check whether *annot* is a typing.ClassVar.

    The string comparison hack is used to avoid evaluating all string
    annotations which would put attrs-based classes at a performance
    disadvantage compared to plain old classes.
    )�str�
startswith�_classvar_prefixes)Zannotrrr�
_is_class_varsrScCsHt|dd�}|dkriS|jdd�D]}|t|dd�kr&iSq&|S)z$
    Get annotations for *cls*.
    �__annotations__Nr)�getattr�__mro__)r�anns�base_clsrrr�_get_annotationss
rYcCs
|djS)zQ
    Key function for sorting to avoid re-creating a lambda for every class.
    r��counter��errr�_counter_getter-sr^c	sl|j�t|��|dk	r@dd�t|�D�}t|t�s>|jtd�n�|dk�rdd����D�}g}t�}���D]Z\}}t	|�r�qn|�
|���|t�}	t|	t
�s�|	tkr�t�}	n
t|	d�}	|�||	f�qn||}
t|
�d	k�r&td
d�t|
�fdd
�d��d��ntdd����D�dd
�d�}�fdd�|D�}g}i}
dd�|D�}|jdd�D]\}t|dd�}|dk	�r\|D]:}	|�|	j�}|dk�rz|�|	�|	||	j<||
|	j<�qz�q\dd�||D�}t|j|�}|�r�dd�|D�}dd�|D�}|||�}d}dd�|D�D]D}	|dk�r@|	jtk�r@td|	f��|dk�r|	jtk	�rd}�qt|||
f�S)z�
    Transform all `_CountingAttr`s on a class into `Attribute`s.

    If *these* is passed, use that and don't look for them on the class.

    Return an `_Attributes`.
    NcSsg|]\}}||f�qSrr)�.0�name�carrr�
<listcomp>@sz$_transform_attrs.<locals>.<listcomp>)�keyTcSsh|]\}}t|t�r|�qSr��
isinstancer9�r_r`�attrrrr�	<setcomp>Es
�z#_transform_attrs.<locals>.<setcomp>)r(rz1The following `attr.ib`s lack a type annotation: �, cs��|�jSr)�getr[)�n)�cdrr�<lambda>]�z"_transform_attrs.<locals>.<lambda>�.css$|]\}}t|t�r||fVqdSrrdrfrrr�	<genexpr>cs
�z#_transform_attrs.<locals>.<genexpr>cSs
|djS�NrrZr\rrrrmhrncs&g|]\}}tj||��|�d��qS))r`rar0)�	Attribute�from_counting_attrrj)r_r=ra)rWrrrbks��cSsi|]}|j|�qSr�r`�r_�arrr�
<dictcomp>tsz$_transform_attrs.<locals>.<dictcomp>r����__attrs_attrs__cSsg|]
}|j�qSrrtrurrrrb�scSsg|]}|jdd��qS�T)r1��_assocrurrrrb�scSsg|]}|jdd��qSrzr{rurrrrb�sFcss&|]}|jdk	r|jdkr|VqdS)FN)r-r1rurrrrp�s

znNo mandatory attributes allowed after an attribute with a default value or factory.  Attribute in question: %r)�__dict__rYr
rer�sortr^�items�setrS�addrjrr9r;rC�lenrrH�sortedrVrUr`rLr"r(r6rM)r�these�auto_attribsr1Zca_listZca_namesZannot_namesr=r0rvZunannotatedZ	own_attrsrO�
base_attr_mapZtaken_attr_namesrXZ	sub_attrsZprev_arIZ
AttrsClassrNZhad_defaultr)rWrlr�_transform_attrs4s�

�


������	
�



��r�cCs
t��dS)z4
    Attached to frozen classes as __setattr__.
    N�r�r r`�valuerrr�_frozen_setattrs�sr�cCs
t��dS)z4
    Attached to frozen classes as __delattr__.
    Nr�)r r`rrr�_frozen_delattrs�sr�c@s|eZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�ZdS)�
_ClassBuilderz(
    Iteratively build *one* class.
    )
�_cls�	_cls_dict�_attrs�_base_names�_attr_names�_slots�_frozen�
_weakref_slot�_cache_hash�_has_post_init�_delete_attribs�_base_attr_map�_is_excc

Cs�t||||�\}
}}||_|r(t|j�ni|_|
|_tdd�|D��|_||_t	dd�|
D��|_
||_|prt|�|_
||_||_tt|dd��|_t|�|_|	|_|j|jd<|r�t|jd<t|jd<dS)	Ncss|]}|jVqdSrrtrurrrrp�sz)_ClassBuilder.__init__.<locals>.<genexpr>css|]}|jVqdSrrtrurrrrp�s�__attrs_post_init__Fry�__setattr__�__delattr__)r�r��dictr}r�r�r�r�r��tupler�r��_has_frozen_base_classr�r�r��boolrUr�r�r�r�r�)
r rr��slots�frozen�weakref_slotr�r1�
cache_hash�is_excrNrOZbase_maprrr�__init__�s.�

z_ClassBuilder.__init__cCsdj|jjd�S)Nz<_ClassBuilder(cls={cls})>r)rAr�r"rrrrr!�sz_ClassBuilder.__repr__cCs|jdkr|��S|��SdS)z�
        Finalize class based on the accumulated configuration.

        Builder cannot be used after calling this method.
        TN)r��_create_slots_class�_patch_original_classrrrr�build_class�s
z_ClassBuilder.build_classc	Cs�|j}|j}|jrZ|jD]@}||krt||t�tk	rzt||�Wqtk
rVYqXq|j�	�D]\}}t
|||�qd|jr�t|dd�}|r�td��dd�}t
|d|�|S)zA
        Apply accumulated methods and return the class.
        �__setstate__Nz�Currently you cannot use hash caching if you specify your own __setstate__ method.See https://github.com/python-attrs/attrs/issues/494 .cSst|td�dSr)�setattr�_hash_cache_field)Z	chss_self�_rrr�cache_hash_set_stateszA_ClassBuilder._patch_original_class.<locals>.cache_hash_set_state)
r�r�r�r�rU�	_sentinel�delattr�AttributeErrorr�rr�r��NotImplementedError)r r�
base_namesr`r�Zexisting_set_state_methodr�rrrr��s.
���z#_ClassBuilder._patch_original_classc
s��j��fdd�t�j�D�}d}�jjdd�D]}dt|dd�kr2d	}qPq2�j}�jr�dt�jd
d�kr�d|kr�|s�|d7}�fdd
�|D�}�jr�|�	t
�t|�|d
<t�jdd�}|dk	r�||d<tdd��jD����fdd�}�j���fdd�}||d<||d<t�j��jj
�jj|�}	|	j��D]`}
t|
ttf��rZt|
jdd�}nt|
dd�}|�sp�q6|D]}|j�jk�rtt||	��qt�q6|	S)zL
        Build and return a new class with a `__slots__` attribute.
        cs(i|] \}}|t�j�dkr||�qS))r}�__weakref__)r�r�)r_�k�vrrrrw)s�z5_ClassBuilder._create_slots_class.<locals>.<dictcomp>Frrxr�r}rT�	__slots__)r�csg|]}|�kr|�qSrr�r_r`)r�rrrbBsz5_ClassBuilder._create_slots_class.<locals>.<listcomp>r$Ncss|]}|dkr|VqdS)r�Nr)r_ZanrrrrpLsz4_ClassBuilder._create_slots_class.<locals>.<genexpr>cst�fdd��D��S)�9
            Automatically created by attrs.
            c3s|]}t�|�VqdSr�rUr�rrrrpTszL_ClassBuilder._create_slots_class.<locals>.slots_getstate.<locals>.<genexpr>�r�r)�state_attr_namesrr�slots_getstatePsz9_ClassBuilder._create_slots_class.<locals>.slots_getstatecs<t�|t�}t�|�D]\}}|||�q�r8|td�dS)r�N)�_obj_setattr�__get__rr�zipr�)r �stateZ_ClassBuilder__bound_setattrr`r�)�hash_caching_enabledr�rr�slots_setstateXs
z9_ClassBuilder._create_slots_class.<locals>.slots_setstate�__getstate__r��__closure__)r�r
r�r�rVrUr�r�r�rCr�r�r0r"�	__bases__r}�valuesre�classmethod�staticmethod�__func__�
cell_contentsr
)
r rlZweakref_inheritedrX�namesZ
slot_names�qualnamer�r�r�itemZ
closure_cellsZcellr)r�r�r r�rr�$sZ
�����
�z!_ClassBuilder._create_slots_classcCs|�t|j|d��|jd<|S)N)�nsr!)�_add_method_dunders�
_make_reprr�r�)r r�rrr�add_repr�s�
z_ClassBuilder.add_reprcCs8|j�d�}|dkrtd��dd�}|�|�|jd<|S)Nr!z3__str__ can only be generated if a __repr__ exists.cSs|��Sr)r!rrrr�__str__�sz&_ClassBuilder.add_str.<locals>.__str__r�)r�rjr6r�)r r*r�rrr�add_str�s�z_ClassBuilder.add_strcCsd|jd<|S)N�__hash__)r�rrrr�make_unhashable�s
z_ClassBuilder.make_unhashablecCs(|�t|j|j|j|jd��|jd<|S)N�r�r�r�)r��
_make_hashr�r�r�r�r�rrrr�add_hash�s��
	z_ClassBuilder.add_hashcCs6|�t|j|j|j|j|j|j|j|j	��|j
d<|S)Nr�)r��
_make_initr�r�r�r�r�r�r�r�r�rrrr�add_init�s��

z_ClassBuilder.add_initcs2�j}�fdd�t�j�j�D�\|d<|d<�S)Nc3s|]}��|�VqdSr�r��r_�methrrrrp�s�z'_ClassBuilder.add_eq.<locals>.<genexpr>�__eq__�__ne__)r��_make_eqr�r��r rlrrr�add_eq�s

�z_ClassBuilder.add_eqcs>�j}�fdd�t�j�j�D�\|d<|d<|d<|d<�S)Nc3s|]}��|�VqdSrr�r�rrrrp�s�z*_ClassBuilder.add_order.<locals>.<genexpr>�__lt__�__le__�__gt__�__ge__)r��_make_orderr�r�r�rrr�	add_order�s

�z_ClassBuilder.add_ordercCsXz|jj|_Wntk
r"YnXzd�|jj|jf�|_Wntk
rRYnX|S)zL
        Add __module__ and __qualname__ to a *method* if possible.
        ro)r�r#r�rHr$r")r �methodrrrr��s�
z!_ClassBuilder._add_method_dundersN)r"r#r$r%r�r�r!r�r�r�r�r�r�r�r�r�r�r�rrrrr��s$0`


r�zrThe usage of `cmp` is deprecated and will be removed on or after 2021-06-01.  Please use `eq` and `order` instead.cCs||dk	r$t|dk	|dk	f�r$td��|dk	rDtjttdd�||fS|dkrPd}|dkr\|}|dkrt|dkrttd��||fS)zp
    Validate the combination of *cmp*, *eq*, and *order*. Derive the effective
    values of eq and order.
    Nz&Don't mix `cmp` with `eq' and `order`.���
stacklevelTFz-`order` can only be True if `eq` is True too.)�anyr6�warnings�warn�_CMP_DEPRECATION�DeprecationWarning)r+r2r3rrrr4�sr4csPt|���\������������	�
���
�fdd�}|dkrD|S||�SdS)a� 
    A class decorator that adds `dunder
    <https://wiki.python.org/moin/DunderAlias>`_\ -methods according to the
    specified attributes using `attr.ib` or the *these* argument.

    :param these: A dictionary of name to `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 and will *not* remove any attributes from it.

        If *these* is an ordered dict (`dict` on Python 3.6+,
        `collections.OrderedDict` otherwise), the order is deduced from
        the order of the attributes inside *these*.  Otherwise the order
        of the definition of the attributes is used.

    :type these: `dict` of `str` to `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
        representation of ``attrs`` attributes..
    :param bool str: Create a ``__str__`` method that is identical to
        ``__repr__``.  This is usually not necessary except for
        `Exception`\ s.
    :param bool eq: If ``True`` or ``None`` (default), add ``__eq__`` and
        ``__ne__`` methods that check two instances for equality.

        They compare the instances as if they were tuples of their ``attrs``
        attributes, but only iff the types of both classes are *identical*!
    :type eq: `bool` or `None`
    :param bool order: If ``True``, add ``__lt__``, ``__le__``, ``__gt__``,
        and ``__ge__`` methods that behave like *eq* above and allow instances
        to be ordered. If ``None`` (default) mirror value of *eq*.
    :type order: `bool` or `None`
    :param cmp: Setting to ``True`` is equivalent to setting ``eq=True,
        order=True``. Deprecated in favor of *eq* and *order*, has precedence
        over them for backward-compatibility though. Must not be mixed with
        *eq* or *order*.
    :type cmp: `bool` or `None`
    :param hash: If ``None`` (default), the ``__hash__`` method is generated
        according how *eq* and *frozen* are set.

        1. If *both* are True, ``attrs`` will generate a ``__hash__`` for you.
        2. If *eq* is True and *frozen* is False, ``__hash__`` will be set to
           None, marking it unhashable (which it is).
        3. If *eq* is False, ``__hash__`` will be left untouched meaning the
           ``__hash__`` method of the base class will be used (if base class 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 our documentation on `hashing`, Python's documentation on
        `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 initializes 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 `slotted class <slotted classes>` that's more
        memory-efficient.
    :param bool frozen: Make instances immutable after initialization.  If
        someone attempts to modify a frozen instance,
        `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 your own.

            2. True immutability is impossible in Python.

            3. This *does* have a minor a runtime performance `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)``.

    :param bool weakref_slot: Make instances weak-referenceable.  This has no
        effect unless ``slots`` is also enabled.
    :param bool auto_attribs: If True, collect `PEP 526`_-annotated attributes
        (Python 3.6 and later only) from the class body.

        In this case, you **must** annotate every field.  If ``attrs``
        encounters a field that is set to an `attr.ib` but lacks a type
        annotation, an `attr.exceptions.UnannotatedAttributeError` is
        raised.  Use ``field_name: typing.Any = attr.ib(...)`` if you don't
        want to set a type.

        If you assign a value to those attributes (e.g. ``x: int = 42``), that
        value becomes the default value like if it were passed using
        ``attr.ib(default=42)``.  Passing an instance of `Factory` also
        works as expected.

        Attributes annotated as `typing.ClassVar`, and attributes that are
        neither annotated nor set to an `attr.ib` are **ignored**.

        .. _`PEP 526`: https://www.python.org/dev/peps/pep-0526/
    :param bool kw_only: Make all attributes keyword-only (Python 3+)
        in the generated ``__init__`` (if ``init`` is ``False``, this
        parameter is ignored).
    :param bool cache_hash: Ensure that the object's hash code is computed
        only once and stored on the object.  If this is set to ``True``,
        hashing must be either explicitly or implicitly enabled for this
        class.  If the hash code is cached, avoid any reassignments of
        fields involved in hash code computation or mutations of the objects
        those fields point to after object creation.  If such changes occur,
        the behavior of the object's hash code is undefined.
    :param bool auto_exc: If the class subclasses `BaseException`
        (which implicitly includes any subclass of any exception), the
        following happens to behave like a well-behaved Python exceptions
        class:

        - the values for *eq*, *order*, and *hash* are ignored and the
          instances compare and hash by the instance's ids (N.B. ``attrs`` will
          *not* remove existing implementations of ``__hash__`` or the equality
          methods. It just won't add own ones.),
        - all attributes that are either passed into ``__init__`` or have a
          default value are additionally available as a tuple in the ``args``
          attribute,
        - the value of *str* is ignored leaving ``__str__`` to base classes.

    .. versionadded:: 16.0.0 *slots*
    .. versionadded:: 16.1.0 *frozen*
    .. versionadded:: 16.3.0 *str*
    .. versionadded:: 16.3.0 Support for ``__attrs_post_init__``.
    .. versionchanged:: 17.1.0
       *hash* supports ``None`` as value which is also the default now.
    .. versionadded:: 17.3.0 *auto_attribs*
    .. versionchanged:: 18.1.0
       If *these* is passed, no attributes are deleted from the class body.
    .. versionchanged:: 18.1.0 If *these* is ordered, the order is retained.
    .. versionadded:: 18.2.0 *weakref_slot*
    .. deprecated:: 18.2.0
       ``__lt__``, ``__le__``, ``__gt__``, and ``__ge__`` now raise a
       `DeprecationWarning` if the classes compared are subclasses of
       each other. ``__eq`` and ``__ne__`` never tried to compared subclasses
       to each other.
    .. versionchanged:: 19.2.0
       ``__lt__``, ``__le__``, ``__gt__``, and ``__ge__`` now do not consider
       subclasses comparable anymore.
    .. versionadded:: 18.2.0 *kw_only*
    .. versionadded:: 18.2.0 *cache_hash*
    .. versionadded:: 19.1.0 *auto_exc*
    .. deprecated:: 19.2.0 *cmp* Removal on or after 2021-06-01.
    .. versionadded:: 19.2.0 *eq* and *order*
    c
sHt|dd�dkrtd���dko(t|t�}t|�
������|�	}�	dkrT|��
��dkrd|���dkrx|sx|���dkr�|s�|���dk	r��dk	r��dk	r�td��np�dksʈdkrƈdks�|r؈r�td��nF�dks��dk�r�dk�r�dk�r|�	�n��rtd��|�
��dk�r2|��n��r@td��|��S)Nrz(attrs only works with new-style classes.TFr'zlInvalid value for cache_hash.  To use hash caching, hashing must be either explicitly or implicitly enabled.zFInvalid value for cache_hash.  To use hash caching, init must be True.)
rUr5�
issubclass�
BaseExceptionr�r�r�r�r�r�r�r�r�)rr�Zbuilder�r��auto_excr�r2r�r,r-r1r3r*�repr_nsr�rPr�r�rr�wrap�sZ�
��&
�

�zattrs.<locals>.wrapN)r4)Z	maybe_clsr�r�r*r+r,r-r�r�r�rPr�r1r�r�r2r3r�rr�rrN�s2(DcCs"t|jdd�tjko |jjtjkS)�b
        Check whether *cls* has a frozen ancestor by looking at its
        __setattr__.
        r#N)rUr�r�r#r"rrrrr�s
��r�cCs
|jtkS)r�)r�r�rrrrr�scst�fdd�|D��S)z:
    Create a tuple of all values of *obj*'s *attrs*.
    c3s|]}t�|j�VqdSr)rUr`ru��objrrrpsz"_attrs_to_tuple.<locals>.<genexpr>r�)r�rNrr�r�_attrs_to_tuplesr�cCslt��}d}d}d�||jt|d|j�|�}ddt|�f|f}tj�	||�|krT|S|d7}d�|�}qdS)zF
    Create a "filename" suitable for a function being generated.
    r?rz <attrs generated {0} {1}.{2}{3}>r$Nz-{0})
�uuidZuuid4rAr#rUr"rP�	linecache�cache�
setdefault)rZ	func_nameZ	unique_idZextra�count�unique_filenameZ
cache_linerrr�_generate_unique_filename"s"�	��rcs�tdd��D���d}t|d�}t|��dg����fdd�}|r���|dt�|r~|d	t|d
���|d
d�n|dt|d
���|d
t�n
|d|�d���}i}i}	t||d�}
t|
||	�t|�d|�	d�|ft
j|<|	dS)Ncss0|](}|jdks$|jdkr|jdkr|VqdS)TN)r,r2rurrrrpAs



z_make_hash.<locals>.<genexpr>z        r,zdef __hash__(self):csP��||d|d�fg��D]}��|d|j�q$��|d�dS)z�
        Generate the code for actually computing the hash code.
        Below this will either be returned directly or used to compute
        a value which is then cached, depending on the value of cache_hash
        zhash((z        %d,�        self.%s,z    ))N)�extendrCr`)�prefix�indentrv�rNZmethod_linesZ	type_hashrr�append_hash_computation_linesLs�z1_make_hash.<locals>.append_hash_computation_lineszif self.%s is None:zobject.__setattr__(self, '%s', ��)z
self.%s = zreturn self.%szreturn r>r@Tr�)r�rr,rCr�rHrGrFr��
splitlinesr�r)rrNr�r�Ztabrr
�scriptrK�locs�bytecoderr	rr�@sB�
��

�
r�cCst||ddd�|_|S)z%
    Add a hash method to *cls*.
    Fr�)r�r��rrNrrr�	_add_hash|srcCs|�|�}|tkrtS|S)z^
    Check equality and either forward a NotImplemented or return the result
    negated.
    )r��NotImplemented)r �other�resultrrrr��s
r�c
Cs�dd�|D�}t|d�}dddg}|rt|�d�dg}|D](}|�d	|jf�|�d
|jf�q:||dg7}n
|�d�d
�|�}i}i}t||d�}	t|	||�t|�d|�d�|ftj	|<|dt
fS)NcSsg|]}|jr|�qSr)r2rurrrrb�sz_make_eq.<locals>.<listcomp>r2zdef __eq__(self, other):z-    if other.__class__ is not self.__class__:z        return NotImplementedz
    return  (z
    ) == (rz        other.%s,z    )z    return Truer>r@Tr�)rrCr`rHrGrFr�r
r�rr�)
rrNr�linesZothersrvrrKrrrrrr��s2
�


�
r�csVdd��D���fdd���fdd�}�fdd�}�fd	d
�}�fdd�}||||fS)
NcSsg|]}|jr|�qSr)r3rurrrrb�sz_make_order.<locals>.<listcomp>cs
t|��S)z&
        Save us some typing.
        )r�r��rNrr�attrs_to_tuple�sz#_make_order.<locals>.attrs_to_tuplecs |j|jkr�|��|�kStS��1
        Automatically created by attrs.
        �rr�r r�rrrr��sz_make_order.<locals>.__lt__cs |j|jkr�|��|�kStSrrrrrrr��sz_make_order.<locals>.__le__cs |j|jkr�|��|�kStSrrrrrrr��sz_make_order.<locals>.__gt__cs |j|jkr�|��|�kStSrrrrrrr��sz_make_order.<locals>.__ge__r)rrNr�r�r�r�r)rNrrr��s				r�cCs$|dkr|j}t||�\|_|_|S)z5
    Add equality methods to *cls* with *attrs*.
    N)ryr�r�r�rrrr�_add_eq�srcs$tdd�|D�����fdd�}|S)z^
    Make a repr method that includes relevant *attrs*, adding *ns* to the full
    name.
    css2|]*}|jdk	r|j|jdkr"tn|jfVqdS)FTN)r*r`rurrrrp�s
�z_make_repr.<locals>.<genexpr>c	
sz
tj}Wn tk
r*t�}|t_YnXt|�|kr<dS|j}�dkrxt|dd�}|dk	rp|�dd�d}q�|j}n�d|j}|�	t|��z\|dg}d	}�D]8\}}|r�d
}n
|�d�|�|d|t||t
��f�q�d
�|�dW�S|�
t|��XdS)rz...Nr$z>.rrxro�(TFri�=r?r)�_already_repring�working_setr�r��idrrU�rsplitr"r��removerCrrrH)	r r"Zreal_clsr��
class_namer�firstr`Z	attr_repr�Zattr_names_with_reprsr�rrr!s6

�z_make_repr.<locals>.__repr__r�)rNr�r!rr(rr��s
�*r�cCs|dkr|j}t||�|_|S)z%
    Add a repr method to *cls*.
    N)ryr�r!)rr�rNrrr�	_add_repr1sr)cCs�dd�|D�}t|d�}t|||||||�\}	}
}i}t|	|d�}
tdd�|D��}|
�t|d��|dkrtt|
d	<t|
|
|�t|	�d|	�	d�|ft
j|<|d
}||_|S)NcSs g|]}|js|jtk	r|�qSr)r-r(rrurrrrb?s
z_make_init.<locals>.<listcomp>r-r@css|]}|j|fVqdSrrtrurrrrpHsz_make_init.<locals>.<genexpr>)r�	attr_dictTZ_cached_setattrr�)
r�_attrs_to_init_scriptrGr��updaterr�rFr�r
r�rrT)rrN�	post_initr�r�r�r�r�rrrK�annotationsrrr*r�rrrr�<s4
�
�
r�cCs8t|�std��t|dd�}|dkr4tdj|d���|S)a�
    Return 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 accessors) of `attr.Attribute`

    ..  versionchanged:: 16.2.0 Returned tuple allows accessing the fields
        by name.
    �Passed object must be a class.ryN�({cls!r} is not an attrs-decorated class.r)r	r5rUrrArrrr�fieldsas
�r1cCsFt|�std��t|dd�}|dkr4tdj|d���tdd�|D��S)a8
    Return an ordered dictionary of ``attrs`` attributes for a class, whose
    keys are the attribute names.

    :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: an ordered dict where keys are attribute names and values are
        `attr.Attribute`\ s. This will be a `dict` if it's
        naturally ordered like on Python 3.6+ or an
        :class:`~collections.OrderedDict` otherwise.

    .. versionadded:: 18.1.0
    r/ryNr0rcss|]}|j|fVqdSrrtrurrrrp�szfields_dict.<locals>.<genexpr>)r	r5rUrrArrrrr�fields_dict}s
�r2cCsDtjdkrdSt|j�D]&}|j}|dk	r|||t||j��qdS)z�
    Validate all attributes on *inst* that have a validator.

    Leaves all exceptions through.

    :param inst: Instance of a class with ``attrs`` attributes.
    FN)rZ_run_validatorsr1rr)rUr`)�instrvr�rrr�validate�s
r4cCs
d|jkS)Nr�)r}rrrr�_is_slot_cls�sr5cCs||kot||�S)z>
    Check if the attribute name comes from a slot class.
    )r5)Za_namer�rrr�
_is_slot_attr�sr6c
s�g}t�fdd�|D��}|dkrx|dkrF|�d�dd�}	dd�}
q�|�d	�|r^|�d��fd
d�}	�fdd�}
ndd�}	d
d�}
g}g}g}
i}ddi}|D�] }|jr�|
�|�|j}|j�d�}t|jt�}|r�|jjr�d}nd}|j	dk�r�|�rrt
�|j�}|jdk	�rJ|�|
||d�|���t
�|j�}|j||<n|�|	||d�|���|jj||<nT|jdk	�r�|�|
|dj|d���t
�|j�}|j||<n|�|	|dj|d����n�|jtk	�rL|�sLdj||d�}|j�r�|�|�n
|�|�|jdk	�r8|�|
||��|j|t
�|j�<n|�|	||���nR|�r@dj|d�}|j�rr|�|�n
|�|�|�dj|d��t
�|j�}|jdk	�r�|�d|
||��|�d�|�d|
||d�|���|j|t
�|j�<n<|�d|	||��|�d�|�d|	||d�|���|jj||<n^|j�rT|�|�n
|�|�|jdk	�r�|�|
||��|j|t
�|j�<n|�|	||��|j	dkr�|jdkr�|jdk	r�|j||<q�|
�r,t|d<|�d�|
D]F}d �|j�}d!�|j�}|�d"�|||j��|j||<|||<�q�|�r<|�d#�|�rp|�rZ|�rTd$}nd%}nd&}|�|td'f�|�r�d(�d)d�|D��}|�d*|f�d+�|�}|�r�t�r�td,��|d-j|�r�d+ndd+�|�d.�7}d/j||�r�d0�|�nd1d2�||fS)3z�
    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__``.
    c3s|]}t|j��VqdSr)r6r`ru�r�rrrp�sz(_attrs_to_init_script.<locals>.<genexpr>Tz8_setattr = _cached_setattr.__get__(self, self.__class__)cSsd||d�S)N�(_setattr('%(attr_name)s', %(value_var)s)�r=�	value_varrr9rrr�
fmt_setter�s�z)_attrs_to_init_script.<locals>.fmt_settercSst�|�}d|||d�S)Nz2_setattr('%(attr_name)s', %(conv)s(%(value_var)s))�r=r:Zconv��_init_converter_patrA�r=r:�	conv_namerrr�fmt_setter_with_converter�s
�z8_attrs_to_init_script.<locals>.fmt_setter_with_converterz_inst_dict = self.__dict__cs,t|��rd||d�}nd||d�}|S)Nr8r9z+_inst_dict['%(attr_name)s'] = %(value_var)s)r6)r=r:�resr7rrr;�s
�
�cs.t�|�}t|��rd}nd}||||d�S)Nz/_setattr('%(attr_name)s', %(c)s(%(value_var)s))z2_inst_dict['%(attr_name)s'] = %(c)s(%(value_var)s))r=r:�c)r>rAr6)r=r:r@Ztmplr7rrrA�s

�cSsd||d�S)Nzself.%(attr_name)s = %(value)s�r=r�rrDrrrr;s�cSst�|�}d|||d�S)Nz,self.%(attr_name)s = %(conv)s(%(value_var)s)r<r=r?rrrrA	s
��returnNr�r r?Fz({0})z attr_dict['{attr_name}'].default)r=z+{arg_name}=attr_dict['{attr_name}'].default)�arg_namer=z{arg_name}=NOTHING)rFzif {arg_name} is not NOTHING:z    zelse:rz#if _config._run_validators is True:z__attr_validator_{}z	__attr_{}z    {}(self, {}, self.{})zself.__attrs_post_init__()z_setattr('%s', %s)z_inst_dict['%s'] = %szself.%s = %s�None�,css|]}|jrd|jVqdS)zself.N)r-r`rurrrrp�sz BaseException.__init__(self, %s)riz7Keyword-only arguments only work on Python 3 and later.z {leading_comma}*, {kw_only_args})Z
leading_comma�kw_only_argsz(def __init__(self, {args}):
    {lines}
z
    �pass)�argsr)r�rCr)r`�lstriprer(r8�
takes_selfr-�_init_factory_patrAr.r>r:rr1r0rr�rHrr)rNr�r�r-r�r�r�rZany_slot_ancestorsr;rArKrIZattrs_to_validateZnames_for_globalsr.rvr=rFZhas_factoryZ
maybe_selfZinit_factory_namer@�argZval_nameZinit_hash_cache�valsrr7rr+�s`��

�


�����������
�
�

��
���	�
�
���
�
�
�


����r+c@s`eZdZdZdZddd�Zdd�Zedd	d
��Ze	dd��Z
d
d�Zdd�Zdd�Z
dd�ZdS)rra 
    *Read-only* representation of an attribute.

    :attribute name: The name of the attribute.

    Plus *all* arguments of `attr.ib` (except for ``factory``
    which is only syntactic sugar for ``default=Factory(...)``.

    For the version history of the fields, see `attr.ib`.
    )r`r(r)r*r2r3r,r-r/r0r.r1NFcCs�t|||
�\}}
t�|t�}|d|�|d|�|d|�|d|�|d|�|d|
�|d|�|d|�|d	|
�|d
|r�t|�nt�|d|	�|d|�dS)
Nr`r(r)r*r2r3r,r-r.r/r0r1)r4r�r�rrr�_empty_metadata_singleton)r r`r(r)r*r+r,r-r/r0r.r1r2r3�
bound_setattrrrrr��s&








�
�
zAttribute.__init__cCs
t��dSrr�r�rrrr�szAttribute.__setattr__csT|dkr�j}n�jdk	r"td���fdd�tjD�}|f|�j�j|dd�|��S)Nz8Type annotation and type argument cannot both be presentcs i|]}|dkr|t�|��qS))r`r)r(r0r�)r_r��rarrrws��z0Attribute.from_counting_attr.<locals>.<dictcomp>)r`r)r(r0r+)r0r6rrr��
_validator�_default)rr`rar0Z	inst_dictrrSrrss$
�
���zAttribute.from_counting_attrcCstjttdd�|jo|jS)zD
        Simulate the presence of a cmp attribute and warn.
        rr�)r�r�r�r�r2r3rrrrr+3sz
Attribute.cmpcKst�|�}|�|���|S)z2
        Copy *self* and apply *changes*.
        )�copy�	_setattrsr)r Zchanges�newrrrr|=s
zAttribute._assoccst�fdd��jD��S)�(
        Play nice with pickle.
        c3s*|]"}|dkrt�|�nt�j�VqdS)r/N)rUr�r/r�rrrrpLs�z)Attribute.__getstate__.<locals>.<genexpr>)r�r�rrrrr�Hs�zAttribute.__getstate__cCs|�t|j|��dS)rYN)rWr�r�)r r�rrrr�QszAttribute.__setstate__cCsHt�|t�}|D]2\}}|dkr,|||�q|||r<t|�nt�qdS)Nr/)r�r�rrrrQ)r Zname_values_pairsrRr`r�rrrrWWs�
�zAttribute._setattrs)NNNFNN)N)r"r#r$r%r�r�r�r�rsrEr+r|r�r�rWrrrrrr�s$�
+
		rrc
Cs*g|]"}t|tddddd|dkdd�	�qS)NTFr/)	r`r(r)r*r+r2r3r,r-�rrrr�rrrrbes��rbrcCsg|]}|jr|�qSr)r,rurrrrbvsc
@s`eZdZdZdZedd�dD��edddddd	dd	dd	d
�
fZdZdd
�Z	dd�Z
dd�ZdS)r9a
    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.
    )r[rUr*r2r3r,r-r/rTr.r0r1c
cs*|]"}t|tddddddddd�
VqdS)NTF�
r`r(r)r*r+r,r-r1r2r3rZr�rrrrp�s
��z_CountingAttr.<genexpr>)r[rUr*r2r3r,r-r/NTFr[rc

Csztjd7_tj|_||_|r:t|ttf�r:t|�|_n||_||_	||_
||_||_||_
||_||_|	|_|
|_dSrq)r9�cls_counterr[rUre�listr��and_rTr*r2r3r,r-r.r/r0r1)
r r(r)r*r+r,r-r.r/r0r1r2r3rrrr��sz_CountingAttr.__init__cCs$|jdkr||_nt|j|�|_|S)z�
        Decorator that adds *meth* to the list of validators.

        Returns *meth* unchanged.

        .. versionadded:: 17.1.0
        N)rTr^�r r�rrrr)�s
z_CountingAttr.validatorcCs"|jtk	rt��t|dd�|_|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)rM)rUrrr8r_rrrr(�s

z_CountingAttr.default)r"r#r$r%r�r�rrryr\r�r)r(rrrrr9zs.
����$!r9)r�r-r,c@s&eZdZdZe�Ze�Zddd�ZdS)r8a�
    Stores a factory callable.

    If passed as the default value to `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*
    FcCs||_||_dS)z�
        `Factory` is part of the default machinery so if we want a default
        value here, we have to implement it ourselves.
        N)r:rM)r r:rMrrrr�szFactory.__init__N)F)r"r#r$r%r;r:rMr�rrrrr8�sr8c	Ks�t|t�r|}n*t|ttf�r2tdd�|D��}ntd��|�dd�}t|||dkrXind|i�}zt�d�j	�
dd�|_Wntt
fk
r�YnX|�d	d�}t||�
d
�|�
d��\|d
<|d<tfd|i|��|�S)
aR
    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.

        If *attrs* is a list or an ordered dict (`dict` on Python 3.6+,
        `collections.OrderedDict` otherwise), the order is deduced from
        the order of the names or attributes inside *attrs*.  Otherwise the
        order of the definition of the attributes is used.
    :type attrs: `list` or `dict`

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

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

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

    .. versionadded:: 17.1.0 *bases*
    .. versionchanged:: 18.1.0 If *attrs* is ordered, the order is retained.
    css|]}|t�fVqdSr)r;rurrrrp4szmake_class.<locals>.<genexpr>z(attrs argument must be a dict or a list.r�Nrr"�__main__r+r2r3r�)rer�r]r�r5�popr0�sys�	_getframe�	f_globalsrjr#r�r6r4r�)r`rN�basesZattributes_argumentsZcls_dictr-Ztype_r+rrr�
make_classs8
�	�
��
�rf)r�r,c@seZdZdZe�Zdd�ZdS)�
_AndValidatorz2
    Compose many validators to a single one.
    cCs|jD]}||||�qdSr)�_validators)r r3rgr�r�rrr�__call__`s
z_AndValidator.__call__N)r"r#r$r%r;rhrirrrrrgXsrgcGs6g}|D] }|�t|t�r |jn|g�qtt|��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
    )rrergrhr�)Z
validatorsrPr)rrrr^es��r^)NNNTNNTFFTFFFFFNN)N)NN)QZ
__future__rrrrVr�rbZ	threadingr�r��operatorrr?rZ_compatrr	r
rrr
�
exceptionsrrrrr�objectr�r�r>rNrDrRr�rQr�rrr;rLrMrSrYr^r�r�r�r�r�r4rNr�r�r�rr�rr�r�r�rZlocalr!r�r)r�r1r2r4r5r6r+rrr�Z_ar9r8rfrgr^rrrr�<module>s� 
��
��
k4��
~
<'0
;
%��~A