%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python3/dist-packages/configobj/__pycache__/
Upload File :
Create Path :
Current File : //usr/lib/python3/dist-packages/configobj/__pycache__/validate.cpython-312.pyc

�

�:�e)�����dZdZdZddlZddlZddlmZejdejejz�Z	ejdejejz�Z
dZd	ezZd
�Z
d�ZGd�d
e�ZGd�de�ZGd�de�ZGd�de�ZGd�de�ZGd�de�ZGd�de�ZGd�de�ZGd�de�ZGd�de�ZGd �d!e�Zd=d#�Zd>d$�Zd>d%�Zd&d&d&d&d&d"d"d"d"d"d'�
Z d(�Z!d)�Z"d>d*�Z#d>d+�Z$d>d,�Z%d>d-�Z&d>d.�Z'd>d/�Z(d>d0�Z)d>d1�Z*d>d2�Z+eee"e%e!d3�Z,d4�Z-d5�Z.d6�Z/d7�Z0d8�Z1e2d9k(r�ddlZddl3Z3ejhjkd9�Z6e6jnjq�Z9e9jud:e�i�e3jve6e9e3jxe3jzz�;�\Z>Z?e>rJd<j�e>e?���yy)?a
    The Validator object is used to check that supplied values 
    conform to a specification.
    
    The value can be supplied as a string - e.g. from a config file.
    In this case the check will also *convert* the value to
    the required type. This allows you to add validation
    as a transparent layer to access data stored as strings.
    The validation checks that the data is correct *and*
    converts it to the expected type.
    
    Some standard checks are provided for basic data types.
    Additional checks are easy to write. They can be
    provided when the ``Validator`` is instantiated or
    added afterwards.
    
    The standard functions work with the following basic data types :
    
    * integers
    * floats
    * booleans
    * strings
    * ip_addr
    
    plus lists of these datatypes
    
    Adding additional checks is done through coding simple functions.
    
    The full set of standard checks are : 
    
    * 'integer': matches integer values (including negative)
                 Takes optional 'min' and 'max' arguments : ::
    
                   integer()
                   integer(3, 9)  # any value from 3 to 9
                   integer(min=0) # any positive value
                   integer(max=9)
    
    * 'float': matches float values
               Has the same parameters as the integer check.
    
    * 'boolean': matches boolean values - ``True`` or ``False``
                 Acceptable string values for True are :
                   true, on, yes, 1
                 Acceptable string values for False are :
                   false, off, no, 0
    
                 Any other value raises an error.
    
    * 'ip_addr': matches an Internet Protocol address, v.4, represented
                 by a dotted-quad string, i.e. '1.2.3.4'.
    
    * 'string': matches any string.
                Takes optional keyword args 'min' and 'max'
                to specify min and max lengths of the string.
    
    * 'list': matches any list.
              Takes optional keyword args 'min', and 'max' to specify min and
              max sizes of the list. (Always returns a list.)
    
    * 'tuple': matches any tuple.
              Takes optional keyword args 'min', and 'max' to specify min and
              max sizes of the tuple. (Always returns a tuple.)
    
    * 'int_list': Matches a list of integers.
                  Takes the same arguments as list.
    
    * 'float_list': Matches a list of floats.
                    Takes the same arguments as list.
    
    * 'bool_list': Matches a list of boolean values.
                   Takes the same arguments as list.
    
    * 'ip_addr_list': Matches a list of IP addresses.
                     Takes the same arguments as list.
    
    * 'string_list': Matches a list of strings.
                     Takes the same arguments as list.
    
    * 'mixed_list': Matches a list with different types in 
                    specific positions. List size must match
                    the number of arguments.
    
                    Each position can be one of :
                    'integer', 'float', 'ip_addr', 'string', 'boolean'
    
                    So to specify a list with two strings followed
                    by two integers, you write the check as : ::
    
                      mixed_list('string', 'string', 'integer', 'integer')
    
    * 'pass': This check matches everything ! It never fails
              and the value is unchanged.
    
              It is also the default if no check is specified.
    
    * 'option': This check matches any from a list of options.
                You specify this check with : ::
    
                  option('option 1', 'option 2', 'option 3')
    
    You can supply a default value (returned if no value is supplied)
    using the default keyword argument.
    
    You specify a list argument for default using a list constructor syntax in
    the check : ::
    
        checkname(arg1, arg2, default=list('val 1', 'val 2', 'val 3'))
    
    A badly formatted set of arguments will raise a ``VdtParamError``.
z1.0.1)�__version__�dottedQuadToNum�numToDottedQuad�
ValidateError�VdtUnknownCheckError�
VdtParamError�VdtTypeError�
VdtValueError�VdtValueTooSmallError�VdtValueTooBigError�VdtValueTooShortError�VdtValueTooLongError�VdtMissingValue�	Validator�
is_integer�is_float�
is_boolean�is_list�is_tuple�
is_ip_addr�	is_string�is_int_list�is_bool_list�
is_float_list�is_string_list�is_ip_addr_list�
is_mixed_list�	is_option�N)�pprinta�
    (?:
        ([a-zA-Z_][a-zA-Z0-9_]*)\s*=\s*list\(
            (
                (?:
                    \s*
                    (?:
                        (?:".*?")|              # double quotes
                        (?:'.*?')|              # single quotes
                        (?:[^'",\s\)][^,\)]*?)  # unquoted
                    )
                    \s*,\s*
                )*
                (?:
                    (?:".*?")|              # double quotes
                    (?:'.*?')|              # single quotes
                    (?:[^'",\s\)][^,\)]*?)  # unquoted
                )?                          # last one
            )
        \)
    )
z�
    (
        (?:".*?")|              # double quotes
        (?:'.*?')|              # single quotes
        (?:[^'",\s=][^,=]*?)       # unquoted
    )
    (?:
    (?:\s*,\s*)|(?:\s*$)            # comma
    )
a�
    (?:
        (
            (?:
                [a-zA-Z_][a-zA-Z0-9_]*\s*=\s*list\(
                    (?:
                        \s*
                        (?:
                            (?:".*?")|              # double quotes
                            (?:'.*?')|              # single quotes
                            (?:[^'",\s\)][^,\)]*?)       # unquoted
                        )
                        \s*,\s*
                    )*
                    (?:
                        (?:".*?")|              # double quotes
                        (?:'.*?')|              # single quotes
                        (?:[^'",\s\)][^,\)]*?)       # unquoted
                    )?                              # last one
                \)
            )|
            (?:
                (?:".*?")|              # double quotes
                (?:'.*?')|              # single quotes
                (?:[^'",\s=][^,=]*?)|       # unquoted
                (?:                         # keyword argument
                    [a-zA-Z_][a-zA-Z0-9_]*\s*=\s*
                    (?:
                        (?:".*?")|              # double quotes
                        (?:'.*?')|              # single quotes
                        (?:[^'",\s=][^,=]*?)       # unquoted
                    )
                )
            )
        )
        (?:
            (?:\s*,\s*)|(?:\s*$)            # comma
        )
    )
    z^%s*c��ddl}ddl}	|jd|j|j	���dS#|j
$rt
d|z��wxYw)a�
    Convert decimal dotted quad string to long integer
    
    >>> int(dottedQuadToNum('1 '))
    1
    >>> int(dottedQuadToNum(' 1.2'))
    16777218
    >>> int(dottedQuadToNum(' 1.2.3 '))
    16908291
    >>> int(dottedQuadToNum('1.2.3.4'))
    16909060
    >>> dottedQuadToNum('255.255.255.255')
    4294967295
    >>> dottedQuadToNum('255.255.255.256')
    Traceback (most recent call last):
    ValueError: Not a good dotted-quad IP: 255.255.255.256
    rN�!LzNot a good dotted-quad IP: %s)�socket�struct�unpack�	inet_aton�strip�error�
ValueError)�ipr"r#s   �4/usr/lib/python3/dist-packages/configobj/validate.pyrr�s_��(�?��}�}�T����R�X�X�Z�(�*�*+�-�	-���<�<�?��8�2�=�>�>�?�s	�1<�Ac��ddl}ddl}|td�kDs|dkrtd|z��	|j	|jdt|���S#|j|jtf$rtd|z��wxYw)a
    Convert int or long int to dotted quad string
    
    >>> numToDottedQuad(int(-1))
    Traceback (most recent call last):
    ValueError: Not a good numeric IP: -1
    >>> numToDottedQuad(int(1))
    '0.0.0.1'
    >>> numToDottedQuad(int(16777218))
    '1.0.0.2'
    >>> numToDottedQuad(int(16908291))
    '1.2.0.3'
    >>> numToDottedQuad(int(16909060))
    '1.2.3.4'
    >>> numToDottedQuad(int(4294967295))
    '255.255.255.255'
    >>> numToDottedQuad(int(4294967296))
    Traceback (most recent call last):
    ValueError: Not a good numeric IP: 4294967296
    >>> numToDottedQuad(-1)
    Traceback (most recent call last):
    ValueError: Not a good numeric IP: -1
    >>> numToDottedQuad(1)
    '0.0.0.1'
    >>> numToDottedQuad(16777218)
    '1.0.0.2'
    >>> numToDottedQuad(16908291)
    '1.2.0.3'
    >>> numToDottedQuad(16909060)
    '1.2.3.4'
    >>> numToDottedQuad(4294967295)
    '255.255.255.255'
    >>> numToDottedQuad(4294967296)
    Traceback (most recent call last):
    ValueError: Not a good numeric IP: 4294967296

    rNl��zNot a good numeric IP: %sr!)r"r#�intr(�	inet_ntoa�packr'�
OverflowError)�numr"r#s   r*rrs���P��S��_���a���4�s�:�;�;�<�����K�K��c�#�h�'�)�	)���L�L�&�,�,�
�6�<��4�s�:�;�;�<�s�)A�/Bc��eZdZdZy)ra
    This error indicates that the check failed.
    It can be the base class for more specific errors.
    
    Any check function that fails ought to raise this error.
    (or a subclass)
    
    >>> raise ValidateError
    Traceback (most recent call last):
    ValidateError
    N��__name__�
__module__�__qualname__�__doc__��r*rrIs��
r8rc��eZdZdZy)rz1No value was supplied to a check that needed one.Nr2r7r8r*rrWs��;r8rc��eZdZdZd�Zy)rz'An unknown check function was requestedc�8�tj|d|�d��y)z�
        >>> raise VdtUnknownCheckError('yoda')
        Traceback (most recent call last):
        VdtUnknownCheckError: the check "yoda" is unknown.
        zthe check "z
" is unknown.N�r�__init__��self�values  r*r=zVdtUnknownCheckError.__init__^���	���t�U�%L�Mr8N�r3r4r5r6r=r7r8r*rr[s��1�Nr8rc��eZdZdZd�Zy)rz!An incorrect parameter was passedc�>�tj|d|�d|�d��y)z�
        >>> raise VdtParamError('yoda', 'jedi')
        Traceback (most recent call last):
        VdtParamError: passed an incorrect value "jedi" for parameter "yoda".
        zpassed an incorrect value "z" for parameter "z".N)�SyntaxErrorr=)r?�namer@s   r*r=zVdtParamError.__init__js��	���T�[`�bf�#g�hr8NrBr7r8r*rrgs��+�ir8rc��eZdZdZd�Zy)rz(The value supplied was of the wrong typec�8�tj|d|�d��y)z�
        >>> raise VdtTypeError('jedi')
        Traceback (most recent call last):
        VdtTypeError: the value "jedi" is of the wrong type.
        �the value "z" is of the wrong type.Nr<r>s  r*r=zVdtTypeError.__init__vs��	���t�u�%V�Wr8NrBr7r8r*rrss��2�Xr8rc��eZdZdZd�Zy)r	zIThe value supplied was of the correct type, but was not an allowed value.c�8�tj|d|�d��y)z�
        >>> raise VdtValueError('jedi')
        Traceback (most recent call last):
        VdtValueError: the value "jedi" is unacceptable.
        rIz" is unacceptable.Nr<r>s  r*r=zVdtValueError.__init__�s��	���t�%�%Q�Rr8NrBr7r8r*r	r	s��S�Sr8r	c��eZdZdZd�Zy)r
z>The value supplied was of the correct type, but was too small.c�8�tj|d|�d��y)z�
        >>> raise VdtValueTooSmallError('0')
        Traceback (most recent call last):
        VdtValueTooSmallError: the value "0" is too small.
        rIz" is too small.Nr<r>s  r*r=zVdtValueTooSmallError.__init__�s��	���t�u�%N�Or8NrBr7r8r*r
r
�s��H�Pr8r
c��eZdZdZd�Zy)rz<The value supplied was of the correct type, but was too big.c�8�tj|d|�d��y)z�
        >>> raise VdtValueTooBigError('1')
        Traceback (most recent call last):
        VdtValueTooBigError: the value "1" is too big.
        rIz
" is too big.Nr<r>s  r*r=zVdtValueTooBigError.__init__�rAr8NrBr7r8r*rr�s��F�Nr8rc��eZdZdZd�Zy)rz>The value supplied was of the correct type, but was too short.c�8�tj|d|�d��y)z�
        >>> raise VdtValueTooShortError('jed')
        Traceback (most recent call last):
        VdtValueTooShortError: the value "jed" is too short.
        rIz" is too short.Nr<r>s  r*r=zVdtValueTooShortError.__init__�s��	����.3�5�	7r8NrBr7r8r*rr�s
��H�7r8rc��eZdZdZd�Zy)r
z=The value supplied was of the correct type, but was too long.c�8�tj|d|�d��y)z�
        >>> raise VdtValueTooLongError('jedie')
        Traceback (most recent call last):
        VdtValueTooLongError: the value "jedie" is too long.
        rIz" is too long.Nr<r>s  r*r=zVdtValueTooLongError.__init__�s��	���t�e�%M�Nr8NrBr7r8r*r
r
�s��G�Or8r
c�t�eZdZdZej
dej�Zej
dej�Ze	Z	e
Z
ej
eejejz�Z
ej
eejejz�Zdd�Zdd�Zd�Zd�Zd	�Zd
�Zd�Zd�Zd
�Zd�Zy)ra

    Validator is an object that allows you to register a set of 'checks'.
    These checks take input and test that it conforms to the check.
    
    This can also involve converting the value from a string into
    the correct datatype.
    
    The ``check`` method takes an input string which configures which
    check is to be used and applies that check to a supplied value.
    
    An example input string would be:
    'int_range(param1, param2)'
    
    You would then provide something like:
    
    >>> def int_range_check(value, min, max):
    ...     # turn min and max from strings to integers
    ...     min = int(min)
    ...     max = int(max)
    ...     # check that value is of the correct type.
    ...     # possible valid inputs are integers or strings
    ...     # that represent integers
    ...     if not isinstance(value, (int, str)):
    ...         raise VdtTypeError(value)
    ...     elif isinstance(value, str):
    ...         # if we are given a string
    ...         # attempt to convert to an integer
    ...         try:
    ...             value = int(value)
    ...         except ValueError:
    ...             raise VdtValueError(value)
    ...     # check the value is between our constraints
    ...     if not min <= value:
    ...          raise VdtValueTooSmallError(value)
    ...     if not value <= max:
    ...          raise VdtValueTooBigError(value)
    ...     return value
    
    >>> fdict = {'int_range': int_range_check}
    >>> vtr1 = Validator(fdict)
    >>> vtr1.check('int_range(20, 40)', '30')
    30
    >>> vtr1.check('int_range(20, 40)', '60')
    Traceback (most recent call last):
    VdtValueTooBigError: the value "60" is too big.
    
    New functions can be added with : ::
    
    >>> vtr2 = Validator()       
    >>> vtr2.functions['int_range'] = int_range_check
    
    Or by passing in a dictionary of functions when Validator 
    is instantiated.
    
    Your functions *can* use keyword arguments,
    but the first argument should always be 'value'.
    
    If the function doesn't take additional arguments,
    the parentheses are optional in the check.
    It can be written with either of : ::
    
        keyword = function_name
        keyword = function_name()
    
    The first program to utilise Validator() was Michael Foord's
    ConfigObj, an alternative to ConfigParser which supports lists and
    can validate a config file using a config schema.
    For more details on using Validator with ConfigObj see:
    https://configobj.readthedocs.org/en/latest/configobj.html
    z([^\(\)]+?)\((.*)\)z%^([a-zA-Z_][a-zA-Z0-9_]*)\s*=\s*(.*)$Nc�v�id|j�dt�dt�dt�dt�dt
�dt�dt�d	t�d
t�dt�dt�d
t�dt�d|j�dt�dt�|_|�|j j#|�t$|_i|_y)z(
        >>> vtri = Validator()
        ��integer�float�boolean�ip_addr�string�list�tuple�int_list�
float_list�	bool_list�ip_addr_list�string_list�
mixed_list�pass�option�
force_listN)�_passrrrrrrrrrrrrrrrf�	functions�updater�baseErrorClass�_cache)r?rhs  r*r=zValidator.__init__s��
���
�
�
��z�
�
�X�
�
�z�	
�

�z�
�
�i�

�
�G�
�
�X�
�
��
�
�-�
�
��
�
�O�
�
�>�
�
�-�
�
�D�J�J�
� 
�i�!
�"
�*�#
���&� ��N�N�!�!�)�,�+�����r8c��|j|�\}}}}|r|�
t��|j|�}|�y|j||||�S)a�
        Usage: check(check, value)
        
        Arguments:
            check: string representing check to apply (including arguments)
            value: object to be checked
        Returns value, converted to correct type if necessary
        
        If the check fails, raises a ``ValidateError`` subclass.
        
        >>> vtor.check('yoda', '')
        Traceback (most recent call last):
        VdtUnknownCheckError: the check "yoda" is unknown.
        >>> vtor.check('yoda()', '')
        Traceback (most recent call last):
        VdtUnknownCheckError: the check "yoda" is unknown.
        
        >>> vtor.check('string(default="")', '', missing=True)
        ''
        N)�_parse_with_cachingr�_handle_none�_check_value)r?�checkr@�missing�fun_name�fun_args�
fun_kwargs�defaults        r*rpzValidator.check6s]��*37�2J�2J�5�2Q�/��(�J�����%�'�'��%�%�g�.�E��=��� � ���(�J�G�Gr8c�<�|dk(ry|dvr|j|�}|S)N�None�z'None'z"None")�_unquoter>s  r*rnzValidator._handle_noneYs(���F�?��
�*�
*��M�M�%�(�E��r8c	��||jvr+|j|\}}}}t|�}t|�}n{|j|�\}}}}tt|j	��D��cgc]\}}t|�|f��c}}�}|t|�t|�|f|j|<||||fScc}}w�N)rkr\�dict�_parse_check�items�str)r?rprrrsrtru�keyr@s        r*rmzValidator._parse_with_cachingbs����D�K�K��6:�k�k�%�6H�3�H�h�
�G��H�~�H��j�)�J�6:�6G�6G��6N�3�H�h�
�G��T�*�JZ�JZ�J\�E]�^�\�c�5��C��%�0�^�_�J�!)�4��>�4�
�;K�W�!T�D�K�K�����:�w�6�6��_s�1B;
c�j�	|j|}||g|��i|��S#t$rt|��wxYwr{)rh�KeyErrorr)r?r@rrrsrt�funs      r*rozValidator._check_valuepsH��	7��.�.��*�C��u�6�x�6�:�6�6���	1�&�x�0�0�	1�s��2c���|jj|�}|�r1|jd�}|jd�}|jj|�}|�t	d|z��g}i}|j
j
|�D]�}|j�}|jj|�}	|	r|j|	�\}
}|||
<�J|jj|�}|r;|jd�}|dvr|j|�}|||jd�<��|j|j|����n|didfS|jdd�}
||||
fS)N��zBad syntax in check "%s".rxr7ru)�_func_re�match�group�_matchfinderr�_paramfinder�findallr&�	_list_arg�_list_handle�_key_argry�append�pop)r?rp�	fun_matchrr�
arg_string�	arg_matchrsrt�arg�	listmatchr��val�keymatchrus              r*r}zValidator._parse_checkysg���M�M�'�'��.�	�� ���q�)�H�"����+�J��)�)�/�/�
�;�I�� �#�$?�%�$G�H�H��H��J��(�(�0�0��<�
4���i�i�k�� �N�N�0�0��5�	��#�0�0��;�H�C��&)�J�s�O���=�=�.�.�s�3���"�.�.��+�C��"6�6�"�m�m�C�0��47�J�x�~�~�a�0�1������
�
�c� 2�3�#
4�(�"�b�$�&�&��.�.��D�1����:�w�6�6r8c�P�t|�dk\r|ddvr|d|dk(r|dd}|S)zUnquote a value if necessary.r�r)�'�"���r�)�len)r?r�s  r*ryzValidator._unquote�s7����H��M��A��*� 4�3�q�6�S��W�;L��a��)�C��
r8c���g}|jd�}|jd�}|jj|�D]"}|j|j	|���$||fS)z7Take apart a ``keyword=list('val, 'val')`` type string.r�r�)r��
_list_membersr�r�ry)r?r��outrF�argsr�s      r*r�zValidator._list_handle�sb�������q�!�����q�!���%�%�-�-�d�3�	+�C��J�J�t�}�}�S�)�*�	+��S�y�r8c��|S)z�
        Dummy check that always passes
        
        >>> vtor.check('', 0)
        0
        >>> vtor.check('', '0')
        '0'
        r7r>s  r*rgzValidator._pass�s	���r8c��|j|�\}}}}|�td|z��|j|�}|�|S|j||||�S)z�
        Given a check, return the default value for the check
        (converted to the right type).
        
        If the check doesn't specify a default value then a
        ``KeyError`` will be raised.
        z Check "%s" has no default value.)rmr�rnro)r?rprrrsrtrur@s       r*�get_default_valuezValidator.get_default_value�sd��37�2J�2J�5�2Q�/��(�J���?��=��E�F�F��!�!�'�*���=��L�� � ���(�J�G�Gr8r{�F)r3r4r5r6�re�compile�DOTALLr�r�r�r��_paramstring�VERBOSEr��_matchstringr�r=rprnrmror}ryr�rgr�r7r8r*rr�s���E�P�r�z�z�0�"�)�)�<�H��r�z�z�B�R�Y�Y�O�H��I�"�M��2�:�:�l�B�J�J����,B�C�L��2�:�:�l�B�J�J����,B�C�L��< H�F�7�7�%7�P��	�Hr8rFc�6�|xrtxst}g}t||�D]X\}}|�|j|��t	|ttt
f�r	|j||���Nt||��|S#t$r}t||��d}~wwxYw)a�
    Return numbers from inputs or raise VdtParamError.
    
    Lets ``None`` pass through.
    Pass in keyword argument ``to_float=True`` to
    use float for the conversion rather than int.
    
    >>> _is_num_param(('', ''), (0, 1.0))
    [0, 1]
    >>> _is_num_param(('', ''), (0, 1.0), to_float=True)
    [0.0, 1.0]
    >>> _is_num_param(('a'), ('a'))
    Traceback (most recent call last):
    VdtParamError: passed an incorrect value "a" for parameter "a".
    N)rXr,�zipr��
isinstancerr(r)�names�values�to_floatr��
out_paramsrFr��es        r*�
_is_num_paramr��s��� �
�u�
#��C��J��5�&�)�	+���s��;����c�"�
��c�5�#�.�
/�
/��!�!�#�c�(�+� ��c�*�*�	+����	�
/�#�D�#�.�.��
/�s�A>�>	B�B�Bc��td||f�\}}t|ttf�st	|��t|t�r	t|�}|�||krt
|��|�||kDrt|��|S#t
$rt	|��wxYw)a?
    A check that tests that a given value is an integer (int)
    and optionally, between bounds. A negative value is accepted, while
    a float will fail.
    
    If the value is a string, then the conversion is done - if possible.
    Otherwise a VdtError is raised.
    
    >>> vtor.check('integer', '-1')
    -1
    >>> vtor.check('integer', '0')
    0
    >>> vtor.check('integer', 9)
    9
    >>> vtor.check('integer', 'a')
    Traceback (most recent call last):
    VdtTypeError: the value "a" is of the wrong type.
    >>> vtor.check('integer', '2.2')
    Traceback (most recent call last):
    VdtTypeError: the value "2.2" is of the wrong type.
    >>> vtor.check('integer(10)', '20')
    20
    >>> vtor.check('integer(max=20)', '15')
    15
    >>> vtor.check('integer(10)', '9')
    Traceback (most recent call last):
    VdtValueTooSmallError: the value "9" is too small.
    >>> vtor.check('integer(10)', 9)
    Traceback (most recent call last):
    VdtValueTooSmallError: the value "9" is too small.
    >>> vtor.check('integer(max=20)', '35')
    Traceback (most recent call last):
    VdtValueTooBigError: the value "35" is too big.
    >>> vtor.check('integer(max=20)', 35)
    Traceback (most recent call last):
    VdtValueTooBigError: the value "35" is too big.
    >>> vtor.check('integer(0, 9)', False)
    0
    ��min�max)r�r�r,rrr(r
r�r@r�r��min_val�max_vals     r*rr�s���P'�~��S�z�B��W�g��e�c�3�Z�(��5�!�!��%���	&���J�E�	��%�'�/�#�E�*�*���%�'�/�!�%�(�(��L��
�	&��u�%�%�	&�s�A5�5B
c�(�td||fd��\}}t|tttf�st|��t|t�s	t|�}|�||krt|��|�||kDrt|��|S#t$rt|��wxYw)a<
    A check that tests that a given value is a float
    (an integer will be accepted), and optionally - that it is between bounds.
    
    If the value is a string, then the conversion is done - if possible.
    Otherwise a VdtError is raised.
    
    This can accept negative values.
    
    >>> vtor.check('float', '2')
    2.0
    
    From now on we multiply the value to avoid comparing decimals
    
    >>> vtor.check('float', '-6.8') * 10
    -68.0
    >>> vtor.check('float', '12.2') * 10
    122.0
    >>> vtor.check('float', 8.4) * 10
    84.0
    >>> vtor.check('float', 'a')
    Traceback (most recent call last):
    VdtTypeError: the value "a" is of the wrong type.
    >>> vtor.check('float(10.1)', '10.2') * 10
    102.0
    >>> vtor.check('float(max=20.2)', '15.1') * 10
    151.0
    >>> vtor.check('float(10.0)', '9.0')
    Traceback (most recent call last):
    VdtValueTooSmallError: the value "9.0" is too small.
    >>> vtor.check('float(max=20.0)', '35.0')
    Traceback (most recent call last):
    VdtValueTooBigError: the value "35.0" is too big.
    r�T)r�)	r�r�r,rXrrr(r
rr�s     r*rr,s���F'���c�
�T�3��W�g��e�c�5�#�.�/��5�!�!��e�U�#�	&��%�L�E�	��%�'�/�#�E�*�*���%�'�/�!�%�(�(��L��
�	&��u�%�%�	&�s�A<�<BT)
T�on�1�true�yesF�off�0�false�noc��t|t�r	t|j�S|dk(ry|dk(ryt|��#t$rt|��wxYw)a�
    Check if the value represents a boolean.
    
    >>> vtor.check('boolean', 0)
    0
    >>> vtor.check('boolean', False)
    0
    >>> vtor.check('boolean', '0')
    0
    >>> vtor.check('boolean', 'off')
    0
    >>> vtor.check('boolean', 'false')
    0
    >>> vtor.check('boolean', 'no')
    0
    >>> vtor.check('boolean', 'nO')
    0
    >>> vtor.check('boolean', 'NO')
    0
    >>> vtor.check('boolean', 1)
    1
    >>> vtor.check('boolean', True)
    1
    >>> vtor.check('boolean', '1')
    1
    >>> vtor.check('boolean', 'on')
    1
    >>> vtor.check('boolean', 'true')
    1
    >>> vtor.check('boolean', 'yes')
    1
    >>> vtor.check('boolean', 'Yes')
    1
    >>> vtor.check('boolean', 'YES')
    1
    >>> vtor.check('boolean', '')
    Traceback (most recent call last):
    VdtTypeError: the value "" is of the wrong type.
    >>> vtor.check('boolean', 'up')
    Traceback (most recent call last):
    VdtTypeError: the value "up" is of the wrong type.
    
    FT)r�r�	bool_dict�lowerr�r�r@s r*rrfsb��X�%���	&��U�[�[�]�+�+�
��~��	�$����5�!�!���	&��u�%�%�	&�s�A�Ac��t|t�st|��|j�}	t	|�|S#t
$rt
|��wxYw)as
    Check that the supplied value is an Internet Protocol address, v.4,
    represented by a dotted-quad string, i.e. '1.2.3.4'.
    
    >>> vtor.check('ip_addr', '1 ')
    '1'
    >>> vtor.check('ip_addr', ' 1.2')
    '1.2'
    >>> vtor.check('ip_addr', ' 1.2.3 ')
    '1.2.3'
    >>> vtor.check('ip_addr', '1.2.3.4')
    '1.2.3.4'
    >>> vtor.check('ip_addr', '0.0.0.0')
    '0.0.0.0'
    >>> vtor.check('ip_addr', '255.255.255.255')
    '255.255.255.255'
    >>> vtor.check('ip_addr', '255.255.255.256')
    Traceback (most recent call last):
    VdtValueError: the value "255.255.255.256" is unacceptable.
    >>> vtor.check('ip_addr', '1.2.3.4.5')
    Traceback (most recent call last):
    VdtValueError: the value "1.2.3.4.5" is unacceptable.
    >>> vtor.check('ip_addr', 0)
    Traceback (most recent call last):
    VdtTypeError: the value "0" is of the wrong type.
    )r�rrr&rr(r	r�s r*rr�sT��6�e�S�!��5�!�!��K�K�M�E�#�����L���#��E�"�"�#�s	�:�Ac��td||f�\}}t|t�rt|��	t	|�}|�||krt
|��|�||kDrt|��t|�S#t
$rt|��wxYw)a�
    Check that the value is a list of values.
    
    You can optionally specify the minimum and maximum number of members.
    
    It does no check on list members.
    
    >>> vtor.check('list', ())
    []
    >>> vtor.check('list', [])
    []
    >>> vtor.check('list', (1, 2))
    [1, 2]
    >>> vtor.check('list', [1, 2])
    [1, 2]
    >>> vtor.check('list(3)', (1, 2))
    Traceback (most recent call last):
    VdtValueTooShortError: the value "(1, 2)" is too short.
    >>> vtor.check('list(max=5)', (1, 2, 3, 4, 5, 6))
    Traceback (most recent call last):
    VdtValueTooLongError: the value "(1, 2, 3, 4, 5, 6)" is too long.
    >>> vtor.check('list(min=3, max=5)', (1, 2, 3, 4))
    [1, 2, 3, 4]
    >>> vtor.check('list', 0)
    Traceback (most recent call last):
    VdtTypeError: the value "0" is of the wrong type.
    >>> vtor.check('list', '12')
    Traceback (most recent call last):
    VdtTypeError: the value "12" is of the wrong type.
    r�)	r�r�rrr��	TypeErrorrr
r\�r@r�r��min_len�max_len�num_memberss      r*rr�s���>'�~��S�z�B��W�g��%����5�!�!�"��%�j����{�W�4�#�E�*�*���{�W�4�"�5�)�)���;���
�"��5�!�!�"�s�A(�(A=c�.�tt|||��S)a�
    Check that the value is a tuple of values.
    
    You can optionally specify the minimum and maximum number of members.
    
    It does no check on members.
    
    >>> vtor.check('tuple', ())
    ()
    >>> vtor.check('tuple', [])
    ()
    >>> vtor.check('tuple', (1, 2))
    (1, 2)
    >>> vtor.check('tuple', [1, 2])
    (1, 2)
    >>> vtor.check('tuple(3)', (1, 2))
    Traceback (most recent call last):
    VdtValueTooShortError: the value "(1, 2)" is too short.
    >>> vtor.check('tuple(max=5)', (1, 2, 3, 4, 5, 6))
    Traceback (most recent call last):
    VdtValueTooLongError: the value "(1, 2, 3, 4, 5, 6)" is too long.
    >>> vtor.check('tuple(min=3, max=5)', (1, 2, 3, 4))
    (1, 2, 3, 4)
    >>> vtor.check('tuple', 0)
    Traceback (most recent call last):
    VdtTypeError: the value "0" is of the wrong type.
    >>> vtor.check('tuple', '12')
    Traceback (most recent call last):
    VdtTypeError: the value "12" is of the wrong type.
    )r]r�r@r�r�s   r*rr�s��>����S�)�*�*r8c���t|t�st|��td||f�\}}	t	|�}|�||krt
|��|�||kDrt|��|S#t
$rt|��wxYw)a�
    Check that the supplied value is a string.
    
    You can optionally specify the minimum and maximum number of members.
    
    >>> vtor.check('string', '0')
    '0'
    >>> vtor.check('string', 0)
    Traceback (most recent call last):
    VdtTypeError: the value "0" is of the wrong type.
    >>> vtor.check('string(2)', '12')
    '12'
    >>> vtor.check('string(2)', '1')
    Traceback (most recent call last):
    VdtValueTooShortError: the value "1" is too short.
    >>> vtor.check('string(min=2, max=3)', '123')
    '123'
    >>> vtor.check('string(min=2, max=3)', '1234')
    Traceback (most recent call last):
    VdtValueTooLongError: the value "1234" is too long.
    r�)r�rrr�r�r�rr
r�s      r*rrs���,�e�S�!��5�!�!�&�~��S�z�B��W�g�"��%�j����{�W�4�#�E�*�*���{�W�4�"�5�)�)��L��
�"��5�!�!�"�s�A�A4c�T�t|||�D�cgc]
}t|���c}Scc}w)a
    Check that the value is a list of integers.
    
    You can optionally specify the minimum and maximum number of members.
    
    Each list member is checked that it is an integer.
    
    >>> vtor.check('int_list', ())
    []
    >>> vtor.check('int_list', [])
    []
    >>> vtor.check('int_list', (1, 2))
    [1, 2]
    >>> vtor.check('int_list', [1, 2])
    [1, 2]
    >>> vtor.check('int_list', [1, 'a'])
    Traceback (most recent call last):
    VdtTypeError: the value "a" is of the wrong type.
    )rr�r@r�r��mems    r*rr:s%��((/�u�c�3�'?�@��J�s�O�@�@��@��%c�T�t|||�D�cgc]
}t|���c}Scc}w)al
    Check that the value is a list of booleans.
    
    You can optionally specify the minimum and maximum number of members.
    
    Each list member is checked that it is a boolean.
    
    >>> vtor.check('bool_list', ())
    []
    >>> vtor.check('bool_list', [])
    []
    >>> check_res = vtor.check('bool_list', (True, False))
    >>> check_res == [True, False]
    1
    >>> check_res = vtor.check('bool_list', [True, False])
    >>> check_res == [True, False]
    1
    >>> vtor.check('bool_list', [True, 'a'])
    Traceback (most recent call last):
    VdtTypeError: the value "a" is of the wrong type.
    )rrr�s    r*rrQs%��,(/�u�c�3�'?�@��J�s�O�@�@��@r�c�T�t|||�D�cgc]
}t|���c}Scc}w)a
    Check that the value is a list of floats.
    
    You can optionally specify the minimum and maximum number of members.
    
    Each list member is checked that it is a float.
    
    >>> vtor.check('float_list', ())
    []
    >>> vtor.check('float_list', [])
    []
    >>> vtor.check('float_list', (1, 2.0))
    [1.0, 2.0]
    >>> vtor.check('float_list', [1, 2.0])
    [1.0, 2.0]
    >>> vtor.check('float_list', [1, 'a'])
    Traceback (most recent call last):
    VdtTypeError: the value "a" is of the wrong type.
    )rrr�s    r*rrjs%��(&-�U�C��%=�>�c�H�S�M�>�>��>r�c��t|t�rt|��t|||�D�cgc]
}t	|���c}Scc}w)an
    Check that the value is a list of strings.
    
    You can optionally specify the minimum and maximum number of members.
    
    Each list member is checked that it is a string.
    
    >>> vtor.check('string_list', ())
    []
    >>> vtor.check('string_list', [])
    []
    >>> vtor.check('string_list', ('a', 'b'))
    ['a', 'b']
    >>> vtor.check('string_list', ['a', 1])
    Traceback (most recent call last):
    VdtTypeError: the value "1" is of the wrong type.
    >>> vtor.check('string_list', 'hello')
    Traceback (most recent call last):
    VdtTypeError: the value "hello" is of the wrong type.
    )r�rrrrr�s    r*rr�s:��*�%����5�!�!�&-�e�S�#�&>�?�s�I�c�N�?�?��?s�Ac�T�t|||�D�cgc]
}t|���c}Scc}w)a
    Check that the value is a list of IP addresses.
    
    You can optionally specify the minimum and maximum number of members.
    
    Each list member is checked that it is an IP address.
    
    >>> vtor.check('ip_addr_list', ())
    []
    >>> vtor.check('ip_addr_list', [])
    []
    >>> vtor.check('ip_addr_list', ('1.2.3.4', '5.6.7.8'))
    ['1.2.3.4', '5.6.7.8']
    >>> vtor.check('ip_addr_list', ['a'])
    Traceback (most recent call last):
    VdtValueError: the value "a" is unacceptable.
    )rrr�s    r*rr�s%��$(/�u�c�3�'?�@��J�s�O�@�@��@r�c�N�t|ttf�s|g}t|||�S)a�
    Check that a value is a list, coercing strings into
    a list with one member. Useful where users forget the
    trailing comma that turns a single value into a list.
    
    You can optionally specify the minimum and maximum number of members.
    A minumum of greater than one will fail if the user only supplies a
    string.
    
    >>> vtor.check('force_list', ())
    []
    >>> vtor.check('force_list', [])
    []
    >>> vtor.check('force_list', 'hello')
    ['hello']
    )r�r\r]rr�s   r*rfrf�s(��"�e�d�E�]�+�����5�#�s�#�#r8)rWrXrZr[rYc�L�	t|�}|t|�krt|��|t|�kDrt	|��	t||�D��cgc]\}}t
||���c}}S#t$rt|��wxYwcc}}w#t$r}td|��d}~wwxYw)a�
    Check that the value is a list.
    Allow specifying the type of each member.
    Work on lists of specific lengths.
    
    You specify each member as a positional argument specifying type
    
    Each type should be one of the following strings :
      'integer', 'float', 'ip_addr', 'string', 'boolean'
    
    So you can specify a list of two strings, followed by
    two integers as :
    
      mixed_list('string', 'string', 'integer', 'integer')
    
    The length of the list must match the number of positional
    arguments you supply.
    
    >>> mix_str = "mixed_list('integer', 'float', 'ip_addr', 'string', 'boolean')"
    >>> check_res = vtor.check(mix_str, (1, 2.0, '1.2.3.4', 'a', True))
    >>> check_res == [1, 2.0, '1.2.3.4', 'a', True]
    1
    >>> check_res = vtor.check(mix_str, ('1', '2.0', '1.2.3.4', 'a', 'True'))
    >>> check_res == [1, 2.0, '1.2.3.4', 'a', True]
    1
    >>> vtor.check(mix_str, ('b', 2.0, '1.2.3.4', 'a', True))
    Traceback (most recent call last):
    VdtTypeError: the value "b" is of the wrong type.
    >>> vtor.check(mix_str, (1, 2.0, '1.2.3.4', 'a'))
    Traceback (most recent call last):
    VdtValueTooShortError: the value "(1, 2.0, '1.2.3.4', 'a')" is too short.
    >>> vtor.check(mix_str, (1, 2.0, '1.2.3.4', 'a', 1, 'b'))
    Traceback (most recent call last):
    VdtValueTooLongError: the value "(1, 2.0, '1.2.3.4', 'a', 1, 'b')" is too long.
    >>> vtor.check(mix_str, 0)
    Traceback (most recent call last):
    VdtTypeError: the value "0" is of the wrong type.

    >>> vtor.check('mixed_list("yoda")', ('a'))
    Traceback (most recent call last):
    VdtParamError: passed an incorrect value "KeyError('yoda',)" for parameter "'mixed_list'"
    rcN)	r�r�rrr
r��fun_dictr�r)r@r��lengthr�r�r�s      r*rr�s���V"��U�����D�	��#�E�*�*�	�#�d�)�	�"�5�)�)�-�36�t�U�3C�D�x�s�C���
�c�"�D�D���"��5�!�!�"��E���-��L�!�,�,��-�s5�A+�B	�B�'B	�+B�B	�		B#�B�B#c�Z�t|t�st|��||vrt|��|S)a�
    This check matches the value to any of a set of options.
    
    >>> vtor.check('option("yoda", "jedi")', 'yoda')
    'yoda'
    >>> vtor.check('option("yoda", "jedi")', 'jed')
    Traceback (most recent call last):
    VdtValueError: the value "jed" is unacceptable.
    >>> vtor.check('option("yoda", "jedi")', 0)
    Traceback (most recent call last):
    VdtTypeError: the value "0" is of the wrong type.
    )r�rrr	)r@�optionss  r*rr	s1���e�S�!��5�!�!��G���E�"�"��Lr8c��|||fS)a 

    A function that exists for test purposes.
    
    >>> checks = [
    ...     '3, 6, min=1, max=3, test=list(a, b, c)',
    ...     '3',
    ...     '3, 6',
    ...     '3,',
    ...     'min=1, test="a b c"',
    ...     'min=5, test="a, b, c"',
    ...     'min=1, max=3, test="a, b, c"',
    ...     'min=-100, test=-99',
    ...     'min=1, max=3',
    ...     '3, 6, test="36"',
    ...     '3, 6, test="a, b, c"',
    ...     '3, max=3, test=list("a", "b", "c")',
    ...     '''3, max=3, test=list("'a'", 'b', "x=(c)")''',
    ...     "test='x=fish(3)'",
    ...    ]
    >>> v = Validator({'test': _test})
    >>> for entry in checks:
    ...     pprint(v.check(('test(%s)' % entry), 3))
    (3, ('3', '6'), {'max': '3', 'min': '1', 'test': ['a', 'b', 'c']})
    (3, ('3',), {})
    (3, ('3', '6'), {})
    (3, ('3',), {})
    (3, (), {'min': '1', 'test': 'a b c'})
    (3, (), {'min': '5', 'test': 'a, b, c'})
    (3, (), {'max': '3', 'min': '1', 'test': 'a, b, c'})
    (3, (), {'min': '-100', 'test': '-99'})
    (3, (), {'max': '3', 'min': '1'})
    (3, ('3', '6'), {'test': '36'})
    (3, ('3', '6'), {'test': 'a, b, c'})
    (3, ('3',), {'max': '3', 'test': ['a', 'b', 'c']})
    (3, ('3',), {'max': '3', 'test': ["'a'", 'b', 'x=(c)']})
    (3, (), {'test': 'x=fish(3)'})
    
    >>> v = Validator()
    >>> v.check('integer(default=6)', '3')
    3
    >>> v.check('integer(default=6)', None, True)
    6
    >>> v.get_default_value('integer(default=6)')
    6
    >>> v.get_default_value('float(default=6)')
    6.0
    >>> v.get_default_value('pass(default=None)')
    >>> v.get_default_value("string(default='None')")
    'None'
    >>> v.get_default_value('pass')
    Traceback (most recent call last):
    KeyError: 'Check "pass" has no default value.'
    >>> v.get_default_value('pass(default=list(1, 2, 3, 4))')
    ['1', '2', '3', '4']
    
    >>> v = Validator()
    >>> v.check("pass(default=None)", None, True)
    >>> v.check("pass(default='None')", None, True)
    'None'
    >>> v.check('pass(default="None")', None, True)
    'None'
    >>> v.check('pass(default=list(1, 2, 3, 4))', None, True)
    ['1', '2', '3', '4']
    
    Bug test for unicode arguments
    >>> v = Validator()
    >>> v.check('string(min=4)', 'test') == 'test'
    True
    
    >>> v = Validator()
    >>> v.get_default_value('string(min=4, default="1234")') == '1234'
    True
    >>> v.check('string(min=4, default="1234")'), 'test') == 'test'
    True
    
    >>> v = Validator()
    >>> default = v.get_default_value('string(default=None)')
    >>> default == None
    1
    r7)r@r��keywargss   r*�_testr�s��b
�4��"�"r8c��y)z�
    >>> 
    >>> v = Validator()
    >>> v.get_default_value('string(default="#ff00dd")')
    '#ff00dd'
    >>> v.get_default_value('integer(default=3) # comment')
    3
    Nr7r7r8r*�_test2r�q��r8c��y)a�
    >>> vtor.check('string(default="")', '', missing=True)
    ''
    >>> vtor.check('string(default="\n")', '', missing=True)
    '\n'
    >>> print(vtor.check('string(default="\n")', '', missing=True))
    <BLANKLINE>
    <BLANKLINE>
    >>> vtor.check('string()', '\n')
    '\n'
    >>> vtor.check('string(default="\n\n\n")', '', missing=True)
    '\n\n\n'
    >>> vtor.check('string()', 'random \n text goes here\n\n')
    'random \n text goes here\n\n'
    >>> vtor.check('string(default=" \nrandom text\ngoes \n here\n\n ")',
    ... '', missing=True)
    ' \nrandom text\ngoes \n here\n\n '
    >>> vtor.check("string(default='\n\n\n')", '', missing=True)
    '\n\n\n'
    >>> vtor.check("option('\n','a','b',default='\n')", '', missing=True)
    '\n'
    >>> vtor.check("string_list()", ['foo', '\n', 'bar'])
    ['foo', '\n', 'bar']
    >>> vtor.check("string_list(default=list('\n'))", '', missing=True)
    ['\n']
    Nr7r7r8r*�_test3r�{r�r8�__main__�vtor)�globs�optionflagsz{} failures out of {} testsr�)NN)Ar6r�__all__r��sysrr�r�r�r�r�r�r�rr�	ExceptionrrrrErrr	r
rrr
�objectrr�rrr�rrrrrrrrrrrfr�rrr�r�r�r3�doctest�modules�get�m�__dict__�copyr�ri�testmod�IGNORE_EXCEPTION_DETAIL�ELLIPSIS�failures�tests�formatr7r8r*�<module>r�sq��"n�`����@
�
��
�B�J�J��*�Z�Z�"�)�)��+
�	�.��
�
�	��Z�Z�"�)�)��	�
�'��R��$���<1<�h�I��<�m�<�	N�=�	N�	i�K�	i�	X�=�	X�	S�M�	S�	P�M�	P�	N�-�	N�7�M�7�	O�=�	O�OH��OH�d�J5�p1�j�d��t�D���U�U�%�
�	�9"�x"�J*�Z+�D!�HA�.A�2?�.@�4A�*$�0�
������6-�r�(Q#�h��:�z���������
�#�A�
�J�J�O�O��E�	�L�L��	����&�g�o�o�	���3�3�g�6F�6F�F�H�O�H�e��N�6�=�=�h��N�N�<�x�r8

Zerion Mini Shell 1.0