� u��g��V�dZddlZddlmZddlmZmZmZmZgd�Z d�Z edfd�Z d �Z dS) z Commonly useful converters. �N�)�_AnnotationExtractor)�NOTHING� Converter�Factory�pipe)�default_if_none�optionalr�to_boolc�t��t�t��r�fd�}n�fd�}t���}|���}|rtj||jd<|���}|rtj||jd<t�t��rt|dd���S|S)a_ 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. Args: converter (typing.Callable): the converter that is used for non-`None` values. .. versionadded:: 17.1.0 c�&��|�dS�|||��S�N�)�val�inst�field� converters ��_/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/attr/converters.py�optional_converterz$optional.<locals>.optional_converter&s!����{��t��9�S�$��.�.� .�c�"��|�dS�|��Srr)rrs �rrz$optional.<locals>.optional_converter-s����{��t��9�S�>�>� !rr�returnT)� takes_self� takes_field)� isinstancerr�get_first_param_type�typing�Optional�__annotations__�get_return_type)rr�xtr�t�rts` rr r s�����)�Y�'�'� "� /� /� /� /� /� /� "� "� "� "� "� �y� )� )�C� � � �"�"�A��G�4:�O�A�4F��*�5�1� � � � � �B� �K�7=��r�7J��*�8�4��)�Y�'�'�P��+��$�O�O�O�O� �rc� ���tur|�d}t|����tur|�d}t|���|�t|���t�t��r�jrd}t |����fd�}n�fd�}|S)a� A converter that allows to replace `None` values by *default* or the result of *factory*. Args: default: Value to be used if `None` is passed. Passing an instance of `attrs.Factory` is supported, however the ``takes_self`` option is *not*. factory (typing.Callable): A callable that takes no parameters whose result is used if `None` is passed. Raises: TypeError: If **neither** *default* or *factory* is passed. TypeError: If **both** *default* and *factory* are passed. 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.c�4��|�|S����Sr)�factory�r�defaults �r�default_if_none_converterz2default_if_none.<locals>.default_if_none_converterls������ ��?�?�$�$� $rc���|�|S�Srrr's �rr)z2default_if_none.<locals>.default_if_none_converterts������ ��Nr)r� TypeErrorrrr� ValueError)r(r&�msgr)s` rr r Bs����4�'���g�o�8����n�n���g���'�"5�E����n�n�����'�"�"���'�7�#�#�� � � "�E�C��S�/�/� !� %� %� %� %� %� %� � � � � � %�$rc��t|t��r|���}|dvrdS|dvrdSd|��}t|���)a� Convert "boolean" strings (for example, from environment variables) to real booleans. Values mapping to `True`: - ``True`` - ``"true"`` / ``"t"`` - ``"yes"`` / ``"y"`` - ``"on"`` - ``"1"`` - ``1`` Values mapping to `False`: - ``False`` - ``"false"`` / ``"f"`` - ``"no"`` / ``"n"`` - ``"off"`` - ``"0"`` - ``0`` Raises: ValueError: For any other value. .. versionadded:: 21.3.0 )T�truer"�yes�y�on�1rT)F�false�f�no�n�off�0rFzCannot convert value to bool: )r�str�lowerr,)rr-s rr r }s^��8�#�s�����i�i�k�k�� �;�;�;��t� �=�=�=��u� 2�3� 2� 2�C� �S�/�/�r) �__doc__r�_compatr�_makerrrr�__all__r r r rrr�<module>r@s������ � � �)�)�)�)�)�)�4�4�4�4�4�4�4�4�4�4�4�4� � � ��*�*�*�Z$�T�8%�8%�8%�8%�v%�%�%�%�%r
Memory