kfZAddlZddlmZmZddlmZmZmZddlm Z dde ddfdZ d Z dde dfd Zd Zd Zd Z ddZdS)N) PY_3_9_PLUSget_generic_base)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)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 `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 attrs.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 rrr_asdict_anything.0irr rrs k/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/attr/_funcs.py zasdict..LsL   )#(#))54K-=    c 3rK|]1\}}t|dt|dfV2dSTrFNrrkkvvdfr rrs r zasdict..Zs  &B#)#'#))+4K-= )#(#))+4K-=       r) r __class__getattrnamehasasdict isinstancetuplelistset frozensetdictitems) instr r rrrattrsrvavcfr"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 rrrr2r5r"s ```` @rrrvsfs}/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)a) 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 attrs.exceptions.NotAnAttrsClassError: If *cls* is not an *attrs* class. .. versionadded:: 16.2.0 NTr r tuple_factoryrc 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=rNr?)rr r!rBr=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/) r0r r r=rr1r2r3r4r5r"rBs `` @rr@r@sB 4> " "E B $F ;; D!& ! !  ffQll   d??1;4   $%&306 AtS)<==* $*dNNQ[[ B      &'      At$$ $*dNNQ[[ B"'(ggii#, ! IIaLLLL$&&22MM",=,==rct|dd}|dSt|}|t|dd}|||_|duSdS)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 r7NTF)r%rr7)clsr1 generic_base generic_attrss rr'r'#sf C*D 1 1E t$C((L .?FF  $"/C D(( 5rc tj|}t|j}|D]O\}}t ||t }|t urt |d|jdt|||P|S)a Copy *inst* and apply *changes*. This is different from `evolve` that applies the changes to the arguments that create the new instance. `evolve`'s behavior is preferable, but there are `edge cases`_ where it doesn't work. Therefore `assoc` is deprecated, but will not be removed. .. _`edge cases`: https://github.com/python-attrs/attrs/issues/251 :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 attrs.exceptions.AttrsAttributeNotFoundError: If *attr_name* couldn't be found on *cls*. :raise attrs.exceptions.NotAnAttrsClassError: If *cls* is not an *attrs* class. .. deprecated:: 17.1.0 Use `attrs.evolve` instead if you can. This function will not be removed du to the slightly different approach compared to `attrs.evolve`. z is not an attrs attribute on .)copyrr$r/r%rr r)r0changesnewr1kr4r3s rassocrO;s6 )D//C 4> " "E   1 E1g & & <<-DDCMDDD  S!Q Jrc|r5 |\}n#t$r"tdt|ddwxYw |d}n#t$rtddwxYwddl}|dtd |j}t|}|D]/}|j s |j }|j }||vrt||||<0|d i|S) a Create a new instance, based on the first positional argument 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 attrs.exceptions.NotAnAttrsClassError: If *cls* is not an *attrs* class. .. versionadded:: 17.1.0 .. deprecated:: 23.1.0 It is now deprecated to pass the instance using the keyword argument *inst*. It will raise a warning until at least April 2024, after which it will become an error. Always pass the instance as a positional argument. z*evolve() takes 1 positional argument, but z were givenNr0z7evolve() missing 1 required positional argument: 'inst'rzgPassing the instance per keyword argument is deprecated and will stop working in, or after, April 2024.) stacklevel) ValueError TypeErrorlenpopKeyErrorwarningswarnDeprecationWarningr$rinitr&aliasr%) argsrLr0rYrFr1r3 attr_name init_names revolverabsT0   GTT   SYY    ;;v&&DD   I     :      .C 3KKE ::v  F G G # #!(y!9!9GI  3>>>>s ,5AA*ct|dd|kreddl}||d}tr||d<|j|fi|}|t |n|D]'}|j|vrt |d||j(||_|S)aA 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. :param bool include_extras: Resolve more accurately, if possible. Pass ``include_extras`` to ``typing.get_hints``, if supported by the typing module. On supported Python versions (3.9+), this resolves the types more accurately. :raise TypeError: If *cls* is not a class. :raise attrs.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* .. versionadded:: 23.1.0 *include_extras* __attrs_types_resolved__Nr)globalnslocalnsinclude_extrastype)r%typingrget_type_hintsrr&rrc) rFrdreattribsrfrhkwargshintsfields r resolve_typesrnsVs.55<< &7;;  6'5F# $%%c44V44$+OVC[[[ ? ?EzU""UFE%*,=>>>(+$ Jr)NNNT)rK_compatrr_makerrr exceptionsr r.r(rr*r@r'rOrarnrSrrrrs 222222220000000000333333  ! hhhhVFFFV  ! a>a>a>a>H0$$$N;;;~DH======r