Viewing File: /opt/alt/python35/lib/python3.5/site-packages/attr/__pycache__/_funcs.cpython-35.pyc



#IGZ@sddlmZmZmZddlZddlmZddlmZm	Z	m
Z
ddlmZdde
dd	d
ZddedddZd
dZddZddZdS))absolute_importdivisionprint_functionN)	iteritems)NOTHING_obj_setattrfields)AttrsAttributeNotFoundErrorTFc
	sat|j}}xB|D]:}t||j}dk	rV||rVq|dkrLt|jrt|dddd||j<qYt|ttt	fr|dkr|jnt}	|	fdd|D||j<qYt|t
r<fdd	t|D||j<qY|||j<q|||j<qW|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*
    NTrecursefilterdict_factoryc
sCg|]9}t|jr9t|ddddn|qS)rTrr
)has	__class__asdict).0i)r
r
/_funcs.py
<listcomp>4s	zasdict.<locals>.<listcomp>c3sc|]Y\}}t|jr0t|dn|t|jrTt|dn|fVqdS)r
N)rrr)rkkvv)dfrr	<genexpr>;szasdict.<locals>.<genexpr>)r	rgetattrnamerr
isinstancetuplelistsetdictr)
instrrr
retain_collection_typesattrsrvavcfr)rr
rrr
s,	
rcst|j}g}|xc|D][}t||j}dk	rY||rYq"|dkrpt|jr|jt|dddddq}t|tt	t
frdkr|jnt	}	|j|	fdd|Dq}t|tr`dkr(|jnt}
|j|
fd	d
t|Dq}|j|q"|j|q"Wt	kr|S|S)a8
    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 :class:`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
    NTrr
tuple_factoryr"csIg|]?}t|jr?t|dddddn|qS)rTrr(r")rrastuple)rj)rretainr(rrrqs	zastuple.<locals>.<listcomp>c3so|]e\}}t|jr6t|ddn|t|jr`t|ddn|fVqdS)r(r"N)rrr))rrr)r+r(rrrzszastuple.<locals>.<genexpr>)
r	rrrrappendr)rrrrr r)r!rrr(r"r#r$r%r&r'rr)rr+r(rr)Fs2

		r)cCst|dddk	S)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: :class:`bool`
    Z__attrs_attrs__N)r)clsrrrrs	rcKsddl}|jdtddtj|}t|j}xit|D][\}}t||t}|tkrt	dj
d|d|jt|||qMW|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 :func:`evolve` instead.
    rNz6assoc is deprecated and will be removed after 2018/01.
stacklevelz&{k} is not an attrs attribute on {cl}.kZcl)warningswarnDeprecationWarningcopyr	rrrrr
formatr)r!changesr1newr#r0r&r%rrrassocs	
	r8cKs|j}t|}xh|D]`}|js.q|j}|ddkrM|n
|dd}||krt||||<qW||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_rN)rr	Zinitrr)r!r6r-r#r%Z	attr_nameZ	init_namerrrevolves	
		&r:)Z
__future__rrrr4Z_compatr_makerrr	
exceptionsr
r rrr)rr8r:rrrr<module>s	;	G!
Back to Directory File Manager