o
    ef                      @   s<   d Z dgZddlmZ ddlZddlZG dd dejZdS )z9CSSUnknownRule implements DOM Level 2 CSS CSSUnknownRule.CSSUnknownRule   )cssrule    Nc                       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__Z
_atkeywordcssTextZ	_readonly)selfr
   r   r   readonly	__class__ KD:\Projects\ConvertPro\env\Lib\site-packages\cssutils/css/cssunknownrule.pyr	      s
   
zCSSUnknownRule.__init__c                 C   s   d | jj| jS )Nzcssutils.css.{}(cssText={!r}))formatr   __name__r
   r   r   r   r   __repr__!   s   
zCSSUnknownRule.__repr__c                 C   s   d | jj| jt| S )Nz/<cssutils.css.{} object cssText={!r} at 0x{:x}>)r   r   r   r
   idr   r   r   r   __str__&   s
   zCSSUnknownRule.__str__c                 C   s   t j| S )z#Return serialized property cssText.)cssutilsZserZ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}]){[()}])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(   Zopeningnewr   r   r   CHARL   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*   r-   r   r.   r/   r%   r0   r1   r2   r'   r(   r3   r   r   FUNCTIONk   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*   )r.   r/   r%   r0   xclosing)r4   r   r   r   z   s
   z'CSSUnknownRule._setCssText.<locals>.EOFc                    s"   j jd|tjjd d d< | S )NzCSSUnknownRule: Bad syntax.)r%   r   Fr   )r-   r   xmldomZ	SyntaxErr)r.   r/   r%   r0   r3   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$   )Z_stringtokenvaluer*   r-   r   r7   r3   r   r   STRING      
z*CSSUnknownRule._setCssText.<locals>.STRINGc                    r?   r@   )Z_uritokenvaluer*   r-   r   r7   r3   r   r   URI   rB   z'CSSUnknownRule._setCssText.<locals>.URIc                    sF   |\}}}}| dkr|j ||||d | S d d< jjd|d | S r@   )r*   r-   r   r7   r3   r   r   default   s   z+CSSUnknownRule._setCssText.<locals>.default)r5   r   r8   r>   rA   rC   S)r.   r/   r0   ZproductionsrD   r4   r   r   Fz.CSSUnknownRule: No ending ";" or "}" found: %rr   z,CSSUnknownRule: Unclosed "{", "[" or "(": %rN)r   _setCssTextZ
_tokenize2Z
_nexttoken_typeZ_prodsZ	ATKEYWORDr-   r   Z	_valuestrr<   r=   ZInvalidModificationErrZ_tempSeq_parser6   	atkeywordZ_setSeq)r   r
   r0   Zattokenr5   r8   r   r>   rA   rC   rD   Znewseqr   r.   r   r3   r   rG   1   sf   


	
zCSSUnknownRule._setCssTextz*(DOM) The parsable textual representation.)fgetfsetdocc                 C   s   | j S rF   )ZUNKNOWN_RULEr   r   r   r   <lambda>   s    zCSSUnknownRule.<lambda>z=The type of this rule, as defined by a CSSRule type constant.)rM   c                 C   s
   t | jS rF   )boolrJ   r   r   r   r   rN      s   
 )r   NNF)r   
__module____qualname____doc__r	   r   r   r   rG   propertyr
   typer   __classcell__r   r   r   r   r   	   s&    
 ))	rR   __all__r   r   r   Zxml.domr<   ZCSSRuler   r   r   r   r   <module>   s    