Package cssutils :: Module util
[hide private]
[frames] | no frames]

Module util

source code

base classes and helper functions for css and stylesheets packages

Version: $Id: util.py 1429 2008-08-11 19:01:52Z cthedot $

Classes [hide private]
  Base
Base class for most CSS and StyleSheets classes
  Base2
Base class for new seq handling, used by Selector for now only
  Seq
property seq of Base2 inheriting classes, holds a list of Item objects.
  Item
an item in the seq list of classes (successor to tuple items in old seq)
  ListSeq
(EXPERIMENTAL) A base class used for list classes like css.SelectorList or stylesheets.MediaList
  _Namespaces
A dictionary like wrapper for @namespace rules used in a CSSStyleSheet.
  _SimpleNamespaces
namespaces used in objects like Selector as long as they are not connected to a CSSStyleSheet
Functions [hide private]
 
_defaultFetcher(url)
Retrieve data from url.
source code
 
_readUrl(url, fetcher=None, overrideEncoding=None, parentEncoding=None)
Read cssText from url and decode it using all relevant methods (HTTP header, BOM, @charset).
source code

Imports: codecs, ifilter, types, urllib2, xml, normalize, tokenize2, cssutils, encutils


Function Details [hide private]

_defaultFetcher(url)

source code 

Retrieve data from url. cssutils default implementation of fetch URL function.

Returns (encoding, string) or None

_readUrl(url, fetcher=None, overrideEncoding=None, parentEncoding=None)

source code 

Read cssText from url and decode it using all relevant methods (HTTP header, BOM, @charset). Returns

  • encoding used to decode text (which is needed to set encoding of stylesheet properly)
  • type of encoding (how it was retrieved, see list below)
  • decodedCssText
fetcher
see cssutils.registerFetchUrl for details
overrideEncoding
If given this encoding is used and all other encoding information is ignored (HTTP, BOM etc)
parentEncoding
Encoding of parent stylesheet (while e.g. reading @import references sheets) or document if available.

Priority or encoding information

cssutils only: 0. overrideEncoding

  1. An HTTP "charset" parameter in a "Content-Type" field (or similar parameters in other protocols)
  2. BOM and/or @charset (see below)
  3. <link charset=""> or other metadata from the linking mechanism (if any)
  4. charset of referring style sheet or document (if any)
  5. Assume UTF-8