Your IP : 216.73.216.213


Current Path : /opt/alt/python37/lib64/python3.7/site-packages/twisted/python/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/site-packages/twisted/python/__pycache__/roots.cpython-37.pyc

B

:��]��@s�dZddlmZmZddlmZddlmZGdd�de�Z	eGdd�d��Z
eGd	d
�d
��ZeGdd�d��ZGd
d�de
�ZGdd�de�ZGdd�de�ZGdd�de�ZdS)zf
Twisted Python Roots: an abstract hierarchy representation for Twisted.

Maintainer: Glyph Lefkowitz
�)�absolute_import�division)�reflect)�	_oldStylec@seZdZdZdS)�NotSupportedErrorzv
    An exception meaning that the tree-manipulation operation
    you're attempting to perform is not supported.
    N)�__name__�
__module__�__qualname__�__doc__�rr�G/opt/alt/python37/lib64/python3.7/site-packages/twisted/python/roots.pyrsrc@s$eZdZdZdZdd�Zdd�ZdS)�Requestz�I am an abstract representation of a request for an entity.

    I also function as the response.  The request is responded to by calling
    self.write(data) until there is no data left and then calling
    self.finish().
    NcCstdt�|j���dS)z7Add some data to the response to this request.
        z%s.writeN)�NotImplementedErrorr�qual�	__class__)�self�datarrr�write%sz
Request.writecCstdt�|j���dS)zXThe response to this request is finished; flush all data to the network stream.
        z	%s.finishN)rrrr)rrrr�finish*szRequest.finish)rrr	r
ZwireProtocolrrrrrrr
sr
c@seZdZdZdd�ZdS)�EntityaZI am a terminal object in a hierarchy, with no children.

    I represent a null interface; certain non-instance objects (strings and
    integers, notably) are Entities.

    Methods on this class are suggested to be implemented, but are not
    required, and will be emulated on a per-protocol basis for types which do
    not handle them.
    cCstdt�|j���dS)zw
        I produce a stream of bytes for the request, by calling request.write()
        and request.finish().
        z	%s.renderN)rrrr)r�requestrrr�render<sz
Entity.renderN)rrr	r
rrrrrr1s
rc@s�eZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�ZdS) �
Collectionz�I represent a static collection of entities.

    I contain methods designed to represent collections that can be dynamically
    created.
    NcCs|dk	r||_ni|_dS)zInitialize me.
        N)�entities)rrrrr�__init__MszCollection.__init__cCs|j�|�S)zqGet an entity that was added to me using putEntity.

        This method will return 'None' if it fails.
        )r�get)r�namerrr�getStaticEntityUszCollection.getStaticEntitycCsdS)znSubclass this to generate an entity on demand.

        This method should return 'None' if it fails.
        Nr)rrrrrr�getDynamicEntity\szCollection.getDynamicEntitycCs2|�|�}|dk	r|S|�||�}|dk	r.|SdS)aRetrieve an entity from me.

        I will first attempt to retrieve an entity statically; static entities
        will obscure dynamic ones.  If that fails, I will retrieve the entity
        dynamically.

        If I cannot retrieve an entity, I will return 'None'.
        N)rr)rrr�entrrr�	getEntitybs	
zCollection.getEntitycCs||j|<dS)zlStore a static reference on 'name' for 'entity'.

        Raises a KeyError if the operation fails.
        N)r)rr�entityrrr�	putEntitysszCollection.putEntitycCs|j|=dS)zaRemove a static reference for 'name'.

        Raises a KeyError if the operation fails.
        N)r)rrrrr�	delEntityzszCollection.delEntitycCstdt�|j���dS)zGStore an entity for 'name', based on the content of 'request'.
        z%s.storeEntityN)rrrr)rrrrrr�storeEntity�szCollection.storeEntitycCstdt�|j���dS)zHRemove an entity for 'name', based on the content of 'request'.
        z%s.removeEntityN)rrrr)rrrrrr�removeEntity�szCollection.removeEntitycCs
|j��S)zlRetrieve a list of all name, entity pairs that I store references to.

        See getStaticEntity.
        )r�items)rrrr�listStaticEntities�szCollection.listStaticEntitiescCsgS)zaA list of all name, entity that I can generate on demand.

        See getDynamicEntity.
        r)rrrrr�listDynamicEntities�szCollection.listDynamicEntitiescCs|��|�|�S)zURetrieve a list of all name, entity pairs I contain.

        See getEntity.
        )r'r()rrrrr�listEntities�szCollection.listEntitiescCs
|j��S)zkRetrieve a list of the names of entities that I store references to.

        See getStaticEntity.
        )r�keys)rrrr�listStaticNames�szCollection.listStaticNamescCsgS)zlRetrieve a list of the names of entities that I store references to.

        See getDynamicEntity.
        r)rrrr�listDynamicNames�szCollection.listDynamicNamescCs|��S)zZRetrieve a list of all names for entities that I contain.

        See getEntity.
        )r+)rrrrr�	listNames�szCollection.listNames)N)rrr	r
rrrr r"r#r$r%r'r(r)r+r,r-rrrrrEs
rc@seZdZdZdS)�ConstraintViolationz7An exception raised when a constraint is violated.
    N)rrr	r
rrrrr.�sr.c@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�Constrainedz?A collection that has constraints on its names and/or entities.cCsdS)z�A method that determines whether an entity may be added to me with a given name.

        If the constraint is satisfied, return 1; if the constraint is not
        satisfied, either return 0 or raise a descriptive ConstraintViolation.
        �r)rrrrr�nameConstraint�szConstrained.nameConstraintcCsdS)z�A method that determines whether an entity may be added to me.

        If the constraint is satisfied, return 1; if the constraint is not
        satisfied, either return 0 or raise a descriptive ConstraintViolation.
        r0r)rr!rrr�entityConstraint�szConstrained.entityConstraintcCst�|||�dS)N)rr")rrr!rrr�reallyPutEntity�szConstrained.reallyPutEntitycCs8|�|�r,|�|�r"|�||�q4td��ntd��dS)zfStore an entity if it meets both constraints.

        Otherwise raise a ConstraintViolation.
        zEntity constraint violated.zName constraint violated.N)r1r2r3r.)rrr!rrrr"�s



zConstrained.putEntityN)rrr	r
r1r2r3r"rrrrr/�s
r/c@s$eZdZdZdZdd�Zdd�ZdS)�Lockedz5A collection that can be locked from adding entities.rcCs
d|_dS)Nr0)�locked)rrrr�lock�szLocked.lockcCs|jS)N)r5)rr!rrrr2�szLocked.entityConstraintN)rrr	r
r5r6r2rrrrr4�sr4c@s,eZdZdZeZdd�Zdd�Zdd�ZdS)	�
Homogenousz�A homogenous collection of entities.

    I will only contain entities that are an instance of the class or type
    specified by my 'entityType' attribute.
    cCs&t||j�rdStd||jf��dS)Nr0z%s of incorrect type (%s))�
isinstance�
entityTyper.)rr!rrrr2�szHomogenous.entityConstraintcCsdS)N�Namer)rrrr�getNameType�szHomogenous.getNameTypecCs|jjS)N)r9r)rrrr�
getEntityTypeszHomogenous.getEntityTypeN)	rrr	r
�objectr9r2r;r<rrrrr7�s
r7N)r
�
__future__rrZtwisted.pythonrZtwisted.python._oldstylerrrr
rr�	Exceptionr.r/r4r7rrrr�<module>	ss$