
    ,h                     T    d Z ddlZddlmZ ddlmZmZmZmZ g dZ	d Z
edfdZd	 Zy)
z
Commonly useful converters.
    N   )_AnnotationExtractor)NOTHING	ConverterFactorypipe)default_if_noneoptionalr   to_boolc                 X    t         t              r fd}n fd}t               }|j                         }|r t        j
                  |   |j                  d<   |j                         }|r t        j
                  |   |j                  d<   t         t              rt        |dd      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                     | y  | ||      S N )valinstfield	converters      Q/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/attr/converters.pyoptional_converterz$optional.<locals>.optional_converter&   s    {S$..    c                     | y  |       S r   r   )r   r   s    r   r   z$optional.<locals>.optional_converter-   s    {S>!r   r   returnT)
takes_selftakes_field)
isinstancer   r   get_first_param_typetypingOptional__annotations__get_return_type)r   r   xtrtrts   `    r   r
   r
      s     )Y'	/	"
 y
)C  "A4:OOA4F**51				B	7=r7J**84)Y'+$OOr   c                       t         u r|d}t        |       t         ur|d}t        |      |t        |       t         t              r  j                  rd}t        |       fd}|S  fd}|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
    z(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                 ,    | | S j                         S r   )factoryr   defaults    r   default_if_none_converterz2default_if_none.<locals>.default_if_none_converterl   s    
??$$r   c                     | | S S r   r   r'   s    r   r)   z2default_if_none.<locals>.default_if_none_convertert   s    
Nr   )r   	TypeErrorr   r   r   
ValueError)r(   r&   msgr)   s   `   r   r	   r	   B   s    4 'go8ng'"5En'"'7#ECS/!	% %$	 %$r   c                 v    t        | t              r| j                         } | dv ry| dv ryd| }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1r   T)Ffalsefnonoff0r   FzCannot convert value to bool: )r   strlowerr,   )r   r-   s     r   r   r   }   sG    8 #siik
;;
==*3'
2C
S/r   )__doc__r   _compatr   _maker   r   r   r   __all__r
   r	   r   r   r   r   <module>r@      s7     ) 4 4*Z $T 8%v%r   