%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/landscape/lib/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/landscape/lib/__pycache__/schema.cpython-312.pyc

�

�~�el���dZddlmZddlmZddlmZGd�de�ZGd�d�ZGd	�d
�ZGd�d�Z	Gd
�d�Z
Gd�d�ZGd�d�ZGd�d�Z
Gd�d�ZGd�d�ZGd�d�ZGd�d�Zy)z"A schema system. Yes. Another one!�)�	iteritems)�long)�unicodec��eZdZdZy)�InvalidErrorz&Raised when invalid input is received.N)�__name__�
__module__�__qualname__�__doc__���6/usr/lib/python3/dist-packages/landscape/lib/schema.pyrrs��0�r
rc��eZdZdZd�Zd�Zy)�Constantz1Something that must be equal to a constant value.c��||_y�N)�value��selfrs  r�__init__zConstant.__init__s	����
r
c���t|jt�r!t|t�r	|j	�}||jk7rt
|�d|j����|S#t
$rY�6wxYw)Nz != )�
isinstancer�str�bytes�decode�UnicodeDecodeErrorrrs  r�coercezConstant.coercesj���d�j�j�#�&�:�e�U�+C�
�������D�J�J���%��$�t�z�z�n�=�>�>����&�
��
�s�A'�'	A3�2A3N�rr	r
rrrrr
rrr
s��;��	r
rc��eZdZdZd�Zd�Zy)�AnyzsSomething which must apply to any of a number of different schemas.

    @param schemas: Other schema objects.
    c��||_yr)�schemas)rr"s  rrzAny.__init__%s	����r
c��|jD]}	|j|�cSt|�d|j����#t$rY�=wxYw)z�
        The result of the first schema which doesn't raise
        L{InvalidError} from its C{coerce} method will be returned.
        z did not match any schema in )r"rr)rr�schemas   rrz
Any.coerce(sa��
�l�l�	�F�
��}�}�U�+�+�	�
��i�4�T�\�\�N�C�
�	
�� �
��
�s�?�	A�
ANrrr
rr r s���
�
r
r c��eZdZdZd�Zy)�Boolz!Something that must be a C{bool}.c�B�t|t�st|�d���|S)Nz is not a bool)r�boolrrs  rrzBool.coerce:s#���%��&��%��.�9�:�:��r
N�rr	r
rrrr
rr&r&7s
��+�r
r&c��eZdZdZd�Zy)�Intz,Something that must be an C{int} or C{long}.c�N�t|ttf�st|�d���|S)Nz isn't an int or long)r�intrrrs  rrz
Int.coerceCs(���%�#�t��-��%��*?�@�A�A��r
Nr)rr
rr+r+@s
��6�r
r+c��eZdZdZd�Zy)�Floatz7Something that must be an C{int}, C{long}, or C{float}.c�X�t|tttf�st	|�d���|S)Nz isn't a float)rr-r�floatrrs  rrzFloat.coerceLs*���%�#�t�U�!3�4��%��.�9�:�:��r
Nr)rr
rr/r/Is
��A�r
r/c��eZdZdZd�Zy)�BytesziA binary string.

    If the value is a Python3 str (unicode), it will be automatically
    encoded.
    c��t|t�r|St|t�r|j�St	|�d���)Nz isn't a bytestring)rrr�encoderrs  rrzBytes.coerceYs:���e�U�#��L��e�S�!��<�<�>�!��e�Y�&9�:�;�;r
Nr)rr
rr3r3Rs���<r
r3c��eZdZdZdd�Zd�Zy)�Unicodez�Something that must be a C{unicode}.

    If the value is a C{str}, it will automatically be decoded.

    @param encoding: The encoding to automatically decode C{str}s with.
    c��||_yr)�encoding)rr9s  rrzUnicode.__init__ks	�� ��
r
c	��t|t�r	|j|j�}t|t�st|�d���|S#t$r)}tdj
|t|����d}~wwxYw)Nz{!r} can't be decoded: {}z isn't a unicode)	rrrr9rr�formatrr)rr�es   rrzUnicode.coercensz���e�U�#�
����T�]�]�3��
�%��)��%��*:�;�<�<����
&�
�"�/�6�6�u�c�!�f�E����
�s�A
�
	A?�$A:�:A?N)zutf-8rrr
rr7r7cs���!�
r
r7c��eZdZdZd�Zd�Zy)�ListznSomething which must be a C{list}.

    @param schema: The schema that all values of the list must match.
    c��||_yr�r$�rr$s  rrz
List.__init__��	����r
c	��t|t�st|�d���t|�}t|�D]$\}}	|jj|�||<�&|S#t$r"}t|�d|j�d|����d}~wwxYw)Nz is not a list� could not coerce with �: )r�listr�	enumerater$r)rr�new_list�i�subvaluer<s      rrzList.coerce�s����%��&��%��.�9�:�:���;��$�U�+�	�K�A�x�
�"�k�k�0�0��:����	����	 �
�"��l�"9�$�+�+��b���L����
�s�A�	B	�'B�B	Nrrr
rr>r>{s���
�r
r>c��eZdZdZd�Zd�Zy)�Tuplez�Something which must be a fixed-length tuple.

    @param schema: A sequence of schemas, which will be applied to
        each value in the tuple respectively.
    c��||_yrr@rAs  rrzTuple.__init__�rBr
c�v�t|t�st|�d���t|�t|j�k7r0tdt|j��dt|��d|����g}t|j|�D]%\}}|j
|j|���'t|�S)Nz is not a tuplezNeed z items, got z in )r�tupler�lenr$�zip�appendr)rr�	new_valuer$s    rrzTuple.coerce�s����%��'��%��/�:�;�;��u�:��T�[�[�)�)����D�K�K�(�)�*��5�z�l�$�u�i�1��
��	� ����e�4�	3�M�F�E����V�]�]�5�1�2�	3��Y��r
Nrrr
rrLrL�s���� r
rLc��eZdZdZdd�Zd�Zy)�KeyDicta'Something which must be a C{dict} with defined keys.

    The keys must be constant and the values must match a per-key schema.
    If strict, extra keys cause an exception during coercion.

    @param schema: A dict mapping keys to schemas that the values of those
        keys must match.
    Nc�H�|�g}t|�|_||_||_yr)�set�optionalr$�_strict)rr$rX�stricts    rrzKeyDict.__init__�s&�����H��H�
��
������r
c�H�i}t|t�st|�d���t|�D]`\}}||jv}|r&|j
rt|�d|j����|r�?	|j|j
|�||<�bt|j��}t|jj��|jz
}||z
}	|	rtd|	����|S#t$r)}td|�d|�d|j|�d|����d}~wwxYw)N� is not a dict.z is not a valid key as per z	Value of z
 key of dict rDrEz
Missing keys )
r�dictrrr$rYrrW�keysrX)
rr�new_dict�k�v�unknown_keyr<�new_keys�
required_keys�missings
          rrzKeyDict.coerce�s;�����%��&��%��/�:�;�;��e�$�	�D�A�q��4�;�;�.�K��t�|�|�"��e�6�t�{�{�o�F�����
�"�k�k�!�n�3�3�A�6����	�$�x�}�}��'���D�K�K�,�,�.�/�$�-�-�?�
��(�*�����w�i�8�9�9���� �
�"���u�M�%��;� �K�K��N�+�2�a�S�2����
�s�,!C/�/	D!�8$D�D!)NTrrr
rrUrU�s����r
rUc��eZdZdZd�Zd�Zy)�Dictz�Something which must be a C{dict} with arbitrary keys.

    @param key_schema: The schema that keys must match.
    @param value_schema: The schema that values must match.
    c� �||_||_yr)�
key_schema�value_schema)rrirjs   rrz
Dict.__init__�s��$���(��r
c���t|t�st|�d���i}|j�D]<\}}|jj|�||jj|�<�>|S)Nr\)rr]r�itemsrjrri)rrr_r`ras     rrzDict.coerce�sm���%��&��%��/�:�;�;����K�K�M�	N�D�A�q�26�2C�2C�2J�2J�1�2M�H�T�_�_�+�+�A�.�/�	N��r
Nrrr
rrgrg�s���)�r
rgN)r�twisted.python.compatrrr�	Exceptionrrr r&r+r/r3r7r>rLrUrgrr
r�<module>ros���(�+�&�)�	�9�	���$
�
�0������<�<�"��0��. � �0-�-�`�r

Zerion Mini Shell 1.0