Package cssutils :: Module serialize :: Class CSSSerializer
[hide private]
[frames] | no frames]

Class CSSSerializer

source code

object --+
         |
        CSSSerializer

Methods to serialize a CSSStylesheet and its parts

To use your own serializing method the easiest is to subclass CSS Serializer and overwrite the methods you like to customize.

Instance Methods [hide private]
 
__forbidden_in_uri_matcher(...)
match(string[, pos[, endpos]]) --> match object or None.
source code
 
__init__(self, prefs=None)
instance of Preferences
source code
 
_atkeyword(self, rule, default)
returns default or source atkeyword depending on prefs
source code
 
_indentblock(self, text, level)
indent a block like a CSSStyleDeclaration to the given level which may be higher than self._level (e.g.
source code
 
_propertyname(self, property, actual)
used by all styledeclarations to get the propertyname used dependent on prefs setting defaultPropertyName and keepAllProperties
source code
 
_linenumnbers(self, text) source code
 
_string(self, s)
returns s encloded between "..." and escaped delim charater ", escape line breaks n r and f
source code
 
_uri(self, uri)
returns uri enclosed in url() and "..." if necessary
source code
 
_valid(self, x)
checks items valid property and prefs.validOnly
source code
 
do_CSSStyleSheet(self, stylesheet)
serializes a complete CSSStyleSheet
source code
 
do_CSSComment(self, rule)
serializes CSSComment which consists only of commentText
source code
 
do_CSSCharsetRule(self, rule)
serializes CSSCharsetRule encoding: string
source code
 
do_CSSFontFaceRule(self, rule)
serializes CSSFontFaceRule
source code
 
do_CSSImportRule(self, rule)
serializes CSSImportRule
source code
 
do_CSSNamespaceRule(self, rule)
serializes CSSNamespaceRule
source code
 
do_CSSMediaRule(self, rule)
serializes CSSMediaRule
source code
 
do_CSSPageRule(self, rule)
serializes CSSPageRule
source code
 
do_CSSUnknownRule(self, rule)
serializes CSSUnknownRule anything until ";" or "{...}" + CSSComments
source code
 
do_CSSStyleRule(self, rule)
serializes CSSStyleRule
source code
 
do_css_SelectorList(self, selectorlist)
comma-separated list of Selectors
source code
 
do_css_Selector(self, selector)
a single Selector including comments
source code
 
do_css_CSSStyleDeclaration(self, style, separator=None)
Style declaration of CSSStyleRule
source code
 
do_Property(self, property)
Style declaration of CSSStyleRule
source code
 
do_Property_priority(self, priorityseq)
a Properties priority "!" S* "important"
source code
 
do_css_CSSValue(self, cssvalue)
serializes a CSSValue
source code
 
do_stylesheets_medialist(self, medialist)
comma-separated list of media, default is 'all'
source code
 
do_stylesheets_mediaquery(self, mediaquery)
a single media used in medialist
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]

__forbidden_in_uri_matcher(...)

source code 
match(string[, pos[, endpos]]) --> match object or None. Matches zero or more characters at the beginning of the string

__init__(self, prefs=None)
(Constructor)

source code 
prefs
instance of Preferences
Overrides: object.__init__

_indentblock(self, text, level)

source code 
indent a block like a CSSStyleDeclaration to the given level which may be higher than self._level (e.g. for CSSStyleDeclaration)

do_CSSCharsetRule(self, rule)

source code 

serializes CSSCharsetRule encoding: string

always @charset "encoding"; no comments or other things allowed!

do_CSSFontFaceRule(self, rule)

source code 

serializes CSSFontFaceRule

style
CSSStyleDeclaration
  • CSSComments

do_CSSImportRule(self, rule)

source code 

serializes CSSImportRule

href
string
media
optional cssutils.stylesheets.medialist.MediaList
name
optional string
  • CSSComments

do_CSSNamespaceRule(self, rule)

source code 

serializes CSSNamespaceRule

uri
string
prefix
string
  • CSSComments

do_CSSMediaRule(self, rule)

source code 

serializes CSSMediaRule

  • CSSComments

do_CSSPageRule(self, rule)

source code 

serializes CSSPageRule

selectorText
string
style
CSSStyleDeclaration
  • CSSComments

do_CSSStyleRule(self, rule)

source code 

serializes CSSStyleRule

selectorList style

  • CSSComments

do_css_Selector(self, selector)

source code 

a single Selector including comments

an element has syntax (namespaceURI, name) where namespaceURI may be:

  • cssutils._ANYNS => *|name
  • None => name
  • u'' => |name
  • any other value: => prefix|name

do_Property(self, property)

source code 

Style declaration of CSSStyleRule

Property has a seqs attribute which contains seq lists for name, a CSSvalue and a seq list for priority

do_stylesheets_medialist(self, medialist)

source code 

comma-separated list of media, default is 'all'

If "all" is in the list, every other media except "handheld" will be stripped. This is because how Opera handles CSS for PDAs.