Logo Search packages:      
Sourcecode: calibre version File versions

def cssutils::css::cssstyledeclaration::CSSStyleDeclaration::setProperty (   self,
  name,
  value = None,
  priority = u'',
  normalize = True 
)

(DOM) Set a property value and priority within this declaration
block.

:param name:
    of the CSS property to set (in W3C DOM the parameter is called
    "propertyName"), always lowercase (even if not normalized)

    If a property with this `name` is present it will be reset.
    
    cssutils also allowed `name` to be a 
    :class:`~cssutils.css.Property` object, all other
    parameter are ignored in this case

:param value:
    the new value of the property, ignored if `name` is a Property.
:param priority:
    the optional priority of the property (e.g. "important"),
    ignored if `name` is a Property.
:param normalize:
    if True (DEFAULT) `name` will be normalized (lowercase, no simple
    escapes) so "color", "COLOR" or "C\olor" will all be equivalent

:exceptions:
    - :exc:`~xml.dom.SyntaxErr`:
      Raised if the specified value has a syntax error and is
      unparsable.
    - :exc:`~xml.dom.NoModificationAllowedErr`:
      Raised if this declaration is readonly or the property is
      readonly.

Definition at line 542 of file cssstyledeclaration.py.

00542                                                                          :
        """(DOM) Set a property value and priority within this declaration
        block.

        :param name:
            of the CSS property to set (in W3C DOM the parameter is called
            "propertyName"), always lowercase (even if not normalized)

            If a property with this `name` is present it will be reset.
            
            cssutils also allowed `name` to be a 
            :class:`~cssutils.css.Property` object, all other
            parameter are ignored in this case
        
        :param value:
            the new value of the property, ignored if `name` is a Property.
        :param priority:
            the optional priority of the property (e.g. "important"),
            ignored if `name` is a Property.
        :param normalize:
            if True (DEFAULT) `name` will be normalized (lowercase, no simple
            escapes) so "color", "COLOR" or "C\olor" will all be equivalent

        :exceptions:
            - :exc:`~xml.dom.SyntaxErr`:
              Raised if the specified value has a syntax error and is
              unparsable.
            - :exc:`~xml.dom.NoModificationAllowedErr`:
              Raised if this declaration is readonly or the property is
              readonly.
        """
        self._checkReadonly()
        
        if isinstance(name, Property):
            newp = name 
            name = newp.literalname
        else:
            newp = Property(name, value, priority)
        if not newp.wellformed:
            self._log.warn(u'Invalid Property: %s: %s %s'
                    % (name, value, priority))
        else:
            nname = self._normalize(name)
            properties = self.getProperties(name, all=(not normalize))
            for property in reversed(properties):
                if normalize and property.name == nname:
                    property.cssValue = newp.cssValue.cssText
                    property.priority = newp.priority
                    break
                elif property.literalname == name:
                    property.cssValue = newp.cssValue.cssText
                    property.priority = newp.priority
                    break
            else:
                newp.parent = self
                self.seq._readonly = False
                self.seq.append(newp, 'Property')
                self.seq._readonly = True

    def item(self, index):


Generated by  Doxygen 1.6.0   Back to index