| Server IP : 35.80.110.71 / Your IP : 216.73.216.52 Web Server : Apache/2.4.58 (Ubuntu) System : Linux ip-172-31-21-44 6.17.0-1019-aws #19~24.04.1-Ubuntu SMP Tue Jun 23 18:53:06 UTC 2026 x86_64 User : ubuntu ( 1000) PHP Version : 8.3.31 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /lib/python3/dist-packages/css_parser/css/__pycache__/ |
Upload File : |
�
��3etk � � � d Z ddlmZmZmZmZ ddgZdZdZddl m
Z
dd lmZ dd
l
Z
G d� de
e
j j � Zy
)aJ CSSStyleDeclaration implements DOM Level 2 CSS CSSStyleDeclaration and
extends CSS2Properties
see
http://www.w3.org/TR/1998/REC-CSS2-19980512/syndata.html#parsing-errors
Unknown properties
------------------
User agents must ignore a declaration with an unknown property.
For example, if the style sheet is::
H1 { color: red; rotation: 70minutes }
the user agent will treat this as if the style sheet had been::
H1 { color: red }
css_parser gives a message about any unknown properties but
keeps any property (if syntactically correct).
Illegal values
--------------
User agents must ignore a declaration with an illegal value. For example::
IMG { float: left } /* correct CSS2 */
IMG { float: left here } /* "here" is not a value of 'float' */
IMG { background: "red" } /* keywords cannot be quoted in CSS2 */
IMG { border-width: 3 } /* a unit must be specified for length values */
A CSS2 parser would honor the first rule and ignore the rest, as if the
style sheet had been::
IMG { float: left }
IMG { }
IMG { }
IMG { }
css_parser again will issue a message (WARNING in this case) about invalid
CSS2 property values.
TODO:
This interface is also used to provide a read-only access to the
computed values of an element. See also the ViewCSS interface.
- return computed values and not literal values
- simplify unit pairs/triples/quadruples
2px 2px 2px 2px -> 2px for border/padding...
- normalize compound properties like:
background: no-repeat left url() #fff
-> background: #fff url() no-repeat left
� )�unicode_literals�division�absolute_import�print_function�CSSStyleDeclaration�Property�restructuredtextz$Id$� )�CSS2Properties)r Nc �\ � � e Zd ZdZ d(� fd� Zd� Zd� Zd� Zd� Zd� Z d� Z
� fd �Zd
� Zd� Z
d� Zd
� Zd� Zd� Zd� Zd� Zd� Z eeed�� Zd)d�Zd� Z ed� ed�� Zd*d�Zd+d�Zd+d�Zd+d�Zd+d�Zd+d�Z d,d�Z d � Z! ed!� d"�� Z"d#� Z#d$� Z$ ee#e$d%�� Z%d&� Z& ee&d'�� Z'� xZ(S )-r aH The CSSStyleDeclaration class represents a single CSS declaration
block. This class may be used to determine the style properties
currently set in a block or to set style properties explicitly
within the block.
While an implementation may not recognize all CSS properties within
a CSS declaration block, it is expected to provide access to all
specified properties in the style sheet through the
CSSStyleDeclaration interface.
Furthermore, implementations that support a specific level of CSS
should correctly handle CSS shorthand properties for that level. For
a further discussion of shorthand properties, see the CSS2Properties
interface.
Additionally the CSS2Properties interface is implemented.
$css2propertyname
All properties defined in the CSS2Properties class are available
as direct properties of CSSStyleDeclaration with their respective
DOM name, so e.g. ``fontStyle`` for property 'font-style'.
These may be used as::
>>> style = CSSStyleDeclaration(cssText='color: red')
>>> style.color = 'green'
>>> print style.color
green
>>> del style.color
>>> print style.color
<BLANKLINE>
Format::
[Property: Value Priority?;]* [Property: Value Priority?]?
c �b �� t t | � � || _ || _ || _ || _ y)a�
:param cssText:
Shortcut, sets CSSStyleDeclaration.cssText
:param parentRule:
The CSS rule that contains this declaration block or
None if this CSSStyleDeclaration is not attached to a CSSRule.
:param readonly:
defaults to False
:param validating:
a flag defining if this sheet should be validated on change.
Defaults to None, which means defer to the parent stylesheet.
N)�superr �__init__�_parentRule�
validating�cssText� _readonly)�selfr �
parentRule�readonlyr � __class__s ��D/usr/lib/python3/dist-packages/css_parser/css/cssstyledeclaration.pyr zCSSStyleDeclaration.__init__d s0 �� � �!�4�1�3�%���$������!��� c � � t |t � r
|j }n| j |� }|| j � v S )z�Check if a property (or a property with given name) is in style.
:param name:
a string or Property, uses normalized name and not literalname
)�
isinstancer �name�
_normalize�_CSSStyleDeclaration__nnames)r �nameOrPropertyr s r �__contains__z CSSStyleDeclaration.__contains__x s8 � � �n�h�/�!�&�&�D��?�?�>�2�D��t�}�}��&�&r c � � � � fd�} |� S )zAIterator of set Property objects with different normalized names.c 3 �^ �K � �j � D ] } �j | � �� � y �w�N)r �getProperty)r r s �r �
propertiesz0CSSStyleDeclaration.__iter__.<locals>.properties� s- �� �� ��
�
��
-���&�&�t�,�,�
-�s �*-� )r r% s ` r �__iter__zCSSStyleDeclaration.__iter__� s �� � -� �|�r c �4 � t | j � � S )z]Analoguous to standard dict returns property names which are set in
this declaration.)�listr �r s r �keyszCSSStyleDeclaration.keys� s � � �D�M�M�O�$�$r c �$ � | j |� S )zzRetrieve the value of property ``CSSName`` from this declaration.
``CSSName`` will be always normalized.
��getPropertyValue�r �CSSNames r �__getitem__zCSSStyleDeclaration.__getitem__� s � �
�$�$�W�-�-r c �V � d}t |t � r|\ }}| j |||� S )z�Set value of property ``CSSName``. ``value`` may also be a tuple of
(value, priority), e.g. style['color'] = ('red', 'important')
``CSSName`` will be always normalized.
N)r �tuple�setProperty)r r0 �value�prioritys r �__setitem__zCSSStyleDeclaration.__setitem__� s1 � � ���e�U�#�#�O�E�8�������9�9r c �$ � | j |� S )z�Delete property ``CSSName`` from this declaration.
If property is not in this declaration return u'' just like
removeProperty.
``CSSName`` will be always normalized.
��removePropertyr/ s r �__delitem__zCSSStyleDeclaration.__delitem__� s � � �"�"�7�+�+r c � �� g d�}|j t j � ||v rt t | � ||� yt
d|z � �)a Prevent setting of unknown properties on CSSStyleDeclaration
which would not work anyway. For these
``CSSStyleDeclaration.setProperty`` MUST be called explicitly!
TODO:
implementation of known is not really nice, any alternative?
)�
_tokenizer�_log�_ttypes�_seq�seqr r r �valid�
wellformedr r � _profiles�_validatingzRUnknown CSS Property, ``CSSStyleDeclaration.setProperty("%s", ...)`` MUST be used.N)�extendr �_propertiesr r �__setattr__�AttributeError)r �n�v�knownr s �r rH zCSSStyleDeclaration.__setattr__� sQ �� �:�� ���^�/�/�0���:��%�t�8��A�>� � "8�:;�"<� =�
=r c �\ � d| j j �d| j d�� �d�S )Nzcss_parser.css.z (cssText=� )� separator�))r �__name__�
getCssTextr* s r �__repr__zCSSStyleDeclaration.__repr__� s'