%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python2.7/site-packages/salt/utils/
Upload File :
Create Path :
Current File : //usr/lib/python2.7/site-packages/salt/utils/schema.pyc

�
���^c@@s`dZddlmZmZmZddlZddlZddlZddlZddl	Z
ddlmZddl
mZdZdZdefd	��YZd
efd��YZe�Zd�Zee�e_[d
ejee�fd��YZdejee�fd��YZdejee�fd��YZdejee�fd��YZdefd��YZdefd��YZdefd��YZ defd��YZ!de!fd��YZ"de!fd ��YZ#d!e!fd"��YZ$d#e!fd$��YZ%d%e!fd&��YZ&d'e!fd(��YZ'd)e!fd*��YZ(d+efd,��YZ)d-e)fd.��YZ*d/efd0��YZ+d1efd2��YZ,d3efd4��YZ-d5efd6��YZ.d7e.fd8��YZ/d9e.fd:��YZ0d;efd<��YZ1d=e*fd>��YZ2d?efd@��YZ3dAefdB��YZ4dS(Cu,
    :codeauthor: Pedro Algarvio (pedro@algarvio.me)
    :codeauthor: Alexandru Bleotu (alexandru.bleotu@morganstanley.com)


    salt.utils.schema
    ~~~~~~~~~~~~~~~~~

    Object Oriented Configuration - JSON Schema compatible generator

    This code was inspired by `jsl`__, "A Python DSL for describing JSON
    schemas".

    .. __: https://jsl.readthedocs.io/


    A configuration document or configuration document section is defined using
    the py:class:`Schema`, the configuration items are defined by any of the
    subclasses of py:class:`BaseSchemaItem` as attributes of a subclass of
    py:class:`Schema` class.

    A more complex configuration document (containing a defininitions section)
    is defined using the py:class:`DefinitionsSchema`. This type of
    schema supports having complex configuration items as attributes (defined
    extending the py:class:`ComplexSchemaItem`). These items have other
    configuration items (complex or not) as attributes, allowing to verify
    more complex JSON data structures

    As an example:

    .. code-block:: python

        class HostConfig(Schema):
            title = 'Host Configuration'
            description = 'This is the host configuration'

            host = StringItem(
                'Host',
                'The looong host description',
                default=None,
                minimum=1
            )

            port = NumberItem(
                description='The port number',
                default=80,
                required=False,
                minimum=0,
                inclusiveMinimum=False,
                maximum=65535
            )

    The serialized version of the above configuration definition is:

    .. code-block:: python

        >>> print(HostConfig.serialize())
        OrderedDict([
            ('$schema', 'http://json-schema.org/draft-04/schema#'),
            ('title', 'Host Configuration'),
            ('description', 'This is the host configuration'),
            ('type', 'object'),
            ('properties', OrderedDict([
                ('host', {'minimum': 1,
                          'type': 'string',
                          'description': 'The looong host description',
                          'title': 'Host'}),
                ('port', {'description': 'The port number',
                          'default': 80,
                          'inclusiveMinimum': False,
                          'maximum': 65535,
                          'minimum': 0,
                          'type': 'number'})
            ])),
            ('required', ['host']),
            ('x-ordering', ['host', 'port']),
            ('additionalProperties', True)]
        )
        >>> print(salt.utils.json.dumps(HostConfig.serialize(), indent=2))
        {
            "$schema": "http://json-schema.org/draft-04/schema#",
            "title": "Host Configuration",
            "description": "This is the host configuration",
            "type": "object",
            "properties": {
                "host": {
                    "minimum": 1,
                    "type": "string",
                    "description": "The looong host description",
                    "title": "Host"
                },
                "port": {
                    "description": "The port number",
                    "default": 80,
                    "inclusiveMinimum": false,
                    "maximum": 65535,
                    "minimum": 0,
                    "type": "number"
                }
            },
            "required": [
                "host"
            ],
            "x-ordering": [
                "host",
                "port"
            ],
            "additionalProperties": false
        }


    The serialized version of the configuration block can be used to validate a
    configuration dictionary using the `python jsonschema library`__.

    .. __: https://pypi.python.org/pypi/jsonschema

    .. code-block:: python

        >>> import jsonschema
        >>> jsonschema.validate({'host': 'localhost', 'port': 80}, HostConfig.serialize())
        >>> jsonschema.validate({'host': 'localhost', 'port': -1}, HostConfig.serialize())
        Traceback (most recent call last):
        File "<stdin>", line 1, in <module>
        File "/usr/lib/python2.7/site-packages/jsonschema/validators.py", line 478, in validate
            cls(schema, *args, **kwargs).validate(instance)
        File "/usr/lib/python2.7/site-packages/jsonschema/validators.py", line 123, in validate
            raise error
        jsonschema.exceptions.ValidationError: -1 is less than the minimum of 0

        Failed validating 'minimum' in schema['properties']['port']:
            {'default': 80,
            'description': 'The port number',
            'inclusiveMinimum': False,
            'maximum': 65535,
            'minimum': 0,
            'type': 'number'}

        On instance['port']:
            -1
        >>>


    A configuration document can even be split into configuration sections. Let's reuse the above
    ``HostConfig`` class and include it in a configuration block:

    .. code-block:: python

        class LoggingConfig(Schema):
            title = 'Logging Configuration'
            description = 'This is the logging configuration'

            log_level = StringItem(
                'Logging Level',
                'The logging level',
                default='debug',
                minimum=1
            )

        class MyConfig(Schema):

            title = 'My Config'
            description = 'This my configuration'

            hostconfig = HostConfig()
            logconfig = LoggingConfig()


    The JSON Schema string version of the above is:

    .. code-block:: python

        >>> print salt.utils.json.dumps(MyConfig.serialize(), indent=4)
        {
            "$schema": "http://json-schema.org/draft-04/schema#",
            "title": "My Config",
            "description": "This my configuration",
            "type": "object",
            "properties": {
                "hostconfig": {
                    "id": "https://non-existing.saltstack.com/schemas/hostconfig.json#",
                    "title": "Host Configuration",
                    "description": "This is the host configuration",
                    "type": "object",
                    "properties": {
                        "host": {
                            "minimum": 1,
                            "type": "string",
                            "description": "The looong host description",
                            "title": "Host"
                        },
                        "port": {
                            "description": "The port number",
                            "default": 80,
                            "inclusiveMinimum": false,
                            "maximum": 65535,
                            "minimum": 0,
                            "type": "number"
                        }
                    },
                    "required": [
                        "host"
                    ],
                    "x-ordering": [
                        "host",
                        "port"
                    ],
                    "additionalProperties": false
                },
                "logconfig": {
                    "id": "https://non-existing.saltstack.com/schemas/logconfig.json#",
                    "title": "Logging Configuration",
                    "description": "This is the logging configuration",
                    "type": "object",
                    "properties": {
                        "log_level": {
                            "default": "debug",
                            "minimum": 1,
                            "type": "string",
                            "description": "The logging level",
                            "title": "Logging Level"
                        }
                    },
                    "required": [
                        "log_level"
                    ],
                    "x-ordering": [
                        "log_level"
                    ],
                    "additionalProperties": false
                }
            },
            "additionalProperties": false
        }

        >>> import jsonschema
        >>> jsonschema.validate(
            {'hostconfig': {'host': 'localhost', 'port': 80},
             'logconfig': {'log_level': 'debug'}},
            MyConfig.serialize())
        >>> jsonschema.validate(
            {'hostconfig': {'host': 'localhost', 'port': -1},
             'logconfig': {'log_level': 'debug'}},
            MyConfig.serialize())
        Traceback (most recent call last):
        File "<stdin>", line 1, in <module>
        File "/usr/lib/python2.7/site-packages/jsonschema/validators.py", line 478, in validate
            cls(schema, *args, **kwargs).validate(instance)
        File "/usr/lib/python2.7/site-packages/jsonschema/validators.py", line 123, in validate
            raise error
        jsonschema.exceptions.ValidationError: -1 is less than the minimum of 0

        Failed validating 'minimum' in schema['properties']['hostconfig']['properties']['port']:
            {'default': 80,
            'description': 'The port number',
            'inclusiveMinimum': False,
            'maximum': 65535,
            'minimum': 0,
            'type': 'number'}

        On instance['hostconfig']['port']:
            -1
        >>>

    If however, you just want to use the configuration blocks for readability
    and do not desire the nested dictionaries serialization, you can pass
    ``flatten=True`` when defining a configuration section as a configuration
    subclass attribute:

    .. code-block:: python

        class MyConfig(Schema):

            title = 'My Config'
            description = 'This my configuration'

            hostconfig = HostConfig(flatten=True)
            logconfig = LoggingConfig(flatten=True)


    The JSON Schema string version of the above is:

    .. code-block:: python

        >>> print(salt.utils.json.dumps(MyConfig, indent=4))
        {
            "$schema": "http://json-schema.org/draft-04/schema#",
            "title": "My Config",
            "description": "This my configuration",
            "type": "object",
            "properties": {
                "host": {
                    "minimum": 1,
                    "type": "string",
                    "description": "The looong host description",
                    "title": "Host"
                },
                "port": {
                    "description": "The port number",
                    "default": 80,
                    "inclusiveMinimum": false,
                    "maximum": 65535,
                    "minimum": 0,
                    "type": "number"
                },
                "log_level": {
                    "default": "debug",
                    "minimum": 1,
                    "type": "string",
                    "description": "The logging level",
                    "title": "Logging Level"
                }
            },
            "x-ordering": [
                "host",
                "port",
                "log_level"
            ],
            "additionalProperties": false
        }
i(tabsolute_importtprint_functiontunicode_literalsN(tOrderedDict(tsixu*https://non-existing.saltstack.com/schemasiPtPrepareablecB@s#eZdZejs!d�ZnRS(u2
    Preserve attributes order for python 2.x
    c@ssy|d�Wn$tk
r4tj||||�SX�fd�}tj��|�|d<tj||||�S(Nu__new__c
@sy|jWn!tk
r.�||||�SX|j||�}tjd�}x^t|jj�D]7}tj|�rc|j	|krc|j
d��PqcqcW�||||�St|j�d�fd��}x|D]\}}	|	||<q�W�||||�S(NicS@s*y|j|�SWntk
r%dSXdS(Ni(tindext
ValueError(tattribute_namet_names((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyt	get_indexls
tkeyc@s�|d�S(Ni((titem(R
(s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyt<lambda>vs(
t__prepare__tAttributeErrortsyst	_getframetreversedtf_codet	co_conststinspecttiscodetco_nametco_namestsortedtitems(
tmcstnametbasest
attributest	namespacetdefining_frametconstantt
by_appearanceRtvalue(tconstructor(R
s5/usr/lib/python2.7/site-packages/salt/utils/schema.pytpreparing_constructorcs 
(tKeyErrorttypet__new__t	functoolstwraps(RRRRR%((R$s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyR(]s
(t__name__t
__module__t__doc__RtPY3R((((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyRUs	tNullSentinelcB@seZdZd�ZeZRS(ut
    A class which instance represents a null value.
    Allows specifying fields with a default value of null.
    cC@stS(N(tFalse(tself((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyt__bool__�s(R+R,R-R2t__nonzero__(((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyR/s	cO@std��dS(Nu*Can't create another NullSentinel instance(t	TypeError(targstkwargs((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyt_failing_new�st
SchemaMetacB@s/eZed��Zd�Zeed�ZRS(cC@st�S(N(R(RRR((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyR�scC@s�t|d<t|d<d|d<i}i}g}xzt|�D]l}t|d�re|j|j�nt|d�r�|j|j�nt|d�r=|j|j	�q=q=Wx�t
j|�D]�\}}	d}
t|	d�r�t|	d�r�q�nt|	d�rJt|	d�r.|	jdkr.||	_n|	j
p:|}
|	||
<nt|	d�ru|	jpe|}
|	||
<n|j|
�q�W||d<||d<||d<tj||||�S(	Nu
__config__u__flatten__u__config_name__u_itemsu	_sectionsu_orderu__item__utitle(tTrueR0tNoneRthasattrtupdatet_itemst	_sectionstextendt_orderRt	iteritemsttitlet
__item_name__t__config_name__tappendR'R((RRRtattrsRtsectionstordertbaseRR#t
entry_name((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyR(�s<


 




cK@setj|�}|jdd�|_|tkr<t|_n|tkrTt|_n|j|�|S(Nuname(	tobjectR(tpopR:RDR9t__flatten__t__allow_additional_items__t__init__(tclstflattentallow_additional_itemsR6tinstance((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyt__call__�s
(R+R,tclassmethodRR(R0RT(((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyR8�s	*tBaseSchemaItemMetacB@s/eZdZed��Zd�Zd�ZRS(uJ
    Config item metaclass to "tag" the class as a configuration item
    cC@st�S(N(R(RRR((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyR�scC@s�t|d<d|d<g}x�t|�D]�}y�t|dg�}|rX|j|�nx`tjjj|j	�jD]C}|dkst||kr�qtn|dkr�qtn|j
|�qtWWq'tk
r�q'q'Xq'W||d<tj
||||�S(Nu__item__u
__item_name__u_attributesuselfuname(R9R:RtgetattrR?tsalttutilsR5tget_function_argspecRORER4R'R((RRRRFRRItbase_attributestargname((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyR(�s$

"

cO@stj|�}|r$td��nxZ|j�D]L}|dkr[|j|�|_q1n||jkr1|jj|�q1q1W|j||�x`t	t
j|��D]I}t|dd�}|r�|jjj|jk	r�|j|�q�q�q�W|j�|S(NuRPlease pass all arguments as named arguments. Un-named arguments are not supportedunameu__validate_attributes__(RKR(tRuntimeErrortcopyRLRCt_attributesRERORRtgetmroRWR:t__validate_attributes__t__func__t__code__(RPR5R6RSRRItvalidate_attributes((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyRT�s$
(R+R,R-RURR(RT(((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyRV�s	tSchemacB@sdeZdZdZdZdZZZe	Z
e	Zedd��Z
ed��Zed��ZRS(u(
    Configuration definition class
    cC@s�t�}|dk	r.djt|�|d<n
d|d<|jdk	rW|j|d<n|jdk	r�|j|jkr�tj|j�j	�|d<q�|j|d<ng}g}d|d<t�}g|_
x�|jD]�}t}d}||j
kr�|j
|}	|	j|	jtkr"dn|�}
|	jtkr�|j|
d	�d
|
krk|j|
d
�nd|
kr�|j|
d�nt|	d�r�|j
j|	j
�nt}q�|
||<n||jkrQ|j|}|jp�|}|jtkr%|j�}|j
j|�t}n|j�||<|jrQ|j|�qQn|tkr�|dk	r�||kr�|j|�q�q�||kr�|j|�q�q�q�W|r�||d	<n|j
r`i}
xq|j
D]f}x]tj|�D]L\}}||
kr/t|
|t�r9|
|j|�q9q�||
|<q�Wq�W|
r`|
j|�|
}q`n|rs||d<n|r�||d
<n|j|d
<|S(Nu
{0}/{1}.json#uidu'http://json-schema.org/draft-04/schema#u$schemautitleudescriptionuobjectutypeu
propertiesu
x-orderingurequireduafter_items_updateuadditionalProperties(RR:tformattBASE_SCHEMA_URLRBtdescriptionR-ttextwraptdedenttstriptafter_items_updateR@R0R>t	serializeRMR9R<R?R;R=RCREtrequiredRRAt
isinstancetlistRN(RPtid_t
serializedRntorderingt
propertiesRt
skip_ordert	item_nametsectiontserialized_sectiontconfigtserialized_configRltentrytdata((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyRm+s�	

		
$	

		
	



cC@s�|j�}i}x�|dj�D]�\}}d|krO|d||<q#nd|kr#xG|dj�D]5\}}d|krl|d|j|i�|<qlqlWq#q#q#W|S(Nu
propertiesudefault(RmRt
setdefault(RPRrtdefaultsRtdetailstsnametsdetails((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyR~�s!
cC@s\|j�}|jdg�}x.|dD]"}||kr)|j|�q)q)Wtd|�S(Nurequiredu
propertiestrequirements(RmtgetREtRequirementsItem(RPtserialized_schemaRnR((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pytas_requirements_item�sN(R+R,R-R:RBRhR=R>R@R0RMRNRURmR~R�(((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyRes^t
SchemaItemcB@sYeZdZdZdZdZeZdZ	eZ
dd�Zd�Zd�Z
d�ZRS(uR
    Base configuration items class.

    All configurations must subclass it
    cK@s%|dk	r||_n||_dS(u`
        :param required: If the configuration item is required. Defaults to ``False``.
        N(R:Rntextra(R1RnR�((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyRO�scC@s(|jttfkr$td��ndS(u
        Run any validation check you need the instance attributes.

        ATTENTION:

        Don't call the parent class when overriding this
        method because it will just duplicate the executions. This class'es
        metaclass will take care of that.
        u!'required' can only be True/FalseN(RnR9R0R](R1((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyRa�s
cC@s�t|dj|�d�}|dk	r?t|�r?|�}n|dkr`t||d�}n|dkr�t|dj|�d�}n|dkr�|jj|d�}n|S(uP
        Return the argname value looking up on all possible attributes
        u__get_{0}__u__{0}__N(RWRfR:tcallableR�R�(R1R\targvalue((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyt_get_argname_value�scC@s
t�dS(uC
        Return a serializable form of the config instance
        N(tNotImplementedError(R1((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyRm�sN(R+R,R-R:t__type__t
__format__R_R0RMt__serialize_attr_aliases__RnRORaR�Rm(((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyR��s		tBaseSchemaItemcB@s_eZdZdZdZdZdZdZdddddd�Z	d�Z
d�Zd�ZRS(uR
    Base configuration items class.

    All configurations must subclass it
    cK@s�|dk	r||_n|dk	r0||_n|dk	rH||_n|dk	r`||_n|dk	rx||_ntt|�j|�dS(uA
        :param required:
            If the configuration item is required. Defaults to ``False``.
        :param title:
            A short explanation about the purpose of the data described by this item.
        :param description:
            A detailed explanation about the purpose of the data described by this item.
        :param default:
            The default value for this configuration item. May be :data:`.Null` (a special value
            to set the default value to null).
        :param enum:
            A list(list, tuple, set) of valid choices.
        N(	R:RBRhtdefaulttenumt	enumNamestsuperR�RO(R1RBRhR�R�R�R6((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyROscC@s�|jdk	rct|jtttf�s9td��nt|jt�sct|j�|_qcn|jdk	r�t|jtttf�s�td��nt|j�t|j�kr�td��nt|jt�s�t|j�|_q�ndS(NuLOnly the 'list', 'tuple' and 'set' python types can be used to define 'enum'uQOnly the 'list', 'tuple' and 'set' python types can be used to define 'enumNames'u5The size of 'enumNames' must match the size of 'enum'(	R�R:RoRpttupletsetR]R�tlen(R1((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyRa%scC@s�i|jd6}x�|jD]}}|dkr2qn|j|�}|dk	r|tkrbd}n|jr�||jkr�|j|}n|||<qqW|S(uC
        Return a serializable form of the config instance
        utypeurequiredN(R�R_R�R:tNullR�(R1RrR\R�((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyRm;s	cC@sB|jdk	r>|j|jkr7tj|j�j�S|jSdS(N(RhR:R-RiRjRk(R1((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyt__get_description__OsN(
R+R,R-R:RhRBR�R�R�RORaRmR�(((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyR��s
		tNullItemcB@seZdZRS(unull(R+R,R�(((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyR�ustBooleanItemcB@seZdZRS(uboolean(R+R,R�(((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyR�zst
StringItemcB@s^eZdZdZidd6dd6ZdZdZdZdZ	ddddd�Z
d�ZRS(	u&
    A string configuration field
    ustringu	minLengthu
min_lengthu	maxLengthu
max_lengthcK@sz|dk	r||_n|dk	r0||_n|dk	rH||_n|dk	r`||_ntt|�j|�dS(u�
        :param required:
            If the configuration item is required. Defaults to ``False``.
        :param title:
            A short explanation about the purpose of the data described by this item.
        :param description:
            A detailed explanation about the purpose of the data described by this item.
        :param default:
            The default value for this configuration item. May be :data:`.Null` (a special value
            to set the default value to null).
        :param enum:
            A list(list, tuple, set) of valid choices.
        :param format:
            A semantic format of the string (for example, ``"date-time"``, ``"email"``, or ``"uri"``).
        :param pattern:
            A regular expression (ECMA 262) that a string value must match.
        :param min_length:
            The minimum length
        :param max_length:
            The maximum length
        N(R:Rftpatternt
min_lengtht
max_lengthR�R�RO(R1RfR�R�R�R6((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyRO�scC@s1|jdkr-|jdk	r-|j|_ndS(N(RfR:R�(R1((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyRa�sN(R+R,R-R�R�R:RfR�R�R�RORa(((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyR�~s
!t	EMailItemcB@seZdZdZRS(ut
    An internet email address, see `RFC 5322, section 3.4.1`__.

    .. __: http://tools.ietf.org/html/rfc5322
    uemail(R+R,R-R�(((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyR��stIPv4ItemcB@seZdZdZRS(u�
    An IPv4 address configuration field, according to dotted-quad ABNF syntax as defined in
    `RFC 2673, section 3.2`__.

    .. __: http://tools.ietf.org/html/rfc2673
    uipv4(R+R,R-R�(((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyR��stIPv6ItemcB@seZdZdZRS(u�
    An IPv6 address configuration field, as defined in `RFC 2373, section 2.2`__.

    .. __: http://tools.ietf.org/html/rfc2373
    uipv6(R+R,R-R�(((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyR��stHostnameItemcB@seZdZdZRS(u�
    An Internet host name configuration field, see `RFC 1034, section 3.1`__.

    .. __: http://tools.ietf.org/html/rfc1034
    uhostname(R+R,R-R�(((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyR��stDateTimeItemcB@seZdZdZRS(u�
    An ISO 8601 formatted date-time configuration field, as defined by `RFC 3339, section 5.6`__.

    .. __: http://tools.ietf.org/html/rfc3339
    u	date-time(R+R,R-R�(((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyR��stUriItemcB@seZdZdZRS(u�
    A universal resource identifier (URI) configuration field, according to `RFC3986`__.

    .. __: http://tools.ietf.org/html/rfc3986
    uuri(R+R,R-R�(((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyR��st
SecretItemcB@seZdZdZRS(ua
    A string configuration field containing a secret, for example, passwords, API keys, etc
    usecret(R+R,R-R�(((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyR��st
NumberItemcB@s_eZdZidd6dd6dd6ZdZdZdZdZdZ	dddddd�Z
RS(	unumberu
multipleOfumultiple_ofuexclusiveMinimumuexclusive_minimumuexclusiveMaximumuexclusive_maximumcK@s�|dk	r||_n|dk	r0||_n|dk	rH||_n|dk	r`||_n|dk	rx||_ntt|�j|�dS(u�
        :param required:
            If the configuration item is required. Defaults to ``False``.
        :param title:
            A short explanation about the purpose of the data described by this item.
        :param description:
            A detailed explanation about the purpose of the data described by this item.
        :param default:
            The default value for this configuration item. May be :data:`.Null` (a special value
            to set the default value to null).
        :param enum:
            A list(list, tuple, set) of valid choices.
        :param multiple_of:
            A value must be a multiple of this factor.
        :param minimum:
            The minimum allowed value
        :param exclusive_minimum:
            Whether a value is allowed to be exactly equal to the minimum
        :param maximum:
            The maximum allowed value
        :param exclusive_maximum:
            Whether a value is allowed to be exactly equal to the maximum
        N(	R:tmultiple_oftminimumtexclusive_minimumtmaximumtexclusive_maximumR�R�RO(R1R�R�R�R�R�R6((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyROsN(R+R,R�R�R:R�R�R�R�R�RO(((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyR��s
tIntegerItemcB@seZdZRS(uinteger(R+R,R�(((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyR�2st	ArrayItemcB@sxeZdZidd6dd6dd6dd6ZdZdZdZdZdZ	dddddd	�Z
d
�Zd�ZRS(
uarrayuminItemsu	min_itemsumaxItemsu	max_itemsuuniqueItemsuunique_itemsuadditionalItemsuadditional_itemscK@s�|dk	r||_n|dk	r0||_n|dk	rH||_n|dk	r`||_n|dk	rx||_ntt|�j|�dS(u�
        :param required:
            If the configuration item is required. Defaults to ``False``.
        :param title:
            A short explanation about the purpose of the data described by this item.
        :param description:
            A detailed explanation about the purpose of the data described by this item.
        :param default:
            The default value for this configuration item. May be :data:`.Null` (a special value
            to set the default value to null).
        :param enum:
            A list(list, tuple, set) of valid choices.
        :param items:
            Either of the following:
                * :class:`BaseSchemaItem` -- all items of the array must match the field schema;
                * a list or a tuple of :class:`fields <.BaseSchemaItem>` -- all items of the array must be
                  valid according to the field schema at the corresponding index (tuple typing);
        :param min_items:
            Minimum length of the array
        :param max_items:
            Maximum length of the array
        :param unique_items:
            Whether all the values in the array must be distinct.
        :param additional_items:
            If the value of ``items`` is a list or a tuple, and the array length is larger than
            the number of fields in ``items``, then the additional items are described
            by the :class:`.BaseField` passed using this argument.
        :type additional_items: bool or :class:`.BaseSchemaItem`
        N(	R:Rt	min_itemst	max_itemstunique_itemstadditional_itemsR�R�RO(R1RR�R�R�R�R6((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyROFs$cC@s�|jr#|jr#td��n|jdk	r�t|jttf�r�x�|jD]9}t|ttf�sTtdj	t
|����qTqTWq�t|jttf�s�tdj	t
|j����q�ndS(Nu0One of items or additional_items must be passed.utAll items passed in the item argument tuple/list must be a subclass of Schema, SchemaItem or BaseSchemaItem, not {0}u]The items argument passed must be a subclass of Schema, SchemaItem or BaseSchemaItem, not {0}(RR�R]R:RoRpR�ReR�RfR'(R1R((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyRavscC@srt|jttf�r%|jj�St|jttf�rng}x$|jD]}|j|j��qMW|SdS(N(RoRReR�RmR�RpRE(R1RR((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyt
__get_items__�s
N(
R+R,R�R�R:RR�R�R�R�RORaR�(((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyR�6s$
+	tDictItemcB@s�eZdZidd6dd6dd6dd6ZdZdZdZdZdZ	dddddd	�Z
d
�Zd�Zd�Z
d
�Zed�Zd�ZRS(uobjectu
minPropertiesumin_propertiesu
maxPropertiesumax_propertiesupatternPropertiesupattern_propertiesuadditionalPropertiesuadditional_propertiescK@s�|dk	r||_n|dk	r0||_n|dk	rH||_n|dk	r`||_n|dk	rx||_ntt|�j|�dS(u~
        :param required:
            If the configuration item is required. Defaults to ``False``.
        :type required:
            boolean
        :param title:
            A short explanation about the purpose of the data described by this item.
        :type title:
            str
        :param description:
            A detailed explanation about the purpose of the data described by this item.
        :param default:
            The default value for this configuration item. May be :data:`.Null` (a special value
            to set the default value to null).
        :param enum:
            A list(list, tuple, set) of valid choices.
        :param properties:
            A dictionary containing fields
        :param pattern_properties:
            A dictionary whose keys are regular expressions (ECMA 262).
            Properties match against these regular expressions, and for any that match,
            the property is described by the corresponding field schema.
        :type pattern_properties: dict[str -> :class:`.Schema` or
                                       :class:`.SchemaItem` or :class:`.BaseSchemaItem`]
        :param additional_properties:
            Describes properties that are not described by the ``properties`` or ``pattern_properties``.
        :type additional_properties: bool or :class:`.Schema` or :class:`.SchemaItem`
                                     or :class:`.BaseSchemaItem`
        :param min_properties:
            A minimum number of properties.
        :type min_properties: int
        :param max_properties:
            A maximum number of properties
        :type max_properties: int
        N(	R:Rttpattern_propertiestadditional_propertiestmin_propertiestmax_propertiesR�R�RO(R1RtR�R�R�R�R6((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyRO�s*cC@s�|jr-|jr-|jr-td��n|jdk	r�t|jttf�sutdjt	|j����nt|jt�s�xV|jj
�D]B\}}t|ttf�s�tdj|t	|����q�q�Wq�n|jdk	r~t|jt�s%tdjt	|j����nxV|jj
�D]B\}}t|ttf�s5tdj|t	|����q5q5Wn|jdk	r�t|jtttf�s�tdjt	|j����q�ndS(NuMOne of properties, pattern_properties or additional_properties must be passeduEThe passed properties must be passed as a dict or  a Schema not '{0}'ufThe passed property who's key is '{0}' must be of type Schema, SchemaItem or BaseSchemaItem, not '{1}'u@The passed pattern_properties must be passed as a dict not '{0}'unThe passed pattern_property who's key is '{0}' must be of type Schema, SchemaItem or BaseSchemaItem, not '{1}'ufThe passed additional_properties must be of type bool, Schema, SchemaItem or BaseSchemaItem, not '{0}'(
RtR�R�R]R:RoRetdictRfR'RR�tbool(R1Rtprop((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyRa�s:"cC@ss|jdkrdSt|jt�r6|jj�dSt�}x-|jj�D]\}}|j�||<qOW|S(Nu
properties(RtR:RoReRmRR(R1RtRR�((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyt__get_properties__s	cC@sP|jdkrdSt�}x-|jj�D]\}}|j�||<q,W|S(N(R�R:RRRm(R1R�RR�((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyt__get_pattern_properties__s	cC@s9|jdkrdSt|jt�r,|jS|jj�S(N(R�R:RoR�Rm(R1((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyt__get_additional_properties__s
cC@s
||_|S(N(RM(R1RQ((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyRT s	cC@s�tt|�j�}g}|jdk	r�t|jt�rn|jj�}d|kr�|j|d�q�q�x9|jj�D]%\}}|j	r~|j
|�q~q~Wn|r�||d<n|S(Nurequired(R�R�RmRtR:RoReR?RRnRE(R1tresultRnRrRR�((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyRm$s	
N(R+R,R�R�R:RtR�R�R�R�RORaR�R�R�R0RTRm(((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyR��s,
1	)	
		R�cB@s2eZdZdZdd�Zd�Zd�ZRS(uobjectcC@s/|dk	r||_ntt|�j�dS(N(R:R�R�R�RO(R1R�((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyRO:scC@s�|jdkrtd��nt|jttttf�sWtdj|j���nt|jt�s�t|jt�s�t|j�|_nxYt	|j�D]E\}}t|t
jtf�s�tdj|t|����q�q�WndS(Nu)The passed requirements must not be emptyudThe passed requirements must be passed as a list, tuple, set SchemaItem or BaseSchemaItem, not '{0}'uTThe passed requirement at the {0} index must be of type str or SchemaItem, not '{1}'(
R�R:R]RoR�RpR�R�Rft	enumerateRtstring_typesR'(R1tidxR((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyRa?scC@s~t|jt�r$|jj�}nOg}xF|jD];}t|t�rb|j|j��q4n|j|�q4Wi|d6S(Nurequired(RoR�R�RmRE(R1R�trequirement((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyRmUsN(R+R,R�R:R�RORaRm(((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyR�5s
	t	OneOfItemcB@sAeZdZdZddd�Zd�Zed�Zd�Z	RS(uoneOfcC@s5|dk	r||_ntt|�jd|�dS(NRn(R:RR�R�RO(R1RRn((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyROhscC@s�|jstd��nt|jttf�sQtdjt|j����nxSt|j�D]B\}}t|tt	f�satdj|t|����qaqaWt|jt�s�t|j�|_ndS(Nu"The passed items must not be emptyu9The passed items must be passed as a list/tuple not '{0}'u`The passed item at the {0} index must be of type Schema, SchemaItem or BaseSchemaItem, not '{1}'(
RR]RoRpR�RfR'R�ReR�(R1R�R((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyRams	cC@s
||_|S(N(RM(R1RQ((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyRT�s	cC@s*ig|jD]}|j�^q
|j6S(N(RRmR�(R1ti((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyRm�sN(
R+R,R�R:RRORaR0RTRm(((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyR�bs	t	AnyOfItemcB@seZdZRS(uanyOf(R+R,R�(((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyR��st	AllOfItemcB@seZdZRS(uallOf(R+R,R�(((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyR��stNotItemcB@s2eZdZdZdd�Zd�Zd�ZRS(unotcC@s/|dk	r||_ntt|�j�dS(N(R:RR�R�RO(R1R((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyRO�scC@sU|jstd��nt|jttf�sQtdjt|j����ndS(NuAn item must be passeduJThe passed item be of type Schema, SchemaItem or BaseSchemaItem, not '{0}'(RR]RoReR�RfR'(R1((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyRa�s	cC@si|jj�|j6S(N(RRmR�(R1((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyRm�sN(R+R,R�R:RRORaRm(((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyR��s
	tPortItemcB@seZdZdZRS(ii��(R+R,R�R�(((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyR��stComplexSchemaItemcB@s\eZdZgZdZddd�Zd�Zed��Z	d�Z
d�Zd�ZRS(u>
    .. versionadded:: 2016.11.0

    Complex Schema Item
    cC@sKtt|�jd|�d|_|r.|n	|jj|_|j�dS(NRnuobject(R�R�ROR�t	__class__R+t_definition_namet_add_missing_schema_attributes(R1tdefinition_nameRn((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyRO�s
	cC@s�xgt|�D]}|jd�s|^qD]O}t||�}tt||�t�r/||jkr/|jj|�q/q/WdS(u�
        Adds any missed schema attributes to the _attributes list

        The attributes can be class attributes and they won't be
        included in the _attributes list automatically
        u__N(tdirt
startswithRWRoR�R_RE(R1tattrtattr_val((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyR��s
5cC@s|jS(N(R�(R1((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyR��scC@sidj|j�d6S(uc
        The serialization of the complex item is a pointer to the item
        definition
        u#/definitions/{0}u$ref(RfR�(R1((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyRm�scC@s�tt|�j�}|d=|j|d<i}g}xy|jD]n}t||�}|r?t|t�r?||=|j�||<|j||d<|j	r�|j
|�q�q?q?W|jd�dkr�i|d<n|dj
|�|r�||d<n|S(u*Returns the definition of the complex itemudefinition_nameutitleutypeu
propertiesurequiredN(R�R�RmR�R_RWRoR�R�RnRER�R:R<(R1RrRttrequired_attr_namest	attr_nameR�((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pytget_definition�s&
	

cC@s;g|jD]-}tt||�t�r
t||�^q
S(u.Returns a dictionary of the complex attributes(R_RoRWR�(R1R�((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pytget_complex_attrs�sN(
R+R,R-R_R:R�ROR�tpropertyR�RmR�R�(((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyR��s				tDefinitionsSchemacB@s eZdZedd��ZRS(u
    .. versionadded:: 2016.11.0

    JSON schema class that supports ComplexSchemaItem objects by adding
    a definitions section to the JSON schema, containing the item definitions.

    All references to ComplexSchemaItems are built using schema inline
    dereferencing.
    cC@s�tt|�j|�}g}|jj�}tjrEt|�}nx�|r8|jd�}t	|t
�r�|j|�|j|j
��nt	|t�r�|j|j�qHt	|t�r�|j|j�qHt	|t�rH|jr|j|jj��n|jr5t	|jt�r5|j|j�q5qHqHWt�}x3|D]+}t	|t
�rI|j�||j<qIqIW||d<|S(Niudefinitions(R�R�RmR=tvaluesRR.RpRLRoR�RER?R�R�RR�R�RtR�R�RR�R�(RPRqRrt
complex_itemst	aux_itemsRtdefinitionsRy((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyRms4		
			

N(R+R,R-RUR:Rm(((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyR�s	(5R-t
__future__RRRRRRiR)tsalt.utils.argsRXtsalt.utils.odictRtsalt.extRRgt#RENDER_COMMENT_YAML_MAX_LINE_LENGTHR'RRKR/R�R7tstaticmethodR(twith_metaclassR8RVReR�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�(((s5/usr/lib/python2.7/site-packages/salt/utils/schema.pyt<module>AsV*		"A"C"�"B�;	
				;a�-'Q

Zerion Mini Shell 1.0