c8pddlZddlmZmZmZddlmZddeddfdZdZ dde dfd Z d Z d Z d Zdd ZdS)N)NOTHING _obj_setattrfields)AttrsAttributeNotFoundErrorTFc  t|j}}|D],}t||j}  || s' ||| } |durt | jrt | d||j<lt | ttttfr5dur| jnt} | fd| D||j<t | tr8  fd| D||j<| ||j<"| ||j<.|S)af 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 `attrs.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* .. versionadded:: 21.3.0 If a dict has a collection for a key, it is serialized as a tuple. NTrecursefilter dict_factoryretain_collection_typesvalue_serializerc :g|]}t|dSFis_keyr r r r_asdict_anything.0ir r r rs -/usr/lib/python3/dist-packages/attr/_funcs.py zasdict..KsL   )#(#))54K-=    c 3rK|]1\}}t|dt|dfV2dSTrFNrrkkvvdfr r rs r zasdict..Ys  &B#)#'#))+4K-= )#(#))+4K-=       r) r __class__getattrnamehasasdict isinstancetuplelistset frozensetdictitems) instr r r r rattrsrvavcfr s ```` @rr&r& sT 4> " "E B ;; D!& ! !  ffQll    '  q!,,A d??1;0 # !!-,C%5 16 AtS)<==' $;t$C$CQ[[R       "#     16 At$$ !R       &#$''))'   16 ,16 BqvJJ Irct|jddt|d}nt|tt t tfr8dur|j}n|rt}nt }|fd|D}nUt|tr/fd| D}n|} dd|}|S)zK ``asdict`` only works on attrs instances, this works on anything. __attrs_attrs__NTr c :g|]}t|dSrrrs rrz$_asdict_anything..sL   ! !!-,C%5    rc 3rK|]1\}}t|dt|dfV2dSrrrs rr!z#_asdict_anything..s  &B#!!!#,C%5 ! !!#,C%5        r) r#r"r&r'r(r)r*r+r,r-) valrr r r rr0r3r s ```` @rrrusfs}/66B  %$;-     C%sI6 7 7/2 "d * *BB  BBB R              C  2  R       &))++'     ,  '!!$b11B Irc . t|j}g}| |D]a}t||j} ||s'|dur t |jr(|t |d ht|ttttfr? dur|jnt} ||  fd|Dt|trQ dur|jnt} || fd| D5||L||ctur|n |S)a2 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 `attrs.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 NTr r tuple_factoryr c dg|],}t|jrt|dn|-S)Tr:r%r"astuple)rjr retainr;s rrzastuple..sd   !" #1;//#G !(,'-.;8> "#   rc3K|]W\}}t|jrt|n|t|jrt|n|fVXdS))r;r Nr=)rrrr@r;s rr!zastuple..s"#B #2<00 $G ".;8> "$ #2<00 $G ".;8> "$r)rr"r#r$r%appendr>r'r(r)r*r+r,r-) r.r r r;r r/r0r1r2r3r r@s `` @rr>r>sB 4> " "E B $F ;; D!& ! !  ffQll   d??1;4   $%&306 AtS)<==* $*dNNQ[[ B      &'      At$$ $*dNNQ[[ B"'(ggii#, ! IIaLLLL$&&22MM",=,==rc(t|ddduS)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 r5N)r#)clss rr%r%"s 3)4 0 0 < " "E   1 E1g & & <<-DDCMDDD  S!Q Jrc |j}t|}|D]/}|js |j}|j}||vrt ||||<0|di|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"rinitr$aliasr#)r.rMrDr/r1 attr_name init_names revolverWTsr .C 3KKE ::v  F G G # #!(y!9!9GI  3>>>>rct|dd|kr^ddl}||||}|t|n|D]'}|j|vrt |d||j(||_|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. :param Optional[list] attribs: List of attribs for the given class. This is necessary when calling from inside a ``field_transformer`` since *cls* is not an ``attrs`` class yet. :raise TypeError: If *cls* is not a class. :raise attr.exceptions.NotAnAttrsClassError: If *cls* is not an ``attrs`` class and you didn't pass any attribs. :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** `attrs.define`. That means the decorator has to come in the line **before** `attrs.define`. .. versionadded:: 20.1.0 .. versionadded:: 21.1.0 *attribs* __attrs_types_resolved__Nr)globalnslocalnstype)r#typingget_type_hintsrr$rrY)rDrZr[attribsr]hintsfields r resolve_typesrbqsHs.55<< %%cHg%NN$+OVC[[[ ? ?EzU""UFE%*,=>>>(+$ Jr)NNN)rL_makerrr exceptionsrr,r&rr(r>r%rPrWrbrRrrres 0000000000333333  ! hhhhVFFFV  ! a>a>a>a>H = = =###L:111111r