
    ]hI                         d dl mZmZmZmZ d dl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$                  j&                        Zy)    )unicode_literalsdivisionabsolute_importprint_functionN   )PropertyValue)
DeprecatedPropertyrestructuredtextz$Id$   c                       e Zd ZdZ	 	 d$ fd	Zd Zd Zd Zd Zd Z	 e
ee	d	      Zd
 Z e
d ed      Z e
d d      Zd Z e
d ed      Zd Zd Z e
eed      Zd Z e
d ed      Z e
d d      Zd Z e
d ed      Zd Z e
ed      Z ed       d!        Z ed       d"        Z e
eed#      Z xZS )%r
   a<  A CSS property in a StyleDeclaration of a CSSStyleRule (css_parser).

    Format::

        property = name
          : IDENT S*
          ;

        expr = value
          : term [ operator term ]*
          ;
        term
          : unary_operator?
            [ NUMBER S* | PERCENTAGE S* | LENGTH S* | EMS S* | EXS S* |
              ANGLE S* | TIME S* | FREQ S* | function ]
          | STRING S* | IDENT S* | URI S* | hexcolor
          ;
        function
          : FUNCTION S* expr ')' S*
          ;
        /*
         * There is a constraint on the color that it must
         * have either 3 or 6 hex-digits (i.e., [0-9a-fA-F])
         * after the "#"; e.g., "#000" is OK, but "#abcd" is not.
         */
        hexcolor
          : HASH S*
          ;

        prio
          : IMPORTANT_SYM S*
          ;

    c                    t         t        |           g dg g| _        d| _        || _        || _        d| _        d| _        d| _	        t        |       | j                  d<   |r|| _        || _        d| _        d| _        |r|| _        yy)a  
        :param name:
            a property name string (will be normalized)
        :param value:
            a property value string
        :param priority:
            an optional priority string which currently must be u'',
            u'!important' or u'important'
        :param _mediaQuery:
            if ``True`` value is optional (used by MediaQuery)
        :param parent:
            the parent object, normally a
            :class:`css_parser.css.CSSStyleDeclaration`
        NF parentr   )superr
   __init__seqs
wellformed_mediaQueryr   _Property__nametoken_name_literalnamer   namepropertyValue	_priority_literalprioritypriority)selfr   valuer   r   r   	__class__s         /home/pod-website-builder.sw7ft.com/pod-website-builder/website-analyzer/venv/lib/python3.12/site-packages/css_parser/css/property.pyr   zProperty.__init__6   s      	h&(rN	&
$D1		!DI!&D "$DM     c           	          d| j                   j                  d| j                  d| j                  j                  d| j
                  d	S )Nzcss_parser.css.z(name=z, value=z, priority=))r!   __name__literalnamer   cssTextr   r   s    r"   __repr__zProperty.__repr__Y   s8    NN##&&MM	 	r#   c           
          d| j                   j                  | j                   j                  | j                  | j                  j
                  | j                  | j                  t        |       fz  S )Nz<<%s.%s object name=%r value=%r priority=%r valid=%r at 0x%x>)	r!   
__module__r&   r   r   r(   r   valididr)   s    r"   __str__zProperty.__str__`   sY    M..++..))))$$,,--**T( 	r#   c                 N    	 | j                   j                  S # t        $ r Y yw xY w)z%Return True if validation is enabled.T)r   
validatingAttributeErrorr)   s    r"   _isValidatingzProperty._isValidatingj   s)    	;;))) 		s    	$$c                 @    t         j                  j                  |       S )z#Return serialized property cssText.)
css_parserserdo_Propertyr)   s    r"   _getCssTextzProperty._getCssTextr   s    ~~))$//r#   c                    | j                  |      }| j                  |d      }|rd}| j                  |d      }| j                  |d      }| j                  r|s|| _        d| _        d| _        y|j                         }| j                  |      dk7  r1d}| j                  j                  d| j                  |      z  |       n2|s0d}| j                  j                  d	| j                  |      z  |       |r9| j                  |d
         dk(  rR|j                  d|j                  d
             n0d}| j                  j                  d| j                  |      z  |       |r>d| _        || _        || _        || _        | j                         r| j                          yyy| j                  j                  d	| j                  |      z         y)a  
        :exceptions:
            - :exc:`~xml.dom.SyntaxErr`:
              Raised if the specified CSS string value has a syntax error and
              is unparsable.
            - :exc:`~xml.dom.NoModificationAllowedErr`:
              Raised if the rule is readonly.
        T)propertynameendonly)propertyvalueendonly)propertypriorityendonlyN:Fz%Property: No ":" after name found: %sz$Property: No property name found: %s!r   z%Property: No property value found: %s)
_tokenize2_tokensupto2r   r   r   r   pop_tokenvalue_logerror	_valuestrinsertr   r3   validate)r   r(   	tokenizer
nametokensr   valuetokensprioritytokens
colontokens           r"   _setCssTextzProperty._setCssTextv   s    OOG,	&&yd&K
J++IAE , GK!..yGK / MN &	%)" $ $)J
+s2"
		 G $w 7!89CE"
		 F $w 7!89CE ##KO4;"))![__R-@A"
		 G $w 7!89CE "&&	%0" . %%'MMO (  IIOOB NN734 5r#   z"A parsable textual representation.)fgetfsetdocc                 p    dddd fd	}g } j                  d| j                  |      d|i      \  }}|xr d   }t        |t              r|d	   }| _        nd}d
   s1d} j
                  j                  d j                  |      z  |       |rd _        d
    _	         j                   j                         _        | j                  d	<    j                         rE j                  t        j                  j                   vr j
                  j#                  d|d       yyd _        y)z
        :exceptions:
            - :exc:`~xml.dom.SyntaxErr`:
              Raised if the specified name has a syntax error and is
              unparsable.
        NT)r'   r   c                     d| k(  r7j                  |      j                         d<   |j                  d          ydd<   j                  j	                  d|       | S )Nr   r'   EOFFr   Property: Unexpected ident.)rC   lowerappendrD   rE   )expectedseqtokenrI   newr   s       r"   _identz!Property._setName.<locals>._ident   s_    !%)%5%5e%<%B%B%DM"

3}-.$)L!		 =uEr#   r   IDENTrX   rY   rI   productionsr   r   r'   FzProperty: No name found: %s)rZ   z Property: Unknown Property name.rZ   
neverraiseN)_parser@   
isinstancelistr   rD   rE   rF   r   r   
_normalizer   r   r3   r5   profile
knownNameswarn)r   r   r\   newseqr   rX   rZ   r[   s   `      @r"   _setNamezProperty._setName   sH    #!#		  #{{F/559__T5J8?7H  +  J
H  5C$5
 dD!GE$DE=!JIIOO9 NN4018=  ? "DO #M 2D):):;DJ!DIIaL !!#

*:L:L:W:W(W		A%*t  =  $DOr#   c                     | j                   S rb   )r   r)   s    r"   <lambda>zProperty.<lambda>   s
     r#   zName of this property.)rQ   c                     | j                   S rb   )r   r)   s    r"   rm   zProperty.<lambda>   s    (9(9 r#   z7Readonly literal (not normalized) name of this propertyc                     | j                   r|st        |       | j                  d<   y|| j                  d   _        | j                  xr | j                  d   j                  | _        y)a  
        See css.PropertyValue

        :exceptions:
        - :exc:`~xml.dom.SyntaxErr`:
          Raised if the specified CSS string value has a syntax error
          (according to the attached property) or is unparsable.
        - :exc:`~xml.dom.InvalidModificationErr`:
          TODO: Raised if the specified CSS string value represents a different
          type of values than the values allowed by the CSS property.
        r   r   N)r   r   r   r(   r   r   r(   s     r"   _setPropertyValuezProperty._setPropertyValue   sO     G(5DIIaL#*DIIaL "ooI$))A,2I2IDOr#   c                      | j                   d   S )Nr   )r   r)   s    r"   rm   zProperty.<lambda>  s    $))A, r#   z-(css_parser) PropertyValue object of propertyc                 H    | j                   r| j                   j                  S y)Nr   )r   r    r)   s    r"   	_getValuezProperty._getValue  s     %%+++r#   c                 &    | j                  |       y rb   rq   )r   r    s     r"   	_setValuezProperty._setValue  s    u%r#   z3The textual value of this Properties propertyValue.c                      j                   r,d _        d _        |r j                  j	                  d       yt        |t              rd j                  |      k(  rd|z  }dddd fd	}d fd		}g } j                  d
| j                  |      ||d      \  }}|xr d   }|r4d   s/d} j                  j                  d j                  |      z         |r j                  xr | _        d    _         j                   j                         _        | j                  d<    j                  dvr) j                  j	                  d j                  z         yyy)a  
        priority
            a string, currently either u'', u'!important' or u'important'

        Format::

            prio
              : IMPORTANT_SYM S*
              ;

            "!"{w}"important"   {return IMPORTANT_SYM;}

        :exceptions:
            - :exc:`~xml.dom.SyntaxErr`:
              Raised if the specified priority has a syntax error and is
              unparsable.
              In this case a priority not equal to None, "" or "!{w}important".
              As CSSOM defines CSSStyleDeclaration.getPropertyPriority resulting
              in u'important' this value is also allowed to set a Properties
              priority
        r   z0Property: No priority in a MediaQuery - ignored.N	importantz!%sT)literalpriorityr   c                     j                  |      }d| cxk(  r|k(  rn n|j                  |       ydd<   j                  j                  d|       | S )Nr?   ry   Fr   zProperty: Unexpected char.rC   rW   rD   rE   rX   rY   rZ   rI   valr[   r   s        r"   _charz$Property._setPriority.<locals>._charD  sP    ""5)Ch%#%

3"$)L!		 <eDr#   c                     j                  |      }d| k(  r|d<   |j                  |       ydd<   j                  j                  d|       | S )Nry   rz   rT   Fr   rU   r|   r}   s        r"   r\   z%Property._setPriority.<locals>._identO  sV    ""5)Ch&),%&

3$)L!		 =uEr#   r?   )CHARr]   r^   r   rz   FzProperty: Invalid priority: %s   r   ry   z#Property: No CSS priority value: %srb   )r   r   r   rD   rE   rd   string_typerf   rc   r@   inforF   r   rz   r   )r   r   r   r\   rj   r   rX   r[   s   `      @r"   _setPriorityzProperty._setPriority  sv   , DN$&D!		 !+ ,h,PX@Y1Yx'H #%!#		 
	  #{{C/559__X5N@EAG8I  +  J
H
  5C$5
 C 12JIINN;>>(34 5 "oo<*DO$'(9$:D!!__T-A-ABDN!DIIaL~~%66		 E $!/ 0 7 r#   c                     | j                   S rb   )r   r)   s    r"   rm   zProperty.<lambda>s  s
    T^^ r#   zPriority of this property.c                     | j                   S rb   )r   r)   s    r"   rm   zProperty.<lambda>v  s    D,A,A r#   z;Readonly literal (not normalized) priority of this propertyc                     || _         y rb   _parent)r   r   s     r"   
_setParentzProperty._setParenty  s	    r#   c                     | j                   S rb   r   r)   s    r"   rm   zProperty.<lambda>|  s
    4<< r#   zAThe Parent Node (normally a CSSStyledeclaration) of this Propertyc           	         d}d}	 | j                   j                  }|5|j                  |j                  k(  rt        j
                  j                  g}	 | j                  r| j                  rt	 | j                  t        j
                  j                  v rLt        j
                  j                  | j                  | j                  |      \  }}}|sH| j                  j                  ddj                  |      d| j                  | j                  d       n|r~|s||s*dj                  t        j
                  j                         }n|}| j                  j#                  d|d	dj                  |      d
| j                  d| j                  d       d}nI|rG| j                  j%                  ddj                  |      d
| j                  | j                  d       | j&                  dvrd}|S # t        $ r Y w xY w)a		  Validate value against `profiles` which are checked dynamically.
        properties in e.g. @font-face rules are checked against
        ``css_parser.profile.CSS3_FONT_FACE`` only.

        For each of the following cases a message is reported:

        - INVALID (so the property is known but not valid)
            ``ERROR    Property: Invalid value for "{PROFILE-1[/PROFILE-2...]"
            property: ...``

        - VALID but not in given profiles or defaultProfiles
            ``WARNING    Property: Not valid for profile "{PROFILE-X}" but valid
            "{PROFILE-Y}" property: ...``

        - VALID in current profile
            ``DEBUG    Found valid "{PROFILE-1[/PROFILE-2...]" property...``

        - UNKNOWN property
            ``WARNING    Unknown Property name...`` is issued

        so for example::

            css_parser.log.setLevel(logging.DEBUG)
            parser = css_parser.CSSParser()
            s = parser.parseString('''body {
                unknown-property: x;
                color: 4;
                color: rgba(1,2,3,4);
                color: red
            }''')

            # Log output:

            WARNING Property: Unknown Property name. [2:9: unknown-property]
            ERROR   Property: Invalid value for "CSS Color Module Level 3/CSS Level 2.1" property: 4 [3:9: color]
            DEBUG   Property: Found valid "CSS Color Module Level 3" value: rgba(1, 2, 3, 4) [4:9: color]
            DEBUG   Property: Found valid "CSS Level 2.1" value: red [5:9: color]


        and when setting an explicit default profile::

            css_parser.profile.defaultProfiles = css_parser.profile.CSS_LEVEL_2
            s = parser.parseString('''body {
                unknown-property: x;
                color: 4;
                color: rgba(1,2,3,4);
                color: red
            }''')

            # Log output:

            WARNING Property: Unknown Property name. [2:9: unknown-property]
            ERROR   Property: Invalid value for "CSS Color Module Level 3/CSS Level 2.1" property: 4 [3:9: color]
            WARNING Property: Not valid for profile "CSS Level 2.1" but valid
            "CSS Color Module Level 3" value: rgba(1, 2, 3, 4)  [4:9: color]
            DEBUG   Property: Found valid "CSS Level 2.1" value: red [5:9: color]
        FNzProperty: Invalid value for "/z" property: Tr`   z!Property: Not valid for profile "z" but valid "z	" value:  zProperty: Found valid "r   )r   
parentRuletypeFONT_FACE_RULEr5   rg   CSS3_FONT_FACEr2   r   r    rh   validateWithProfilerD   rE   joinr   defaultProfilesri   debugr   )r   r-   profilesrulematchingvalidprofilesnotvalidprofiless          r"   rH   zProperty.validate  s   t 	C;;))D 99 3 33 * 2 2 A ABH 99 yyJ..999 &&::499djjRZ[ /x IIOO'*xx'>

%L +/*:*:/3	 $ 5 8#+.88J4F4F4V4V+W(+3(IINN&68O&*jj$2 *.)9)9.2 # 4 "EIIOO'*xx'>

%L*.*:*:/3 $ 5
 >>!22Ei  		s   G3 3	H ?H zCCheck if value of this property is valid in the properties context.z'Use ``property.propertyValue`` instead.c                     | j                   S rb   )r   r)   s    r"   _getCSSValuezProperty._getCSSValue  s    !!!r#   c                 &    | j                  |       y rb   rv   rp   s     r"   _setCSSValuezProperty._setCSSValue  s    w'r#   z4(DEPRECATED) Use ``property.propertyValue`` instead.)NNr   FN) r&   r,   __qualname____doc__r   r*   r/   r3   r8   rN   propertyr(   rk   r   r'   rq   r   rt   rw   r    r   r   rz   r   r   rH   r-   r	   r   r   cssValue__classcell__)r!   s   @r"   r
   r
      sZ   !F 8:+/!%F0<5| Kk?AG<$| +X02D 9 23KJ$ 6.!PRM& Y	NPER0h 3\8:H A#`bO /!"Ftl X $@ AE 9:" ;" 9:( ;( lRTHr#   )
__future__r   r   r   r   r5   r    r   css_parser.helperr	   __all____docformat____version__sysversion_infostrr   
basestringutilBaser
    r#   r"   <module>r      sb    R R    ( A," 
A!KKpTz## pTr#   