Package cssutils :: Module parse' :: Class CSSParser
[hide private]
[frames] | no frames]

Class CSSParser

source code

object --+
         |
        CSSParser

parses a CSS StyleSheet string or file and returns a DOM Level 2 CSS StyleSheet object

Usage:

parser = CSSParser()
sheet = p.parse('test1.css', 'ascii')

print sheet.cssText
Instance Methods [hide private]
 
__init__(self, log=None, loglevel=None, raiseExceptions=False)
logging object
source code
 
parseString(self, cssText, encoding=None, href=None, media=None, title=None)
Return parsed CSSStyleSheet from given string cssText.
source code
 
parse(self, filename, encoding=None, href=None, media=None, title=None)
Retrieve and return a CSSStyleSheet from given filename.
source code
 
parseURL(self, url, encoding=None, href=None, media=None, title=None)
Retrieve and return a CSSStyleSheet from given url.
source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, log=None, loglevel=None, raiseExceptions=False)
(Constructor)

source code 
log
logging object
loglevel
logging loglevel
raiseExceptions
if log should simple log (default) or raise errors
Overrides: object.__init__

parseString(self, cssText, encoding=None, href=None, media=None, title=None)

source code 

Return parsed CSSStyleSheet from given string cssText.

cssText
CSS string to parse
encoding
encoding of the CSS string. if None the encoding will be read from a @charset rule. If there is none, the parser will fall back to UTF-8. If cssText is a unicode string encoding will be ignored.
href
The href attribute to assign to the parsed style sheet. Used to resolve other urls in the parsed sheet like @import hrefs
media
The media attribute to assign to the parsed style sheet (may be a MediaList, list or a string)
title
The title attribute to assign to the parsed style sheet

parse(self, filename, encoding=None, href=None, media=None, title=None)

source code 

Retrieve and return a CSSStyleSheet from given filename.

filename
of the CSS file to parse
encoding
of the CSS file, None defaults to encoding detection from a @charset rule

for other parameters see parseString

parseURL(self, url, encoding=None, href=None, media=None, title=None)

source code 

Retrieve and return a CSSStyleSheet from given url.

url
url of the CSS file to parse
encoding
if given overrides detected HTTP encoding

for other parameters see parseString