Package cssutils |
[hide private]
[frames] | no frames]

# Package cssutils

source code

cssutils - CSS Cascading Style Sheets library for Python

> Copyright (C) 2004-2007 Christof Hoeke

> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

> This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

> You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

A Python package to parse and build CSS Cascading Style Sheets. Partly implements the DOM Level 2 Stylesheets and DOM Level 2 CSS interfaces.

Please visit http://cthedot.de/cssutils/ for full details and updates.

Tested with Python 2.5 on Windows XP.

This package is optimized for usage of `from cssutils import *` which import subpackages `css` and `stylesheets`, the CSSParser and CSSSerializer classes only.

Usage may be:

    >>> from cssutils import *
    >>> parser = CSSParser()
    >>> sheet = parser.parseString(u'a { color: red}')
    >>> print sheet.cssText

Version: 0.9.2b1 $LastChangedRevision: 177 $

Date: $LastChangedDate: 2007-08-06 18:33:45 +0200 (Mo, 06 Aug 2007) $

Author: $LastChangedBy: doerwalter $

Submodules | [hide private]
cssutils.css: Document Object Model Level 2 CSS http://www.w3.org/TR/2000/PR-DOM-Level-2-Style-20000927/css.html cssutils.css.csscharsetrule: CSSCharsetRule implements DOM Level 2 CSS CSSCharsetRule. cssutils.css.csscomment: CSSComment is not defined in DOM Level 2 at all but a cssutils defined class. cssutils.css.cssimportrule: CSSImportRule implements DOM Level 2 CSS CSSImportRule. cssutils.css.cssmediarule: CSSMediaRule implements DOM Level 2 CSS CSSMediaRule. cssutils.css.cssnamespacerule: CSSNamespaceRule currently implements http://www.w3.org/TR/2006/WD-css3-namespace-20060828/ cssutils.css.csspagerule: CSSPageRule implements DOM Level 2 CSS CSSPageRule. cssutils.css.cssproperties: CSS2Properties (partly!) implements DOM Level 2 CSS CSS2Properties used by CSSStyleDeclaration cssutils.css.cssrule: CSSRule implements DOM Level 2 CSS CSSRule. cssutils.css.cssrulelist: CSSRuleList implements DOM Level 2 CSS CSSRuleList. cssutils.css.cssstyledeclaration: CSSStyleDeclaration implements DOM Level 2 CSS CSSStyleDeclaration and inherits CSS2Properties cssutils.css.cssstylerule: CSSStyleRule implements DOM Level 2 CSS CSSStyleRule. cssutils.css.cssstylesheet: CSSStyleSheet implements DOM Level 2 CSS CSSStyleSheet. cssutils.css.cssunknownrule: CSSUnknownRule implements DOM Level 2 CSS CSSUnknownRule. cssutils.css.cssvalue: CSSValue related classes cssutils.css.property: Property is a single CSS property in a CSSStyleDeclaration cssutils.css.selector: Selector is a single Selector of a CSSStyleRule SelectorList. cssutils.css.selectorlist: SelectorList is a list of CSS Selector objects. cssutils.domimplementationcss: not used yet cssutils.errorhandler: cssutils ErrorHandler cssutils.parse': a validating CSSParser cssutils.scripts cssutils.scripts.csscapture: Retrieve all CSS stylesheets including embedded for a given URL. cssutils.scripts.cssparse: utility scripts installed as Python scripts cssutils.serialize: serializer classes for CSS classes cssutils.stylesheets: Document Object Model Level 2 Style Sheets http://www.w3.org/TR/2000/PR-DOM-Level-2-Style-20000927/stylesheets.html cssutils.stylesheets.medialist: MediaList implements DOM Level 2 Style Sheets MediaList. cssutils.stylesheets.stylesheet: StyleSheet implements DOM Level 2 Style Sheets StyleSheet. cssutils.stylesheets.stylesheetlist: StyleSheetList implements DOM Level 2 Style Sheets StyleSheetList. cssutils.tests: cssutils unittests cssutils.tests.basetest: base class for all tests cssutils.tests.encutils: tests for encutils.py cssutils.tests.test_csscharsetrule: testcases for cssutils.css.CSSCharsetRule cssutils.tests.test_csscomment: testcases for cssutils.css.CSSComment cssutils.tests.test_cssimportrule: testcases for cssutils.css.CSSImportRule cssutils.tests.test_cssmediarule: testcases for cssutils.css.CSSMediaRule cssutils.tests.test_cssnamespacerule: testcases for cssutils.css.CSSImportRule cssutils.tests.test_csspagerule: testcases for cssutils.css.CSSPageRule cssutils.tests.test_cssprimitivevalue cssutils.tests.test_cssproperties: Testcases for cssutils.css.cssproperties. cssutils.tests.test_cssrule: testcases for cssutils.css.CSSRule cssutils.tests.test_cssrulelist: testcases for cssutils.css.CSSRuleList cssutils.tests.test_cssstyledeclaration: Testcases for cssutils.css.cssstyledelaration.CSSStyleDeclaration. cssutils.tests.test_cssstylerule: testcases for cssutils.css.CSSStyleRuleTestCase cssutils.tests.test_cssstylesheet: tests for css.CSSStyleSheet cssutils.tests.test_cssunknownrule: testcases for cssutils.css.CSSUnkownRule cssutils.tests.test_cssutils: testcases for cssutils.css.CSSCharsetRule cssutils.tests.test_cssutilsimport: testcases for cssutils.css.CSSCharsetRule cssutils.tests.test_cssvalue: Testcases for cssutils.css.CSSValue and CSSPrimitiveValue. cssutils.tests.test_escapes: tests for escaping cssutils.tests.test_medialist: testcases for cssutils.stylesheets.MediaList cssutils.tests.test_parse: tests for parsing which does not raise Exceptions normally cssutils.tests.test_property: Testcases for cssutils.css.property._Property. cssutils.tests.test_selector: Testcases for cssutils.css.selector.Selector. cssutils.tests.test_selectorlist: Testcases for cssutils.css.selectorlist.SelectorList. cssutils.tests.test_serialize: testcases for cssutils.CSSSerializer cssutils.tests.test_token: testcases for cssutils.token.Token cssutils.tests.test_tokenize: testcases for cssutils.tokenize.Tokenizer cssutils.tests.test_util: testcases for cssutils.util cssutils.token: Classes used by Tokenizer and Parser cssutils.tokenize: CSS Tokenizer cssutils.util: base classes for css and stylesheets packages

Classes | [hide private]
| CSSParser parses a CSS StyleSheet string or file and returns a DOM Level 2 CSS StyleSheet object
| CSSSerializer Methods to serialize a CSSStylesheet and its parts

Functions | [hide private]
parse(filename, encoding=None, href=None, media=None) reads file with given filename in given encoding (if given) and returns CSSStyleSheet object | source code
parseString(cssText, href=None, media=None) parses given string and returns CSSStyleSheet object | source code
setSerializer(serializer) sets the global serializer used by all class in cssutils | source code

Variables | [hide private]
| log = `errorhandler.ErrorHandler()`
| ser = `CSSSerializer()`

Imports: cssutils.tokenize, cssutils.errorhandler, cssutils.serialize, cssutils.token, cssutils.util