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

# Module csscombine'

source code

Combine 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: css
    * PROCESSING @import sheets\csscombine-1.css
    * PROCESSING @import sheets\csscombine-2.css
    INFO    Nested @imports are not combined: @import "1.css";
    SETTING TARGET ENCODING: ascii

and combined.css:

    @charset "ascii";@import"1.css";@namespaces2"uri";s2|sheet-1{top:1px}s2|sheet-2{top:2px}proxy{top:3px}

or without option -m:

    @charset "ascii";
    @import "1.css";
    @namespace s2 "uri";
    @namespace other "other";
    /* proxy sheet were imported sheets should be combined */
    /* non-ascii chars: \F6 \E4 \FC  */
    /* @import "csscombine-1.css"; */
    /* combined sheet 1 */
    s2|sheet-1 {
        top: 1px
        }
    /* @import url(csscombine-2.css); */
    /* combined sheet 2 */
    s2|sheet-2 {
        top: 2px
        }
    proxy {
        top: 3px
        }

TODO
  - URL or file hrefs? URI should be default
  - no nested @imports are resolved yet
  - maybe add a config file which is used?

Version: $Id: csscombine.py 1332 2008-07-09 13:12:56Z cthedot $

Functions | [hide private]
csscombine(proxypath, sourceencoding=None, targetencoding=`'``utf-8``'`, minify=True) Combine sheets referred to by @import rules in given CSS proxy sheet into a single new sheet. | source code
main(args=None) | source code

Imports: optparse, sys

Function Details | [hide private]

### csscombine(proxypath, sourceencoding=None, targetencoding=`'``utf-8``'`, minify=True) | source code
Combine sheets referred to by @import rules in given CSS proxy sheet into a single new sheet. Parameters: `proxypath` - url or path to a CSSStyleSheet which imports other sheets which are then combined into one sheet `sourceencoding` - encoding of the source sheets including the proxy sheet `targetencoding` - encoding of the combined stylesheet, default 'utf-8' `minify` - defines if the combined sheet should be minified, default True Returns: combined cssText, normal or minified