~ubuntu-branches/ubuntu/natty/inkscape/natty

« back to all changes in this revision

Viewing changes to share/extensions/scour.inkscape.py

  • Committer: Bazaar Package Importer
  • Author(s): Alex Valavanis
  • Date: 2010-09-12 19:44:58 UTC
  • mfrom: (1.1.12 upstream) (45.1.3 maverick)
  • Revision ID: james.westby@ubuntu.com-20100912194458-4sjwmbl7dlsrk5dc
Tags: 0.48.0-1ubuntu1
* Merge with Debian unstable (LP: #628048, LP: #401567, LP: #456248, 
  LP: #463602, LP: #591986)
* debian/control: 
  - Ubuntu maintainers
  - Promote python-lxml, python-numpy, python-uniconvertor to Recommends.
  - Demote pstoedit to Suggests (universe package).
  - Suggests ttf-dejavu instead of ttf-bitstream-vera (LP: #513319)
* debian/rules:
  - Run intltool-update on build (Ubuntu-specific).
  - Add translation domain to .desktop files (Ubuntu-specific).
* debian/dirs:
  - Add usr/share/pixmaps.  Allow inkscape.xpm installation
* drop 50-poppler-API.dpatch (now upstream)
* drop 51-paste-in-unwritable-directory.dpatch (now upstream) 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/env python
2
2
# -*- coding: utf-8 -*-
3
 
import sys
 
3
import sys, inkex
4
4
from scour import scourString
5
 
input = file(sys.argv[1], "r")
6
 
sys.stdout.write(scourString(input.read()).encode("UTF-8"))
7
 
input.close()
8
 
sys.stdout.close()
 
5
 
 
6
class ScourInkscape (inkex.Effect):
 
7
 
 
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)")
 
40
        self.OptionParser.add_option("--enable-viewboxing", type="inkbool",
 
41
            action="store", dest="enable_viewboxing", default=False,
 
42
            help="changes document width/height to 100%/100% and creates viewbox coordinates")
 
43
 
 
44
 
 
45
    def effect(self):   
 
46
        input = file(sys.argv[12], "r")
 
47
        sys.stdout.write(scourString(input.read(), self.options).encode("UTF-8"))
 
48
        input.close()
 
49
        sys.stdout.close()
 
50
 
 
51
 
 
52
if __name__ == '__main__':
 
53
    e = ScourInkscape()
 
54
    e.affect(output=False)