
     h                     `    d Z dgZddlZddlZddlmZ ddlmZ  G d dej                        Z
y)zCSSFontFaceRule implements DOM Level 2 CSS CSSFontFaceRule.

From cssutils 0.9.6 additions from CSS Fonts Module Level 3 are
added http://www.w3.org/TR/css3-fonts/.
CSSFontFaceRule    N   )cssrule)CSSStyleDeclarationc                        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	d
 ed      Z e	d d      Zd Z e	ed      Z e	d       Z xZS )r   a7  
    The CSSFontFaceRule interface represents a @font-face rule in a CSS
    style sheet. The @font-face rule is used to hold a set of font
    descriptions.

    Format::

        font_face
          : FONT_FACE_SYM S*
            '{' S* declaration [ ';' S* declaration ]* '}' S*
          ;

    cssutils uses a :class:`~cssutils.css.CSSStyleDeclaration`  to
    represent the font descriptions. For validation a specific profile
    is used though were some properties have other valid values than
    when used in e.g. a :class:`~cssutils.css.CSSStyleRule`.
    c                     t         |   ||       d| _        |r|| _        || _        yt	               | _        || _        y)z
        If readonly allows setting of properties in constructor only.

        :param style:
            CSSStyleDeclaration used to hold any font descriptions
            for this CSSFontFaceRule
        )
parentRuleparentStyleSheetz
@font-faceN)super__init__
_atkeywordstyler   	_readonly)selfr   r	   r
   readonly	__class__s        \/var/www/api/v1/venv_getwork_v1/lib/python3.12/site-packages/cssutils/css/cssfontfacerule.pyr   zCSSFontFaceRule.__init__$   sE     	JAQR&DJ " -.DJ!    c                 d    d| j                   j                   d| j                  j                  dS )Nzcssutils.css.z(style=))r   __name__r   cssTextr   s    r   __repr__zCSSFontFaceRule.__repr__8   s.    t~~667wtzz?Q?Q>TTUVVr   c           
          d| j                   j                   d| j                  j                  d| j                  dt        |       dd	S )Nz<cssutils.css.z object style=z valid=z at 0xx>)r   r   r   r   valididr   s    r   __str__zCSSFontFaceRule.__str__;   se     7 78tzzGYGYF\\cdhdndncqqwxz{  yA  BC  xD  DE  F  	Fr   c                 @    t         j                  j                  |       S )z#Return serialized property cssText.)cssutilsserdo_CSSFontFaceRuler   s    r   _getCssTextzCSSFontFaceRule._getCssText>   s    ||..t44r   c                 d   t         |   |       | j                  |      }| j                  |d      }| j	                  |      | j
                  j                  k7  rH| j                  j                  d| j                  |      z  t        j                  j                         yt        |       }d}| j                  |dd      \  }}| j                  |      dk7  r0d}| j                  j                  d	| j                  |      z  |       d
di}| j!                         }	| j#                  d|	| j                  |      i       \  }
}|xr	 |
xr |d
   }| j                  |dd      \  }}| j                  |      | j	                  |      }}|dk7  r4|dk7  r/d}| j                  j                  d| j                  |      z         | j                  |      }|rd}| j                  j                  d|       d|k(  r|j%                  |       ||_        |r| j)                  |	       || _        yy)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-CSSFontFaceRule: No CSSFontFaceRule found: %s)error)r	   T)blockstartonlyseparateEnd{Fz:CSSFontFaceRule: No start { of style declaration found: %r
wellformed:)expectedseq	tokenizerproductions)blockendonlyr)   }EOFz9CSSFontFaceRule: No "}" after style declaration found: %rz(CSSFontFaceRule: Trailing content found.)token)r   _setCssText
_tokenize2
_nexttoken_type_prodsFONT_FACE_SYM_logr'   	_valuestrxmldomInvalidModificationErrr   _tokensupto2_tokenvalue_tempSeq_parseappendr   _setSeqr   )r   r   r/   attokennewStyleokbeforetokensbracenewnewseqbeforewellformedr-   styletokensbraceorEOFtokenvaltype_	nonetokenr   s                    r   r5   zCSSFontFaceRule._setCssTextB   s:    	G$OOG,	//)T2::g$++";";;IIOO?..)*gg44   +d;HB"&"3"3$D #4 #L% &#-		,.2nnW.EF  &C]]_F)-//,7	 *5 *&h >(>S->B+/+<+<$ ,= ,(K ))/:DJJ<WCczeun		,.2nnW.EF
 	2I		>i    ~""?3  +HV$%
 r   z7(DOM) The parsable textual representation of this rule.)docc                     | j                          t        |t              rt        ||       | _        y| |_        || _        y)zK
        :param style:
            a CSSStyleDeclaration or string
        )r   r	   N)_checkReadonly
isinstancestrr   _style_parentRule)r   r   s     r   	_setStylezCSSFontFaceRule._setStyle   s7    
 	eS!-eMDK $EDKr   c                     | j                   S N)rX   r   s    r   <lambda>zCSSFontFaceRule.<lambda>   s    T[[r   z[(DOM) The declaration-block of this rule set, a :class:`~cssutils.css.CSSStyleDeclaration`.c                     | j                   S r\   )FONT_FACE_RULEr   s    r   r]   zCSSFontFaceRule.<lambda>   s
    T((r   z=The type of this rule, as defined by a CSSRule type constant.c                     ddg}| j                   j                  d      D ],  }|j                  s y	 |j                  |j                         . t        |       S # t
        $ r Y Fw xY w)Nzfont-familysrcT)allF)r   getPropertiesr   removename
ValueErrorbool)r   neededps      r   	_getValidzCSSFontFaceRule._getValid   sj    '))d)3A77aff%	 4 <  s   A	A('A(z`CSSFontFace is valid if properties `font-family` and `src` are set and all properties are valid.c                      y)NT r   s    r   r]   zCSSFontFaceRule.<lambda>   s    tr   )NNNF)r   
__module____qualname____doc__r   r   r    r%   r5   propertyr   rZ   r   typerj   r   r+   __classcell__)r   s   @r   r   r      s    & LQ"(WF5Q&f HG
   8E (ND
	  :E +,Jr   )ro   __all__xml.domr=   r"    r   cssstyledeclarationr   CSSRuler   rl   r   r   <module>rx      s2    
    4t-goo t-r   