1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 import sys, inkex
4 from scour import scourString
6 class ScourInkscape (inkex.Effect):
8 def __init__(self):
9 inkex.Effect.__init__(self)
10 self.OptionParser.add_option("--tab",
11 action="store", type="string",
12 dest="tab")
13 self.OptionParser.add_option("--simplify-colors", type="inkbool",
14 action="store", dest="simple_colors", default=True,
15 help="won't convert all colors to #RRGGBB format")
16 self.OptionParser.add_option("--style-to-xml", type="inkbool",
17 action="store", dest="style_to_xml", default=True,
18 help="won't convert styles into XML attributes")
19 self.OptionParser.add_option("--group-collapsing", type="inkbool",
20 action="store", dest="group_collapse", default=True,
21 help="won't collapse <g> elements")
22 self.OptionParser.add_option("--enable-id-stripping", type="inkbool",
23 action="store", dest="strip_ids", default=False,
24 help="remove all un-referenced ID attributes")
25 self.OptionParser.add_option("--embed-rasters", type="inkbool",
26 action="store", dest="embed_rasters", default=True,
27 help="won't embed rasters as base64-encoded data")
28 self.OptionParser.add_option("--keep-editor-data", type="inkbool",
29 action="store", dest="keep_editor_data", default=False,
30 help="won't remove Inkscape, Sodipodi or Adobe Illustrator elements and attributes")
31 self.OptionParser.add_option("--strip-xml-prolog", type="inkbool",
32 action="store", dest="strip_xml_prolog", default=False,
33 help="won't output the <?xml ?> prolog")
34 self.OptionParser.add_option("-p", "--set-precision",
35 action="store", type=int, dest="digits", default=5,
36 help="set number of significant digits (default: %default)")
37 self.OptionParser.add_option("--indent",
38 action="store", type="string", dest="indent_type", default="space",
39 help="indentation of the output: none, space, tab (default: %default)")
42 def effect(self):
43 input = file(sys.argv[11], "r")
44 sys.stdout.write(scourString(input.read(), self.options).encode("UTF-8"))
45 input.close()
46 sys.stdout.close()
49 if __name__ == '__main__':
50 e = ScourInkscape()
51 e.affect(output=False)