ANN: cssutils
christof hoeke
csad7@yahoo.com
Sun, 28 Dec 2003 17:24:40 +0100
cssutils contains classes to parse, build (and later normalize) CSS
Cascading Style Sheets in Python.
the most useful feature at the moment might be a pretty printer but you
can also build a new Stylesheet from scratch
example
-------
from cssutils.cssparser import CSSParser
c = CSSParser()
c.parseString('body { color :red }') # or c.parse('filename.css')
c.pprint()
# ---the output
body {
color: red;
}
from cssutils.cssbuilder import *
s = Stylesheet()
r = Rule('body')
d = Declaration('color', 'red')
r.addDeclaration(d)
mr = AtMediaRule('@media print')
r2 = Rule('body')
r2.addDeclaration(Declaration('color', '#000'))
mr.addRule(r2)
s.addComment('/* basic styles */')
s.addRule(r)
s.addRule(mr)
s.pprint(2)
# --- the output
/* basic styles */
body {
color: red;
}
@media print {
body {
color: #000;
}
}
requirements
------------
you need Python 2.3, tested with Python 2.3.3 on Windows only
feedback
--------
i would very much appreciate any feedback
- bug reports
- feature requests
- also coding improvements as this is one of my first Python projects
Download
--------
the current version is 0.23, get cssutils at http://cthedot.de/cssutils
thanks
chris