← Back
Editing: schema.cpython-38.pyc
U ���c9 � @ s� d Z ddlmZmZmZ G dd� de�ZG dd� de�ZG dd� de�Z G d d � d e�Z G dd� de�ZG d d� de�ZG dd� de�Z G dd� de�ZG dd� de�ZG dd� de�ZG dd� de�ZG dd� de�ZdS )z"A schema system. Yes. Another one!� )� iteritems�unicode�longc @ s e Zd ZdZdS )�InvalidErrorz&Raised when invalid input is received.N)�__name__� __module__�__qualname__�__doc__� r r �6/usr/lib/python3/dist-packages/landscape/lib/schema.pyr s r c @ s e Zd ZdZdd� Zdd� ZdS )�Constantz1Something that must be equal to a constant value.c C s || _ d S �N)�value��selfr r r r �__init__ s zConstant.__init__c C sX t | jt�r8t |t�r8z|�� }W n tk r6 Y nX || jkrTtd|| jf ��|S )Nz%r != %r)� isinstancer �str�bytes�decode�UnicodeDecodeErrorr r r r r �coerce s zConstant.coerceN�r r r r r r r r r r r s r c @ s e Zd ZdZdd� Zdd� ZdS )�AnyzsSomething which must apply to any of a number of different schemas. @param schemas: Other schema objects. c G s || _ d S r )�schemas)r r r r r r s zAny.__init__c C sH | j D ]*}z|�|�W S tk r. Y qX qtd|| j f ��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)r r r )r r �schemar r r r # s �z Any.coerceNr r r r r r s r c @ s e Zd ZdZdd� ZdS )�Boolz!Something that must be a C{bool}.c C s t |t�std|f ��|S )Nz%r is not a bool)r �boolr r r r r r 3 s zBool.coerceN�r r r r r r r r r r 1 s r c @ s e Zd ZdZdd� ZdS )�Intz,Something that must be an C{int} or C{long}.c C s t |ttf�std|f ��|S )Nz%r isn't an int or long)r �intr r r r r r r ; s z Int.coerceNr r r r r r 9 s r c @ s e Zd ZdZdd� ZdS )�Floatz7Something that must be an C{int}, C{long}, or C{float}.c C s"