Taschenmesser is a toolbelt containing builders for SCons. It helps you getting stuff done.
It contains builders for:
- SVG optimization (Scour-based)
- SVG2PNG conversion (Inkscape-based)
- Amazon Web Service (S3 Delta Uploads etc)
- Google Closure (JavaScript optimization)
- File utils (GZip etc)
License: Apache 2.0
Taschenmesser is written in Python and comes as a plugin for SCons. You'll need those for all uses.
Install Taschenmesser
easy_install -U taschenmesser
For SVG optimization, you will need Scour:
easy_install -U scour
For SVG-to-PNG conversion, you will need Inkscape. Make sure the Inkscape executable is on your PATH
.
For Amazon Web Service features, you will need Boto:
easy_install -U boto
Here is an example SConstruct
makefile that produces optimized SVGs:
SVG_FILES = ['myfigure.svg']
IMG_SOURCE_DIR = "design"
IMG_GEN_DIR = "gen"
import pkg_resources
taschenmesser = pkg_resources.resource_filename('taschenmesser', '..')
env = Environment(tools = ['default', 'taschenmesser'], toolpath = [taschenmesser])
for svg in SVG_FILES:
svgOpt = env.Scour("%s/%s" % (IMG_GEN_DIR, svg),
"%s/%s" % (IMG_SOURCE_DIR, svg))
You can then just do:
scons
and you'll get optimized SVGs that work in most browsers.
To cleanup, do:
scons -uc
Here is a more complete example SConstruct
that show how to produce:
- Optimized SVGs
- PNGs from those
- GZipped versions of all
everything produced via a single command.
SVG_FILES = ['myfigure.svg', 'awesome_shit1.svg', 'awesome_shit2.svg']
IMG_SOURCE_DIR = "design"
IMG_GEN_DIR = "gen"
import pkg_resources
taschenmesser = pkg_resources.resource_filename('taschenmesser', '..')
env = Environment(tools = ['default', 'taschenmesser'], toolpath = [taschenmesser])
for svg in SVG_FILES:
svgOpt = env.Scour("%s/%s" % (IMG_GEN_DIR, svg),
"%s/%s" % (IMG_SOURCE_DIR, svg),
SCOUR_OPTIONS = {'enable_viewboxing': True})
env.GZip("%s.gz" % svgOpt[0], svgOpt)
png = env.Svg2Png("%s.png" % os.path.splitext(str(svgOpt[0]))[0],
svgOpt,
SVG2PNG_OPTIONS = {})
env.GZip("%s.gz" % png[0], png)
Write me.
Write me.