B
    b8                 @   sV   d Z ddlmZmZ ddlZdgZddddZi dfeeeeeef dddZ	dS )	a  Variable type for enumeration Variables.

Enumeration variables allow selection of one from a specified set of values.

Usage example::

    opts = Variables()
    opts.Add(
        EnumVariable(
            'debug',
            help='debug output and symbols',
            default='no',
            allowed_values=('yes', 'no', 'full'),
            map={},
            ignorecase=2,
        )
    )
    ...
    if env['debug'] == 'full':
    ...
    )TupleCallableNEnumVariable)returnc             C   s"   ||krt jd| ||f d S )Nz6Invalid value for option %s: %s.  Valid values are: %s)SConsZErrorsZ	UserError)keyvalenvZvals r
   ;lib/python3.7/site-packages/SCons/Variables/EnumVariable.py
_validator5   s    r   c                sv   d|d  f }|r$ fdd}n fdd}|dkrFfdd}n"|dkr\fd	d}nfd
d}| ||||fS )a  Return a tuple describing an enumaration SCons Variable.

    The input parameters describe an option with only certain values
    allowed. Returns A tuple including an appropriate converter and
    validator. The result is usable as input to :meth:`Add`.

    *key* and *default* are passed directly on to :meth:`Add`.

    *help* is the descriptive part of the help text,
    and will have the allowed values automatically appended.

    *allowed_values* is a list of strings, which are the allowed values
    for this option.

    The *map*-dictionary may be used for converting the input value
    into canonical values (e.g. for aliases).

    The value of *ignorecase* defines the behaviour of the validator:

        * 0: the validator/converter are case-sensitive.
        * 1: the validator/converter are case-insensitive.
        * 2: the validator/converter is case-insensitive and the
          converted value will always be lower-case.

    The *validator* tests whether the value is in the list of allowed values.
    The *converter* converts input values according to the given
    *map*-dictionary (unmapped input values are returned unchanged).
    z%s (%s)|c                s   t | | | S )N)r   lower)r   r   r	   )allowed_valuesr
   r   <lambda>\   s    zEnumVariable.<locals>.<lambda>c                s   t | || S )N)r   )r   r   r	   )r   r
   r   r   _   s       c                s     |  |  S )N)getr   )r   )mapr
   r   r   c          c                s     |  | S )N)r   r   )r   )r   r
   r   r   e   r   c                s     | | S )N)r   )r   )r   r
   r   r   g   r   )join)r   helpdefaultr   r   Z
ignorecaseZ	validatorZ	converterr
   )r   r   r   r   ;   s    )
__doc__typingr   r   ZSCons.Errorsr   __all__r   strr   r
   r
   r
   r   <module>,   s
   