
    \dp                     J    d Z ddlmZ  G d d          Z G d d          ZdS )z6
Generic sentence handling tools: hopefully reusable.
    )Setc                   l    e Zd ZU dZ e            Zee         ed<   d Z	e
d             Zd Zdefd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}
    ALLOWED_ATTRIBUTESc                     || _         dS )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)selfsentenceDatas     =lib/python3.11/site-packages/twisted/positioning/_sentence.py__init__z_BaseSentence.__init__(   s     *    c                 *    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   )r	   s    r   presentAttributesz_BaseSentence.presentAttributes1   s     D&'''r   c                     || j         v r| j                            |d          S | j        j        }| d| d}t          |          )z5
        Gets an attribute of this sentence.
        Nz sentences have no z attributes)r   r   get	__class____name__AttributeError)r	   name	classNamemsgs       r   __getattr__z_BaseSentence.__getattr__<   sY     4***%))$555/IDD4DDDC %%%r   returnc                     | j                                         }d t          |          D             }d                    |          }| j                             d          pd}| j        j        }d| d| d| dS )	z
        Returns a textual representation of this sentence.

        @return: A textual representation of this sentence.
        @rtype: C{str}
        c                 .    g | ]\  }}|d k    | d| S )typez:  ).0kvs      r   
<listcomp>z*_BaseSentence.__repr__.<locals>.<listcomp>O   s+    EEE1f1r   z, r   zunknown type<z (z) {z}>)r   itemssortedjoinr   r   r   )r	   r$   datadataReprtypeReprr   s         r   __repr__z_BaseSentence.__repr__G   s     "((**EEuEEE99T??%))&11C^N+	;9;;;;h;;;;r   N)r   
__module____qualname____doc__setr   r   str__annotations__r   propertyr   r   r*   r   r   r   r   r   	   s          8 $'355C(((* * * ( ( X(	& 	& 	&<# < < < < < <r   r   c                   (    e Zd ZdZed             ZdS )!_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.
    c                 ~    dh}| j                                         D ]}|D ]}||                    |            |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}
        r   )_SENTENCE_CONTENTSvaluesadd)cls
attributesattributeList	attributes       r   getSentenceAttributesz7_PositioningSentenceProducerMixin.getSentenceAttributesc   sc     X
 3::<< 	* 	*M* * *	$y))))*
 r   N)r   r+   r,   r-   classmethodr<   r   r   r   r3   r3   X   s9            [  r   r3   N)r-   typingr   r   r3   r   r   r   <module>r?      s          L< L< L< L< L< L< L< L<^         r   