utilities

A few utility functions which may help when working with CSS stylesheets.

getUrls

cssutils.getUrls(sheet)

Retrieve all url(urlstring) values (in e.g. cssutils.css.CSSImportRule or cssutils.css.CSSValue objects of given sheet.

Parameters:

This function is a generator. The generated URL values exclude url( and ) and surrounding single or double quotes.

replaceUrls

cssutils.replaceUrls(sheet, replacer)

Replace all URLs in cssutils.css.CSSImportRule or cssutils.css.CSSValue objects of given sheet.

Parameters:
  • sheetcssutils.css.CSSStyleSheet which is changed
  • replacer – a function which is called with a single argument urlstring which is the current value of each url() excluding url( and ) and surrounding single or double quotes.

resolveImports

cssutils.resolveImports(sheet, target=None)

Recurcively combine all rules in given sheet into a target sheet.

Parameters:
Returns:

given target or a new cssutils.css.CSSStyleSheet object