
    ]hq%                         d dl mZmZmZmZ d dlZd dlZddlm	Z	 ddl
mZ ddlmZ 	 dgZdZd	Zd dlZej$                  d    d
k\  reZneZ G d de	j,                        Zy)    )unicode_literalsdivisionabsolute_importprint_functionN   )cssrule)SelectorList)CSSStyleDeclarationCSSStyleRulerestructuredtextz$Id$   c                       e Zd ZdZ	 	 d fd	Zd Zd Zd Z fdZ e	eed	      Z
d
 Z e	ed	      Zd ZdZ e	d ed	      Zd Z e	d ed	      Zd Z e	d ed	      Z e	d d	      Z e	d       Zd Z e	ed	      Z xZS )r   a=  The CSSStyleRule object represents a ruleset specified (if any) in a CSS
    style sheet. It provides access to a declaration block as well as to the
    associated group of selectors.

    Format::

        : selector [ COMMA S* selector ]*
        LBRACE S* declaration [ ';' S* declaration ]* '}' S*
        ;
    Nc                     t         t        |   ||       t               | _        |r|| _        |r|| _        || _        yt               | _        || _        y)a$  
        :Parameters:
            selectorText
                string parsed into selectorList
            style
                string parsed into CSSStyleDeclaration for this CSSStyleRule
            readonly
                if True allows setting of properties in constructor only
        )
parentRuleparentStyleSheetN)	superr   __init__r	   selectorListselectorTextstyler
   	_readonly)selfr   r   r   r   readonly	__class__s         /home/pod-website-builder.sw7ft.com/pod-website-builder/website-analyzer/venv/lib/python3.12/site-packages/css_parser/css/cssstylerule.pyr   zCSSStyleRule.__init__    s\     	lD*j<L 	+ 	N )N ,DDJ " -.DJ!    c                     | j                   r| j                  | j                   f}n| j                  }d| j                  j                  d|d| j                  j
                  dS )Nzcss_parser.css.z(selectorText=z, style=))_namespacesr   r   __name__r   cssText)r   sts     r   __repr__zCSSStyleRule.__repr__9   sR    ##T%5%56B""BNN##R););= 	=r   c                     d| j                   j                  | j                  | j                  j                  | j
                  t        |       fz  S )NzJ<css_parser.css.%s object selectorText=%r style=%r _namespaces=%r at 0x%x>)r   r    r   r   r!   r   idr   s    r   __str__zCSSStyleRule.__str__A   sI    !^^44!..!ZZ//!--X	'' 	'r   c                 @    t         j                  j                  |       S )z#Return serialized property cssText.)
css_parserserdo_CSSStyleRuler&   s    r   _getCssTextzCSSStyleRule._getCssTextI   s    ~~--d33r   c                    t         t        |   |       | j                  |      \  }}	 | j                  j
                  }| j                  |      }| j                  |d      }| j                  |d      }| j                  |      }|r0| j                  j                  d| j                  |      z  |       y|s.| j                  j                  d| j                  |      z         y| j                  |d         j                  d      rH| j                  j                  d	| j                  |      z  t        j                   j"                  
       yt%        |       }t'        |       }d}	|j)                         }
| j                  |
      dk7  r1d}	| j                  j                  d| j                  |      z  |
       n2|s0d}	| j                  j                  d| j                  |      z  |
       ||f|_        |s0d}	| j                  j                  d| j                  |      z         n|j)                         }| j                  |      | j-                  |      }}|dk7  r5|dk7  r0d}	| j                  j                  d| j                  |      z         nd|k(  r|j/                  |       ||_        |	r|| _        || _        yy# t        $ r Y w xY w)aR  
        :param cssText:
            a parseable string or a tuple of (cssText, dict-of-namespaces)
        :exceptions:
            - :exc:`~xml.dom.NamespaceErr`:
              Raised if the specified selector uses an unknown namespace
              prefix.
            - :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.
        T)blockstartonly)blockendonlyz"CSSStyleRule: Trailing content: %s)tokenz#CSSStyleRule: No selector found: %rr   @zCSSStyleRule: No style rule: %r)error)r   {Fz7CSSStyleRule: No start { of style declaration found: %rz$CSSStyleRule: No selector found: %r.z3CSSStyleRule: No style declaration or "}" found: %r}EOFz6CSSStyleRule: No "}" after style declaration found: %rN)r   r   _setCssText_splitNamespacesOffr   
namespacesAttributeError
_tokenize2_tokensupto2
_nexttoken_logr2   	_valuestr_tokenvalue
startswithxmldomInvalidModificationErrr	   r
   popr   _typeappendr!   r   r   )r   r!   r8   	tokenizerselectortokensstyletokenstrailnewSelectorListnewStyleok
bracetokenbraceorEOFtokenvaltypr   s                 r   r6   zCSSStyleRule._setCssTextM   s   ( 	lD-g6 #66w?	..99J OOG,	**9T*J''	'E	*IIOO@ NN734;@  BIIOOA NN734 5nQ/0;;C@IIOO= NN734"%''"@"@  B +d;O*d;HB'++-J
+s2		MNN7+,-79 $		 F $w 7!89CE -;,6,8O( 		INN7+,- #.//"3++O<djj>YS#:#,BIIOO %<&*nnW&=%> ? |#**?;'2H$$3!%
 q  		s   K 	KKz7(DOM) The parsable textual representation of this rule.)docc                 z    	 | j                   j                  S # t        $ r | j                  j                  cY S w xY w)zSUses children namespaces if not attached to a sheet, else the sheet's
        ones.)r   r8   r9   r   r   r&   s    r   __getNamespaceszCSSStyleRule.__getNamespaces   s:    	1((333 	1$$000	1s    ::zIf this Rule is attached to a CSSStyleSheet the namespaces of that sheet are mirrored here. While the Rule is not attached the namespaces of selectorList are used.c                 @    | j                          | |_        || _        y)zp
        :param selectorList: A SelectorList which replaces the current
            selectorList object
        N)_checkReadonly_parentRule_selectorList)r   r   s     r   _setSelectorListzCSSStyleRule._setSelectorList   s     
 	#' )r   c                     | j                   S N)rX   r&   s    r   <lambda>zCSSStyleRule.<lambda>   s    );); r   zThe SelectorList of this rule.c                 f    | j                          t        ||       }|j                  r|| _        yy)aO  
        wrapper for css_parser SelectorList object

        :param selectorText:
            of type string, might also be a comma separated list
            of selectors
        :exceptions:
            - :exc:`~xml.dom.NamespaceErr`:
              Raised if the specified selector uses an unknown namespace
              prefix.
            - :exc:`~xml.dom.SyntaxErr`:
              Raised if the specified CSS string value has a syntax error
              and is unparsable.
            - :exc:`~xml.dom.NoModificationAllowedErr`:
              Raised if this rule is readonly.
        )r   r   N)rV   r	   
wellformedrX   )r   r   sls      r   _setSelectorTextzCSSStyleRule._setSelectorText   s0    " 	|E==!#D r   c                 .    | j                   j                  S r[   )rX   r   r&   s    r   r\   zCSSStyleRule.<lambda>   s    ););)H)H r   zB(DOM) The textual representation of the selector for the rule set.c                     | j                          t        |t              rt        ||       | _        y| |_        || _        y)zt
        :param style: A string or CSSStyleDeclaration which replaces the
            current style object.
        )r!   r   N)rV   
isinstancestring_typer
   _stylerW   )r   r   s     r   	_setStylezCSSStyleRule._setStyle   s7    
 	e[)-eMDK $EDKr   c                     | j                   S r[   )re   r&   s    r   r\   zCSSStyleRule.<lambda>   s
    $++ r   z-(DOM) The declaration-block of this rule set.c                     | j                   S r[   )
STYLE_RULEr&   s    r   r\   zCSSStyleRule.<lambda>   s
     r   z=The type of this rule, as defined by a CSSRule type constant.c                 .    | j                   j                  S r[   )r   r^   r&   s    r   r\   zCSSStyleRule.<lambda>   s    t'8'8'C'C r   c                 .    | j                   j                  S )z.Return whether the style declaration is valid.)r   validr&   s    r   	_getValidzCSSStyleRule._getValid   s    zzr   z,``True`` when the style declaration is true.)NNNNF)r    
__module____qualname____doc__r   r#   r'   r,   r6   propertyr!   _CSSStyleRule__getNamespacesr   rY   rX   r   r`   r   rf   r   typer^   rm   rl   __classcell__)r   s   @r   r   r      s    	 BF16"2='4U&n {K G1 ? HIK* M;=M @BL$. H,!=>L

  -yHJE 0)*D CDJ  YGIEr   )
__future__r   r   r   r   xml.domrA   r)    r   selectorlistr	   cssstyledeclarationr
   __all____docformat____version__sysversion_infostrrd   
basestringCSSRuler    r   r   <module>r      sc    R R    & 4 ;
" 
A!KKeI7?? eIr   