1
2 """
3 cssutils - CSS Cascading Style Sheets library for Python
4
5 Copyright (C) 2004-2007 Christof Hoeke
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
21 A Python package to parse and build CSS Cascading Style Sheets. Partly
22 implements the DOM Level 2 Stylesheets and DOM Level 2 CSS interfaces.
23
24 Please visit http://cthedot.de/cssutils/ for full details and updates.
25
26 Tested with Python 2.5 on Windows XP.
27
28
29 This package is optimized for usage of ``from cssutils import *`` which
30 import subpackages ``css`` and ``stylesheets``, the CSSParser and
31 CSSSerializer classes only.
32
33 Usage may be::
34
35 >>> from cssutils import *
36 >>> parser = CSSParser()
37 >>> sheet = parser.parseString(u'a { color: red}')
38 >>> print sheet.cssText
39
40 """
41 __all__ = ['css', 'stylesheets',
42 'CSSParser', 'CSSSerializer']
43 __docformat__ = 'restructuredtext'
44 __author__ = '$LastChangedBy: doerwalter $'
45 __date__ = '$LastChangedDate: 2007-08-02 22:58:23 +0200 (Do, 02 Aug 2007) $'
46 __version__ = '0.9.2b1 $LastChangedRevision: 160 $'
47
48
49
50 import errorhandler
51 log = errorhandler.ErrorHandler()
52
53 import util
54
55
56 import css
57 import stylesheets
58 from parse import CSSParser
59 from serialize import CSSSerializer
60
61 ser = CSSSerializer()
62
63
64 -def parse(filename, encoding=None):
65 """
66 reads file with given filename in given encoding (if given)
67 and returns CSSStyleSheet object
68 """
69 parser = CSSParser()
70 return parser.parse(filename, encoding)
71
78
79
81 """
82 sets the global serializer used by all class in cssutils
83 """
84 global ser
85 ser = serializer
86
87
88 if __name__ == '__main__':
89 print __doc__
90