관리-도구
편집 파일: _funcs.cpython-39.pyc
a ����Pͣ_3����������������������@���s����d�dl�mZmZmZ�d�dlZddlmZ�ddlmZm Z m Z �ddlmZ�dde ddfd d �Zdd��Zddedfd d�Zdd��Zdd��Zdd��Zddd�ZdS�)�����)�absolute_import�division�print_functionN����)� iteritems)�NOTHING�_obj_setattr�fields)�AttrsAttributeNotFoundErrorTFc��������������������s��t�|�j�}���}|D�]�}t|�|j�} �dur8�|| �s8q�durL�|�|| �} |du��rt| j�rzt| d�����||j<�n�t| ttt t f�rdu�r�| jnt} | ����fdd�| D���||j<�n@t| t�r�����������fdd�t| �D���||j<�n | ||j<�q| ||j<�q|S�)a��� Return the ``attrs`` attribute values of *inst* as a dict. Optionally recurse into other ``attrs``-decorated classes. :param inst: Instance of an ``attrs``-decorated class. :param bool recurse: Recurse into classes that are also ``attrs``-decorated. :param callable filter: A callable whose return code determines whether an attribute or element is included (``True``) or dropped (``False``). Is called with the `attr.Attribute` as the first argument and the value as the second argument. :param callable dict_factory: A callable to produce dictionaries from. For example, to produce ordered dictionaries instead of normal Python dictionaries, pass in ``collections.OrderedDict``. :param bool retain_collection_types: Do not convert to ``list`` when encountering an attribute whose type is ``tuple`` or ``set``. Only meaningful if ``recurse`` is ``True``. :param Optional[callable] value_serializer: A hook that is called for every attribute or dict key/value. It receives the current instance, field and value and must return the (updated) value. The hook is run *after* the optional *filter* has been applied. :rtype: return type of *dict_factory* :raise attr.exceptions.NotAnAttrsClassError: If *cls* is not an ``attrs`` class. .. versionadded:: 16.0.0 *dict_factory* .. versionadded:: 16.1.0 *retain_collection_types* .. versionadded:: 20.3.0 *value_serializer* NTc��������������������s���g�|�]}t�|�������qS�����_asdict_anything��.0�i��dict_factory�filter�retain_collection_types�value_serializerr����//usr/lib/python3.9/site-packages/attr/_funcs.py� <listcomp>I���s�����zasdict.<locals>.<listcomp>c�����������������3���s2���|�]*\}}t�|������t�|������fV��qd�S��Nr����r���ZkkZvv��dfr���r���r���r���r���� <genexpr>V���s �������zasdict.<locals>.<genexpr>) r ���� __class__�getattr�name�has�asdict� isinstance�tuple�list�set� frozenset�dictr���)�inst�recurser���r���r���r����attrs�rv�a�v�cfr����r���r���r���r���r���r���r!��� ���sB����( ��� �r!���c��������������������s����t�|�jdd�dur&t|�d�����}n�t|�ttttf�rh�du�rF|�jnt}|����fdd�|�D���}nHt|�t�r�����������fdd�t |��D���}n|�}�dur��dd|�}|S�)zK ``asdict`` only works on attrs instances, this works on anything. �__attrs_attrs__NTc��������������������s���g�|�]}t�|�������qS�r���r���r���r���r���r���r�������s�����z$_asdict_anything.<locals>.<listcomp>c�����������������3���s2���|�]*\}}t�|������t�|������fV��qd�S�r���r���r���r���r���r���r�������s��� � � ��z#_asdict_anything.<locals>.<genexpr>) r���r���r!���r"���r#���r$���r%���r&���r'���r���)�valr���r���r���r���r+���r.���r���r/���r���r ���p���s2���� ��� � r ���c�������������� ������s��t�|�j�}g�}|�|D�]�}t|�|j�}��dur:��||�s:q|du�r�t|j�rf|�t|d����d���n�t|tt t tf�r��du�r�|jnt } |�| ����fdd�|D�����nJt|t�r�du�r�|jnt} |�| ��fdd�t |�D�����n |�|��q|�|��q�t u��r|S��|�S�)a1�� Return the ``attrs`` attribute values of *inst* as a tuple. Optionally recurse into other ``attrs``-decorated classes. :param inst: Instance of an ``attrs``-decorated class. :param bool recurse: Recurse into classes that are also ``attrs``-decorated. :param callable filter: A callable whose return code determines whether an attribute or element is included (``True``) or dropped (``False``). Is called with the `attr.Attribute` as the first argument and the value as the second argument. :param callable tuple_factory: A callable to produce tuples from. For example, to produce lists instead of tuples. :param bool retain_collection_types: Do not convert to ``list`` or ``dict`` when encountering an attribute which type is ``tuple``, ``dict`` or ``set``. Only meaningful if ``recurse`` is ``True``. :rtype: return type of *tuple_factory* :raise attr.exceptions.NotAnAttrsClassError: If *cls* is not an ``attrs`` class. .. versionadded:: 16.2.0 NT�r)���r���� tuple_factoryr���c�������������� ������s,���g�|�]$}t�|j�r$t|d�����d�n|�qS�)Tr2����r ���r����astuple)r����j�r����retainr3���r���r���r�������s��� ���zastuple.<locals>.<listcomp>c�����������������3���sJ���|�]B\}}t�|j�r"t|���d��n|t�|j�r<t|���d��n|fV��qdS�))r3���r���Nr4���r���)r8���r3���r���r���r�������s ���������zastuple.<locals>.<genexpr>)r ���r���r���r���r ����appendr5���r"���r#���r$���r%���r&���r'���r���)r(���r)���r���r3���r���r*���r+���r,���r-���r.���r���r���r7���r���r5�������sJ����! �� ��� ��r5���c�����������������C���s���t�|�dd�duS�)z� Check whether *cls* is a class with ``attrs`` attributes. :param type cls: Class to introspect. :raise TypeError: If *cls* is not a class. :rtype: bool r0���N)r���)�clsr���r���r���r �����s���� r ���c�����������������K���sv���ddl�}|jdtdd��t�|��}t|�j�}t|�D�]<\}}t||t�}|tu�rdt dj ||jd���t|||��q4|S�)a��� Copy *inst* and apply *changes*. :param inst: Instance of a class with ``attrs`` attributes. :param changes: Keyword changes in the new copy. :return: A copy of inst with *changes* incorporated. :raise attr.exceptions.AttrsAttributeNotFoundError: If *attr_name* couldn't be found on *cls*. :raise attr.exceptions.NotAnAttrsClassError: If *cls* is not an ``attrs`` class. .. deprecated:: 17.1.0 Use `evolve` instead. r���Nz6assoc is deprecated and will be removed after 2018/01.����)� stacklevelz&{k} is not an attrs attribute on {cl}.)�kZcl)�warnings�warn�DeprecationWarning�copyr ���r���r���r���r���r ����formatr���)r(����changesr>����newr*���r=���r-���r,���r���r���r����assoc��s$����� ��rE���c�����������������K���sf���|�j�}t|�}|D�]D}|jsq|j}|d�dkr4|n |dd��}||vrt|�|�||<�q|f�i�|��S�)a��� Create a new instance, based on *inst* with *changes* applied. :param inst: Instance of a class with ``attrs`` attributes. :param changes: Keyword changes in the new copy. :return: A copy of inst with *changes* incorporated. :raise TypeError: If *attr_name* couldn't be found in the class ``__init__``. :raise attr.exceptions.NotAnAttrsClassError: If *cls* is not an ``attrs`` class. .. versionadded:: 17.1.0 r����_r���N)r���r ����initr���r���)r(���rC���r:���r*���r,���Z attr_nameZ init_namer���r���r����evolve=��s����rH���c�������������� ���C���sj���z |�j��W�nZ�tyd���ddl}|j|�||d�}t|��D�] }|j|v�r8t|d||j���q8d|�_�Y�n0�|�S�)a��� Resolve any strings and forward annotations in type annotations. This is only required if you need concrete types in `Attribute`'s *type* field. In other words, you don't need to resolve your types if you only use them for static type checking. With no arguments, names will be looked up in the module in which the class was created. If this is not what you want, e.g. if the name only exists inside a method, you may pass *globalns* or *localns* to specify other dictionaries in which to look up these names. See the docs of `typing.get_type_hints` for more details. :param type cls: Class to resolve. :param Optional[dict] globalns: Dictionary containing global variables. :param Optional[dict] localns: Dictionary containing local variables. :raise TypeError: If *cls* is not a class. :raise attr.exceptions.NotAnAttrsClassError: If *cls* is not an ``attrs`` class. :raise NameError: If types cannot be resolved because of missing variables. :returns: *cls* so you can use this function also as a class decorator. Please note that you have to apply it **after** `attr.s`. That means the decorator has to come in the line **before** `attr.s`. .. versionadded:: 20.1.0 r���N)�globalns�localns�typeT)Z__attrs_types_resolved__�AttributeError�typing�get_type_hintsr ���r���r���)r:���rI���rJ���rM����hintsZfieldr���r���r���� resolve_typesZ��s���� rP���)NN)Z __future__r���r���r���rA���Z_compatr����_maker���r���r ���� exceptionsr ���r'���r!���r ���r#���r5���r ���rE���rH���rP���r���r���r���r����<module>���s(���� f9� d&