B
    ›³ëb>  ã               @   sf   d Z ddlmZmZ ddlZdgZdZdZe	dœdd	„Z
ddœd
d„Zeeeeeef dœdd„ZdS )zÈVariable type for true/false Variables.

Usage example::

    opts = Variables()
    opts.Add(BoolVariable('embedded', 'build for an embedded system', 0))
    ...
    if env['embedded'] == 1:
    ...
é    )ÚTupleÚCallableNÚBoolVariable)ÚyZyesÚtrueÚtÚ1ZonÚall)ÚnZnoZfalseÚfÚ0ZoffZnone)Úreturnc             C   s0   |   ¡ }|tkrdS |tkr dS td|  ƒ‚dS )aL  Converts strings to True/False.

    If *val* looks like it expresses a bool-like value, based on
    the :data:`TRUE_STRINGS` and :data:`FALSE_STRINGS` tuples,
    return the appropriate value.

    This is usable as a converter function for SCons Variables.

    Raises:
        ValueError: if the string cannot be converted.
    TFz$Invalid value for boolean option: %sN)ÚlowerÚTRUE_STRINGSÚFALSE_STRINGSÚ
ValueError)ÚvalZlval© r   ú;lib/python3.7/site-packages/SCons/Variables/BoolVariable.pyÚ
_text2bool-   s    r   c             C   s(   ||  dkr$t j d| ||  f ¡‚dS )zàValidates the given value to be either true or false.

    This is usable as a validator function for SCons Variables.

    Raises:
        KeyError: if key is not set in env
        UserError: if key does not validate.
    )TFz'Invalid value for boolean option %s: %sN)ÚSConsZErrorsZ	UserError)Úkeyr   Úenvr   r   r   Ú
_validatorB   s    	r   c             C   s   d| }| ||t tfS )a>  Return a tuple describing a boolean SCons Variable.

    The input parameters describe a boolean option. Returns a tuple
    including the correct converter and validator.
    The *help* text will have ``(yes|no)`` automatically appended to show the
    valid values. The result is usable as input to :meth:`Add`.
    z%s (yes|no))r   r   )r   ÚhelpÚdefaultr   r   r   r   Q   s    )Ú__doc__Útypingr   r   ZSCons.Errorsr   Ú__all__r   r   Úboolr   r   Ústrr   r   r   r   r   Ú<module>!   s   