#IGZ� � @ s� d d l m Z m Z m Z d d l Z d d l m Z d d l m Z m Z m Z d d l m Z d d e d d d � Z d d e d d d � Z d d � Z d d � Z d d � Z d S)� )�absolute_import�division�print_functionN� )� iteritems)�NOTHING�_obj_setattr�fields)�AttrsAttributeNotFoundErrorTFc sa t | j � } � � } xB| D]:} t | | j � } � d k rV � | | � rV q | d k rLt | j � r� t | d d d � d � �| | j <qYt | t t t f � r� | d k r� | j n t } | � � f d d � | D� � | | j <qYt | t � r<� � � � f d d � t | � D� � | | j <qY| | | j <q | | | j <q W| 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 :class:`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``. :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* NT�recurse�filter�dict_factoryc sC g | ]9 } t | j � r9 t | d d d � d � �n | � q S)r Tr r )�has� __class__�asdict)�.0�i)r r � � /_funcs.py� <listcomp>4 s zasdict.<locals>.<listcomp>c 3 sc | ]Y \ } } t | j � r0 t | d � �n | t | j � rT t | d � �n | f Vq d S)r N)r r r )r �kk�vv)�dfr r � <genexpr>; s zasdict.<locals>.<genexpr>)r r �getattr�namer r � isinstance�tuple�list�set�dictr ) �instr r r �retain_collection_types�attrs�rv�a�v�cfr )r r r r r s, r c s� t | j � } g } | � xc| D][} t | | j � } � d k rY � | | � rY q"