0.9.8 deprecates or better removes support for css.Value, css.ValueList, css.PrimitiveValue and subclasses. They are all replaced by css.PropertyValue, which contains a list of css.Value objects. See docs for these for details.
Changes in more detail:
This actually is not an incompatible change (but was during some alpha releases):
xml.dom.DOMExceptions raised do now contain infos about the position where the exception occured.
You may access these infos with msg, line, col = e.args[0], e.line, e.col. str(e) does work as expected and contains the error message only.
moved cssutils.css.cssproperties.cssvalues to cssutils.profiles.css2
cssutils.utils.Base and cssutils.utils.Base2 have been changed and will be removed in favor of new cssutils.utils.NewBase. These are all internal helper classes and should not be used in client code anyway but ye be warned...
cssutils 0.9.5 introduced some minor incompatible API changes. Reason for most changes is that for most cases the new default behaviour makes more sense.
Upto 0.9.5rc1 any sheet resulting from parsing via any parse* function or CSSParser(raiseExceptions=False) (which is also the default) resulted in the library simply logging any later exceptions and not raising them. 0.9.5rc2 fixes this. Until now the global setting of cssutils.log.raiseExceptions=True (the default) was overwritten with the value of the CSSParser raiseExceptions setting which is normally False any time a cssutils.parse* function or CSSParser.parse* method was used. So
until 0.9.5rc1:
>>> # does not raise during parse
>>> s = cssutils.parseString('$') # empty but CSSStyleSheet object
>>> # does not raise either but should:
>>> s.cssText = '$'
ERROR CSSStyleRule: No start { of style declaration found: u'$' [1:2: ]
# [...]
from 0.9.5rc2:
>>> # still does not raise during parse
>>> s = cssutils.parseString('$') # empty but CSSStyleSheet object
>>> # working with the actual DOM does raise now though
>>> s.cssText = '$'
# [...] traceback
xml.dom.SyntaxErr: CSSStyleRule: No start { of style declaration found: u'$' [1:1: $]
To use the old but false behaviour add the following line at the start to your program:
>>> cssutils.log.raiseExceptions = False # normally True
This should only be done in specific cases as normal raising of exceptions in methods or functions with the CSS DOM is the expected behaviour.
parse() is DEPRECATED in favour of parseFile(). Both methods are still available but parse will be removed for cssutils 1.0.
All parse* functions (or CSSParser.parse* methods) do raise errors from 0.9.5final.
Iterating over css.CSSStyleDelcaration now yields effective properties only and not all properties set in the declaration. To retrieve all properties use CSSStyleDeclaration.getProperties(all=True).
iterating over a CSSStyleDeclaration with cssText='color: red; c\olor: green'
Property.name until now hold the literal value (e.g. c\olor of a properties name. Now it holds the normalized name. Property.normalname is therefor DEPRECATED. To access the unnormalized (literal) name use the new readonly property Property.literalname.
p = Property(ur'c\olor', 'red')
p.name == ur'c\olor'
p.normalname == ur'color' # now DEPRECATED
p.name == ur'color'
p.literalname == ur'c\olor'
The value of Property.priority (or CSSStyleDeclatation.getPropertyPriority(p)) is now important without a leading ! as defined in the CSS specs.
(Property._normalpriority has been removed, the normalized value that was available here is now in Property.priority. The literal priority value is available in Property.literalproperty now (analog to Property.literalname). All these values probably should not be used by client code anyway but may be helpful when using CSS hacks.)
p = Property(u'color', 'red', u'!IMPOR\\TANT')
p.priority == u'!IMPOR\\TANT'
p._normalpriority == u'!important' # now REMOVED!
p.priority == u'important'
p.literalpriority == u'IMPOR\\TANT'
Since 0.9.5b1 replaceUrls has been moved from a method of CSSStyleSheet to a utility function in cssutils directly.
def replacer(url):
"returns new URL"
sheet = cssutils.parseUrl('http://example.com/test.css')
sheet.replaceUrls(replacer)
cssutils.replaceUrls(sheet, replacer)