o
    /h                      @   s<   d Z dgZddlZddlZddlmZ G dd dejZdS )z9CSSUnknownRule implements DOM Level 2 CSS CSSUnknownRule.CSSUnknownRule    N   )cssrulec                       sr   e Zd ZdZ	d fdd	Zdd Zd	d
 Zdd Z fddZe	eeddZ
e	dd ddZe	dd Z  ZS )r   z
    Represents an at-rule not supported by this user agent, so in
    effect all other at-rules not defined in cssutils.

    Format::

        @xxx until ';' or block {...}
     NFc                    s*   t  j||d d| _|r|| _|| _dS )z<
        :param cssText:
            of type string
        )
parentRuleparentStyleSheetN)super__init__
_atkeywordcssText	_readonly)selfr   r   r   readonly	__class__ O/var/www/html/myenv/lib/python3.10/site-packages/cssutils/css/cssunknownrule.pyr	      s
   
zCSSUnknownRule.__init__c                 C   s   d| j j d| jdS )Nzcssutils.css.z	(cssText=))r   __name__r   r   r   r   r   __repr__$   s   zCSSUnknownRule.__repr__c                 C   s$   d| j j d| jdt| ddS )Nz<cssutils.css.z object cssText=z at 0xx>)r   r   r   idr   r   r   r   __str__'   s   $zCSSUnknownRule.__str__c                 C   s   t j| S )z#Return serialized property cssText.)cssutilsserdo_CSSUnknownRuler   r   r   r   _getCssText*   s   zCSSUnknownRule._getCssTextc                    sx  t  | |}|d}|r|jjkr-jjd	| t
jjd dS g dd d fdd	}d fdd		}d fd
d	}d fdd	}d fdd	}d fdd	}	d fdd	}
 }jd||||||||	|
d|
 d\}}|o d }|dkrd}jd	|  n d rd}jd	|  |r|_| dS dS )ad  
        :exceptions:
            - :exc:`~xml.dom.SyntaxErr`:
              Raised if the specified CSS string value has a syntax error and
              is unparsable.
            - :exc:`~xml.dom.InvalidModificationErr`:
              Raised if the specified CSS string value represents a different
              type of rule than the current one.
            - :exc:`~xml.dom.HierarchyRequestErr`:
              Raised if the rule cannot be inserted at this point in the
              style sheet.
            - :exc:`~xml.dom.NoModificationAllowedErr`:
              Raised if the rule is readonly.
        Nz+CSSUnknownRule: No CSSUnknownRule found: %s)errorT)nesting
wellformedc           	         s   |\}}}}| dkra|dv r d  | n6|dv rLdddd| }z d d	 |kr2 d   nt W n tyK   d
 d< jjd|d Y nw |dv rV d sVd} |j ||||d | S d
 d< jjd|d | S )NEOFz{[(r    z}]){[()}]r   Fr!   z+CSSUnknownRule: Wrong nesting of {, [ or (.tokenz};linecol%CSSUnknownRule: Expected end of rule.)appendpop
IndexError_logr   )	expectedseqr*   	tokenizertype_valr,   r-   openingnewr   r   r   CHARI   s6   
z(CSSUnknownRule._setCssText.<locals>.CHARc                    s^   |\}}}} |}| dkr! d d |j||||d | S d d< jjd|d | S )	Nr"   r    r%   r+   Fr!   r.   r)   )_tokenvaluer/   r2   r   r3   r4   r*   r5   r6   r7   r,   r-   r9   r   r   FUNCTIONh   s   
z,CSSUnknownRule._setCssText.<locals>.FUNCTIONc                    s:   t  d D ]}dddd| }||| qg  d< dS )z!close all blocks and return 'EOF'r    r&   r'   r   )r#   r$   r%   r"   )reversedr/   )r3   r4   r*   r5   r   closing)r:   r   r   r"   w   s
   z'CSSUnknownRule._setCssText.<locals>.EOFc                    s"   j jd|tjjd d d< | S )NzCSSUnknownRule: Bad syntax.)r*   r   Fr!   )r2   r   xmldom	SyntaxErr)r3   r4   r*   r5   r9   r   r   INVALID   s
   
z+CSSUnknownRule._setCssText.<locals>.INVALIDc                    P   |\}}}} |}| dkr|j||||d | S d d< jjd|d | S Nr"   r+   Fr!   r.   r)   )_stringtokenvaluer/   r2   r   r=   r9   r   r   STRING      
z*CSSUnknownRule._setCssText.<locals>.STRINGc                    rE   rF   )_uritokenvaluer/   r2   r   r=   r9   r   r   URI   rI   z'CSSUnknownRule._setCssText.<locals>.URIc                    sF   |\}}}}| dkr|j ||||d | S d d< jjd|d | S rF   )r/   r2   r   r=   r9   r   r   default   s   z+CSSUnknownRule._setCssText.<locals>.default)r;   r"   r>   rD   rH   rK   S)r3   r4   r5   productionsrL   r:   r!   r"   Fz.CSSUnknownRule: No ending ";" or "}" found: %rr    z,CSSUnknownRule: Unclosed "{", "[" or "(": %rN)r   _setCssText
_tokenize2
_nexttoken_type_prods	ATKEYWORDr2   r   	_valuestrrA   rB   InvalidModificationErr_tempSeq_parser<   	atkeyword_setSeq)r   r   r5   attokenr;   r>   r"   rD   rH   rK   rL   newseqr!   r3   r   r9   r   rP   .   sf   


	
zCSSUnknownRule._setCssTextz*(DOM) The parsable textual representation.)fgetfsetdocc                 C   s   | j S rO   )UNKNOWN_RULEr   r   r   r   <lambda>   s    zCSSUnknownRule.<lambda>z=The type of this rule, as defined by a CSSRule type constant.)r`   c                 C   s
   t | jS rO   )boolrZ   r   r   r   r   rb      s   
 )r   NNF)r   
__module____qualname____doc__r	   r   r   r   rP   propertyr   typer!   __classcell__r   r   r   r   r      s&    
 ))	rf   __all__xml.domrA   r   r   r   CSSRuler   r   r   r   r   <module>   s    