Package cssutils :: Package scripts :: Module csscombine'
[hide private]
[frames] | no frames]

Module csscombine'

source code

combines sheets referred to by @import rules in a given CSS proxy sheet
into a single new sheet.

- proxy currently is a path (no URI)
- in @import rules only relative paths do work for now but should be used
  anyway
- currently no nested @imports are resolved
- messages are send to stderr
- output to stdout.

Example::

    csscombine sheets\csscombine-proxy.css -m -t ascii -s utf-8
        1>combined.css 2>log.txt

results in log.txt::

    COMBINING sheets\csscombine-proxy.css
    USING SOURCE ENCODING: utf-8
    * PROCESSING @import sheets\csscombine-1.css
    * PROCESSING @import sheets\csscombine-2.css
    SETTING TARGET ENCODING: ascii

and combined.css::

    @charset "ascii";a{color:green}body{color:#fff;background:#000}

or without option -m::

    @charset "ascii";
    /* proxy sheet which imports sheets which should be combined \F6 \E4 \FC  */
    /* @import "csscombine-1.css"; */
    /* combined sheet 1 */
    a {
        color: green
        }
    /* @import url(csscombine-2.css); */
    /* combined sheet 2 */
    body {
        color: #fff;
        background: #000
        }

issues

- URL or file hrefs? URI should be default and therefor baseURI is needed
- no nested @imports are resolved yet
- namespace rules are not working yet!
    - @namespace must be resolved (all should be moved to top of main sheet?
      but how are different prefixes resolved???)

- maybe add a config file which is used?

Functions [hide private]
 
csscombine(proxypath, sourceencoding='css', targetencoding='utf-8', minify=True)
:returns: combined cssText :Parameters: `proxypath`: url or path to a CSSStyleSheet which imports other sheets which are then combined into one sheet `sourceencoding` = 'css': encoding of the source sheets including the proxy sheet
source code
 
main(args=None) source code

Imports: CSSSerializer, cssutils, os, sys


Function Details [hide private]

csscombine(proxypath, sourceencoding='css', targetencoding='utf-8', minify=True)

source code 

:returns: combined cssText
:Parameters:
    `proxypath`:
        url or path to a CSSStyleSheet which imports other sheets which
        are then combined into one sheet
    `sourceencoding` = 'css':
        encoding of the source sheets including the proxy sheet

    `targetencoding` = 'utf-8':
        encoding of the combined stylesheet
    `minify` = True:
        defines if the combined sheet should be minified