
    hp                     <    S r SSKJr   " S S5      r " S S5      rg)z6
Generic sentence handling tools: hopefully reusable.
    )Setc                   b    \ rS rSr% Sr\" 5       r\\   \	S'   S r
\S 5       rS rS\4S jrS	rg
)_BaseSentence	   a  
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                     Xl         g)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     d/root/1688_scrapy/alibaba-scraper/venv/lib/python3.13/site-packages/twisted/positioning/_sentence.py__init___BaseSentence.__init__(   s
     *    c                 ,    [        U R                  5      $ )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   presentAttributes_BaseSentence.presentAttributes1   s     D&&''r   c                     XR                   ;   a  U R                  R                  US5      $ U R                  R                  nU SU S3n[        U5      e)z%
Gets an attribute of this sentence.
Nz sentences have no z attributes)r   r
   get	__class____name__AttributeError)r   name	classNamemsgs       r   __getattr___BaseSentence.__getattr__<   sV     ***%%))$55//IK24&DC %%r   returnc                 H   U R                   R                  5       n[        U5       VVs/ s H  u  p#US:w  d  M  U SU 3PM     nnnSR                  U5      nU R                   R	                  S5      =(       d    SnU R
                  R                  nSU SU SU S3$ s  snnf )	zx
Returns a textual representation of this sentence.

@return: A textual representation of this sentence.
@rtype: C{str}
typez: z, zunknown type<z (z) {z}>)r
   itemssortedjoinr   r   r   )r   r#   kvdatadataReprtypeReprr   s           r   __repr___BaseSentence.__repr__G   s     ""((*(.uEf1#RsE99T?%%))&1C^NN++	9+RzhZs;; Fs
   BBr	   N)r   
__module____qualname____firstlineno____doc__setr   r   str__annotations__r   propertyr   r   r+   __static_attributes__ r   r   r   r   	   sD    8 $'5C(* ( (	&<# <r   r   c                   (    \ rS rSrSr\S 5       rSrg)!_PositioningSentenceProducerMixinX   a  
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                     S1nU R                   R                  5        H"  nU H  nUc  M  UR                  U5        M     M$     U$ )a  
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   getSentenceAttributes7_PositioningSentenceProducerMixin.getSentenceAttributesc   sK     X
 33::<M*	$y) + = r   r6   N)r   r-   r.   r/   r0   classmethodrB   r5   r6   r   r   r8   r8   X   s      r   r8   N)r0   typingr   r   r8   r6   r   r   <module>rF      s&    L< L<^ r   