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/twisted/positioning/__pycache__/_sentence.cpython-38.pyc
U

�`�[��@s8dZddlmZmZGdd�de�ZGdd�de�ZdS)z6
Generic sentence handling tools: hopefully reusable.
�)�absolute_import�divisionc@s:eZdZdZe�Zdd�Zedd��Zdd�Z	dd	�Z
d
S)�
_BaseSentencea-
    A base sentence class for a particular protocol.

    Using this base class, specific sentence classes can almost automatically
    be created for a particular protocol.
    To do this, fill the ALLOWED_ATTRIBUTES class attribute using
    the C{getSentenceAttributes} class method of the producer::

        class FooSentence(BaseSentence):
            """
            A sentence for integalactic transmodulator sentences.

            @ivar transmogrificationConstant: The value used in the
                transmogrifier while producing this sentence, corrected for
                gravitational fields.
            @type transmogrificationConstant: C{Tummy}
            """
            ALLOWED_ATTRIBUTES = FooProtocol.getSentenceAttributes()

    @ivar presentAttributes: An iterable containing the names of the
        attributes that are present in this sentence.
    @type presentAttributes: iterable of C{str}

    @cvar ALLOWED_ATTRIBUTES: A set of attributes that are allowed in this
        sentence.
    @type ALLOWED_ATTRIBUTES: C{set} of C{str}
    cCs
||_dS)z�
        Initializes a sentence with parsed sentence data.

        @param sentenceData: The parsed sentence data.
        @type sentenceData: C{dict} (C{str} -> C{str} or L{None})
        N)�
_sentenceData)�selfZsentenceData�r�?/usr/lib/python3/dist-packages/twisted/positioning/_sentence.py�__init__)sz_BaseSentence.__init__cCs
t|j�S)z�
        An iterable containing the names of the attributes that are present in
        this sentence.

        @return: The iterable of names of present attributes.
        @rtype: iterable of C{str}
        )�iterr)rrrr�presentAttributes3s	z_BaseSentence.presentAttributescCs8||jkr|j�|d�S|jj}d||f}t|��dS)z5
        Gets an attribute of this sentence.
        Nz"%s sentences have no %s attributes)�ALLOWED_ATTRIBUTESr�get�	__class__�__name__�AttributeError)r�name�	className�msgrrr�__getattr__?s

z_BaseSentence.__getattr__cCsL|j��}dd�t|�D�}d�|�}|j�d�p4d}|jj}d|||fS)z�
        Returns a textual representation of this sentence.

        @return: A textual representation of this sentence.
        @rtype: C{str}
        cSs$g|]\}}|dkrd||f�qS)�typez%s: %sr)�.0�k�vrrr�
<listcomp>Ssz*_BaseSentence.__repr__.<locals>.<listcomp>z, rzunknown typez<%s (%s) {%s}>)r�items�sorted�joinr
rr)rr�dataZdataReprZtypeReprrrrr�__repr__Ks

z_BaseSentence.__repr__N)r�
__module__�__qualname__�__doc__�setrr	�propertyrrrrrrrr
s

rc@seZdZdZedd��ZdS)�!_PositioningSentenceProducerMixina�
    A mixin for certain protocols that produce positioning sentences.

    This mixin helps protocols that store the layout of sentences that they
    consume in a C{_SENTENCE_CONTENTS} class variable provide all sentence
    attributes that can ever occur. It does this by providing a class method,
    C{getSentenceAttributes}, which iterates over all sentence types and
    collects the possible sentence attributes.
    cCs<tdg�}|j��D]"}|D]}|dkr*q|�|�qq|S)aR
        Returns a set of all attributes that might be found in the sentences
        produced by this protocol.

        This is basically a set of all the attributes of all the sentences that
        this protocol can produce.

        @return: The set of all possible sentence attribute names.
        @rtype: C{set} of C{str}
        rN)r"Z_SENTENCE_CONTENTS�values�add)�clsZ
attributesZ
attributeListZ	attributerrr�getSentenceAttributesgs
z7_PositioningSentenceProducerMixin.getSentenceAttributesN)rrr r!�classmethodr(rrrrr$]s	r$N)r!Z
__future__rr�objectrr$rrrr�<module>sS