
     h$                     l    d Z dgZddlZddlZddlmZ ddlmZ ddl	m
Z
  G d dej                        Zy)	z5CSSStyleRule implements DOM Level 2 CSS CSSStyleRule.CSSStyleRule    N   )cssrule)CSSStyleDeclaration)SelectorListc                       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               | _        |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)super__init__r   selectorListselectorTextstyler   	_readonly)selfr   r   r
   r   readonly	__class__s         Y/var/www/api/v1/venv_getwork_v1/lib/python3.12/site-packages/cssutils/css/cssstylerule.pyr   zCSSStyleRule.__init__   sS    " 	JAQR(N ,DDJ " -.DJ!    c                     | j                   r| j                  | j                   f}n| j                  }d| j                  j                   d|d| j                  j
                  dS )Nzcssutils.css.z(selectorText=z, style=))_namespacesr   r   __name__r   cssText)r   sts     r   __repr__zCSSStyleRule.__repr__8   sa    ##T%5%56B""Bt~~667~bV8TXT^T^TfTfSiijkkr   c                     d| j                   j                  | j                  | j                  j                  | j
                  t        |       fz  S )NzH<cssutils.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__?   sK     ''!!

""  4
	
r   c                 @    t         j                  j                  |       S )z#Return serialized property cssText.)cssutilsserdo_CSSStyleRuler    s    r   _getCssTextzCSSStyleRule._getCssTextL   s    ||++D11r   c                    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   _setCssText_splitNamespacesOffr   
namespacesAttributeError
_tokenize2_tokensupto2
_nexttoken_logr,   	_valuestr_tokenvalue
startswithxmldomInvalidModificationErrr   r   popr   _typeappendr   r   r   )r   r   r2   	tokenizerselectortokensstyletokenstrailnewSelectorListnewStyleok
bracetokenbraceorEOFtokenvaltypr   s                 r   r0   zCSSStyleRule._setCssTextP   s   ( 	G$ #66w?	..99J OOG,	**9T*J''	'E	*IIOO4t~~g7NN    IIOO5w8OO nQ/0;;C@IIOO1DNN74KKgg44  
 +d;O*d;HB'++-J
+s2		MnnW-.
 $		:T^^G=TT
 -;J+GO(		InnW-.
 #.//"3$$_5JJ/  #:#,BIIOO026..2IJ
 |#**?;'2H$$3!%
 I  		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   r2   r3   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)rR   r    s    r   <lambda>zCSSStyleRule.<lambda>   s
    T''r   zThe SelectorList of this rule.c                 f    | j                          t        ||       }|j                  r|| _        yy)aM  
        wrapper for cssutils 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)rP   r   
wellformedrR   )r   r   sls      r   _setSelectorTextzCSSStyleRule._setSelectorText   s0    " 	|E==!#D r   c                 .    | j                   j                  S rU   )rR   r   r    s    r   rV   zCSSStyleRule.<lambda>   s    T''44r   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)rP   
isinstancestrr   _stylerQ   )r   r   s     r   	_setStylezCSSStyleRule._setStyle   s7    
 	eS!-eMDK $EDKr   c                     | j                   S rU   )r_   r    s    r   rV   zCSSStyleRule.<lambda>  s    T[[r   z-(DOM) The declaration-block of this rule set.c                     | j                   S rU   )
STYLE_RULEr    s    r   rV   zCSSStyleRule.<lambda>
  s    T__r   z=The type of this rule, as defined by a CSSRule type constant.c                 .    | j                   j                  S rU   )r   rX   r    s    r   rV   zCSSStyleRule.<lambda>  s    t'8'8'C'Cr   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&   r0   propertyr   _CSSStyleRule__getNamespacesr   rS   rR   r   rZ   r   r`   r   typerX   rg   rf   __classcell__)r   s   @r   r   r      s    	 "<l
2a&F HG1 K* M',L$. 4SL
   ;E $ND
 CDJ  Y$RSEr   )rj   __all__xml.domr;   r#    r   cssstyledeclarationr   selectorlistr   CSSRuler    r   r   <module>rv      s3    ;
    4 &FT7?? FTr   