The beginnings of a CSS library for Python
Python
Latest commit 5ebfba4 Jul 15, 2014 @jtauber PEP8 compliance
Failed to load latest commit information.
cassidy PEP8 compliance Jul 15, 2014
css3syntax PEP8 compliance Jul 15, 2014
.env added (optional) auto_env Jul 31, 2013
.gitignore added ply files to gitignore Jul 31, 2013
LICENSE
README.md Update README.md Aug 21, 2012
css3_selectors_test.py
requirements.txt
selectors_test.py implemented support and tests for special id and class selector syntax Jul 9, 2012
tox.ini PEP8 compliance Jul 15, 2014

README.md

Cassidy

The beginnings of a CSS library for Python.

At present it implements a decent part of the CSS Selectors spec and the draft CSS3-Syntax spec.

Here's an example of the selectors implementation:

>>> import html5lib
>>> from cassidy.selectors import selector
>>> doc = html5lib.parse("<div><p id='foo'>hello</p><p class='bar'>world</p></div>")
>>> for element in selector("p").find(doc):
...     print element.toxml()
... 
<p id="foo">hello</p>
<p class="bar">world</p>

>>> for element in selector("div .bar").find(doc):
...     print element.toxml()
... 
<p class="bar">world</p>

The css3syntax directory is a work-in-progress implementation of CSS3-Syntax draft spec. css3_selectors_test.py is a test-driven implementation of selectors using css3syntax for tokenization and parsing rather than PLY as cassidy.selectors does. The same actual selector implementation is used, though. This version will likely replace the PLY-based version eventually.

Besides improving all the above, the plan next is to implement the property model and then value calculation and inheritance.