HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/lib/python3/dist-packages/landscape/lib/__pycache__/schema.cpython-38.pyc
U

���c9�@s�dZddlmZmZmZGdd�de�ZGdd�de�ZGdd�de�Z	Gd	d
�d
e�Z
Gdd�de�ZGd
d�de�ZGdd�de�Z
Gdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZdS)z"A schema system. Yes. Another one!�)�	iteritems�unicode�longc@seZdZdZdS)�InvalidErrorz&Raised when invalid input is received.N)�__name__�
__module__�__qualname__�__doc__�r
r
�6/usr/lib/python3/dist-packages/landscape/lib/schema.pyrsrc@s eZdZdZdd�Zdd�ZdS)�Constantz1Something that must be equal to a constant value.cCs
||_dS�N)�value��selfrr
r
r�__init__szConstant.__init__cCsXt|jt�r8t|t�r8z|��}Wntk
r6YnX||jkrTtd||jf��|S)Nz%r != %r)�
isinstancer�str�bytes�decode�UnicodeDecodeErrorrrr
r
r�coerces
zConstant.coerceN�rrrr	rrr
r
r
rr
src@s eZdZdZdd�Zdd�ZdS)�AnyzsSomething which must apply to any of a number of different schemas.

    @param schemas: Other schema objects.
    cGs
||_dSr
)�schemas)rrr
r
rr szAny.__init__c	CsH|jD]*}z|�|�WStk
r.YqXqtd||jf��dS)z�
        The result of the first schema which doesn't raise
        L{InvalidError} from its C{coerce} method will be returned.
        z!%r did not match any schema in %sN)rrr)rr�schemar
r
rr#s
�z
Any.coerceNrr
r
r
rrsrc@seZdZdZdd�ZdS)�Boolz!Something that must be a C{bool}.cCst|t�std|f��|S)Nz%r is not a bool)r�boolrrr
r
rr3s
zBool.coerceN�rrrr	rr
r
r
rr1src@seZdZdZdd�ZdS)�Intz,Something that must be an C{int} or C{long}.cCs t|ttf�std|f��|S)Nz%r isn't an int or long)r�intrrrr
r
rr;sz
Int.coerceNrr
r
r
rr9src@seZdZdZdd�ZdS)�Floatz7Something that must be an C{int}, C{long}, or C{float}.cCs"t|tttf�std|f��|S)Nz%r isn't a float)rr r�floatrrr
r
rrCszFloat.coerceNrr
r
r
rr!Asr!c@seZdZdZdd�ZdS)�BytesziA binary string.

    If the value is a Python3 str (unicode), it will be automatically
    encoded.
    cCs0t|t�r|St|t�r |��Std|��dS)Nz%r isn't a bytestring)rrr�encoderrr
r
rrOs


zBytes.coerceNrr
r
r
rr#Isr#c@s"eZdZdZddd�Zdd�ZdS)	�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.
    �utf-8cCs
||_dSr
)�encoding)rr'r
r
rraszUnicode.__init__c
Csnt|t�rRz|�|j�}Wn6tk
rP}ztd|t|�f��W5d}~XYnXt|t�sjtd|f��|S)Nz%r can't be decoded: %sz%r isn't a unicode)rrrr'rrrr)rr�er
r
rrds
&
zUnicode.coerceN)r&rr
r
r
rr%Ys
r%c@s eZdZdZdd�Zdd�ZdS)�ListznSomething which must be a C{list}.

    @param schema: The schema that all values of the list must match.
    cCs
||_dSr
�r�rrr
r
rrtsz
List.__init__cCs�t|t�std|f��t|�}t|�D]T\}}z|j�|�||<Wq(tk
rz}ztd||j|f��W5d}~XYq(Xq(|S)Nz%r is not a listz%r could not coerce with %s: %s)r�listr�	enumeraterr)rrZnew_list�iZsubvaluer(r
r
rrws

��zList.coerceNrr
r
r
rr)osr)c@s eZdZdZdd�Zdd�ZdS)�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.
    cGs
||_dSr
r*r+r
r
rr�szTuple.__init__cCsxt|t�std|f��t|�t|j�krFtdt|j�t|�|f��g}t|j|�D]\}}|�|�|��qVt|�S)Nz%r is not a tuplezNeed %s items, got %s in %r)r�tupler�lenr�zip�appendr)rrZ	new_valuerr
r
rr�s
�zTuple.coerceNrr
r
r
rr/�sr/c@s"eZdZdZddd�Zdd�ZdS)�KeyDictz�Something which must be a C{dict} with defined keys.

    The keys must be constant and the values must match a per-key schema.

    @param schema: A dict mapping keys to schemas that the values of those
        keys must match.
    NcCs |dkrg}t|�|_||_dSr
)�set�optionalr)rrr6r
r
rr�s
zKeyDict.__init__c	Cs�i}t|t�std|f��t|�D]z\}}||jkrHtd||jf��z|j|�|�||<Wq$tk
r�}ztd|||j||f��W5d}~XYq$Xq$t|���}t|j���|j}||}|r�td|f��|S)N�%r is not a dict.z%r is not a valid key as per %rz7Value of %r key of dict %r could not coerce with %s: %szMissing keys %s)	r�dictrrrrr5�keysr6)	rr�new_dict�k�vr(Znew_keysZ
required_keysZmissingr
r
rr�s,

���zKeyDict.coerce)Nrr
r
r
rr4�s
r4c@s eZdZdZdd�Zdd�ZdS)�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.
    cCs||_||_dSr
)�
key_schema�value_schema)rr>r?r
r
rr�sz
Dict.__init__cCsJt|t�std|f��i}|��D] \}}|j�|�||j�|�<q$|S)Nr7)rr8r�itemsr?rr>)rrr:r;r<r
r
rr�s
zDict.coerceNrr
r
r
rr=�sr=N)r	Ztwisted.python.compatrrr�	Exceptionr�objectrrrrr!r#r%r)r/r4r=r
r
r
r�<module>s$