kfRdZddlZddlmZddlmZmZmZgdZdZ edfdZ d Z dS) z Commonly useful converters. N)_AnnotationExtractor)NOTHINGFactorypipe)default_if_noneoptionalrto_boolcfd}t}|}|rtj||jd<|}|rtj||jd<|S)aO A converter that allows an attribute to be optional. An optional attribute is one which can be set to ``None``. Type annotations will be inferred from the wrapped converter's, if it has any. :param callable converter: the converter that is used for non-``None`` values. .. versionadded:: 17.1.0 c"|dS|SN)val converters o/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/attr/converters.pyoptional_converterz$optional..optional_converter$s ;4y~~rreturn)rget_first_param_typetypingOptional__annotations__get_return_type)rrxtrtrts` rr r s y ) )C   ""AG4:OA4F*51    B K7=r7J*84 rctur|tdtur|td|t|ttrjrt dfd}nfd}|S)a A converter that allows to replace ``None`` values by *default* or the result of *factory*. :param default: Value to be used if ``None`` is passed. Passing an instance of `attrs.Factory` is supported, however the ``takes_self`` option is *not*. :param callable factory: A callable that takes no parameters whose result is used if ``None`` is passed. :raises TypeError: If **neither** *default* or *factory* is passed. :raises TypeError: If **both** *default* and *factory* are passed. :raises ValueError: If an instance of `attrs.Factory` is passed with ``takes_self=True``. .. versionadded:: 18.2.0 Nz(Must pass either `default` or `factory`.z5Must pass either `default` or `factory` but not both.z1`takes_self` is not supported by default_if_none.c4||SSr )factoryrdefaults rdefault_if_none_converterz2default_if_none..default_if_none_converterYs ??$$ $rc||SSr rr s rr"z2default_if_none..default_if_none_converteras Nr)r TypeErrorr isinstance takes_self ValueError)r!rr"s` rrr6s$'goBCCCg'"5 C   '""'7##   C  % % % % % %      %$rct|tr|}hd}hd} ||vrdS||vrdSn#t$rYnwxYwt d|)a Convert "boolean" strings (e.g., from env. vars.) to real booleans. Values mapping to :code:`True`: - :code:`True` - :code:`"true"` / :code:`"t"` - :code:`"yes"` / :code:`"y"` - :code:`"on"` - :code:`"1"` - :code:`1` Values mapping to :code:`False`: - :code:`False` - :code:`"false"` / :code:`"f"` - :code:`"no"` / :code:`"n"` - :code:`"off"` - :code:`"0"` - :code:`0` :raises ValueError: for any other value. .. versionadded:: 21.3.0 >T1ryonyestrue>F0fnnoofffalseTFzCannot convert value to bool: )r%strlowerr$r')rtruthyfalsys rr r js4#siikk : : :F ; ; ;E &==4 %<<5        ;c;; < <r<s  ))))))))))))))))   @$T1%1%1%1%h&=&=&=&=&=r