From: acspike Date: Mon, 8 May 2006 14:54:52 +0000 (+0000) Subject: whitespace and fix sodipodi URI X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=9b77305280c58403993d08f831397d369de015f9;p=inkscape.git whitespace and fix sodipodi URI --- diff --git a/share/extensions/inkex.py b/share/extensions/inkex.py index 041f7bff7..b8bba3803 100755 --- a/share/extensions/inkex.py +++ b/share/extensions/inkex.py @@ -23,33 +23,33 @@ import sys, copy, optparse #a dictionary of all of the xmlns prefixes in a standard inkscape doc NSS = { -u'sodipodi' :u'http://inkscape.sourceforge.net/DTD/sodipodi-0.dtd', -u'cc' :u'http://web.resource.org/cc/', -u'svg' :u'http://www.w3.org/2000/svg', -u'dc' :u'http://purl.org/dc/elements/1.1/', -u'rdf' :u'http://www.w3.org/1999/02/22-rdf-syntax-ns#', -u'inkscape' :u'http://www.inkscape.org/namespaces/inkscape', -u'xlink' :u'http://www.w3.org/1999/xlink' +u'sodipodi' :u'http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd', +u'cc' :u'http://web.resource.org/cc/', +u'svg' :u'http://www.w3.org/2000/svg', +u'dc' :u'http://purl.org/dc/elements/1.1/', +u'rdf' :u'http://www.w3.org/1999/02/22-rdf-syntax-ns#', +u'inkscape' :u'http://www.inkscape.org/namespaces/inkscape', +u'xlink' :u'http://www.w3.org/1999/xlink' } try: - import xml.dom.ext - import xml.dom.ext.reader.Sax2 - import xml.xpath + import xml.dom.ext + import xml.dom.ext.reader.Sax2 + import xml.xpath except: - sys.exit('The inkex.py module requires PyXML. Please download the latest version from .') + sys.exit('The inkex.py module requires PyXML. Please download the latest version from .') def debug(what): - sys.stderr.write(str(what) + "\n") - return what + sys.stderr.write(str(what) + "\n") + return what def check_inkbool(option, opt, value): - if str(value).capitalize() == 'True': - return True - elif str(value).capitalize() == 'False': - return False - else: - raise OptionValueError("option %s: invalid inkbool value: %s" % (opt, value)) + if str(value).capitalize() == 'True': + return True + elif str(value).capitalize() == 'False': + return False + else: + raise OptionValueError("option %s: invalid inkbool value: %s" % (opt, value)) class InkOption(optparse.Option): TYPES = optparse.Option.TYPES + ("inkbool",) @@ -58,46 +58,46 @@ class InkOption(optparse.Option): class Effect: - """A class for creating Inkscape SVG Effects""" - def __init__(self): - self.document=None - self.selected={} - self.options=None - self.args=None - self.OptionParser = optparse.OptionParser(usage="usage: %prog [options] SVGfile",option_class=InkOption) - self.OptionParser.add_option("--id", - action="append", type="string", dest="ids", default=[], - help="id attribute of object to manipulate") - def effect(self): - pass - def getoptions(self,args=sys.argv[1:]): - """Collect command line arguments""" - self.options, self.args = self.OptionParser.parse_args(args) - def parse(self,file=None): - """Parse document in specified file or on stdin""" - reader = xml.dom.ext.reader.Sax2.Reader() - try: - try: - stream = open(file,'r') - except: - stream = open(self.args[-1],'r') - except: - stream = sys.stdin - self.document = reader.fromStream(stream) - stream.close() - def getselected(self): - """Collect selected nodes""" - for id in self.options.ids: - path = '//*[@id="%s"]' % id - for node in xml.xpath.Evaluate(path,self.document): - self.selected[id] = node - def output(self): - """Serialize document into XML on stdout""" - xml.dom.ext.Print(self.document) - def affect(self): - """Affect an SVG document with a callback effect""" - self.getoptions() - self.parse() - self.getselected() - self.effect() - self.output() + """A class for creating Inkscape SVG Effects""" + def __init__(self): + self.document=None + self.selected={} + self.options=None + self.args=None + self.OptionParser = optparse.OptionParser(usage="usage: %prog [options] SVGfile",option_class=InkOption) + self.OptionParser.add_option("--id", + action="append", type="string", dest="ids", default=[], + help="id attribute of object to manipulate") + def effect(self): + pass + def getoptions(self,args=sys.argv[1:]): + """Collect command line arguments""" + self.options, self.args = self.OptionParser.parse_args(args) + def parse(self,file=None): + """Parse document in specified file or on stdin""" + reader = xml.dom.ext.reader.Sax2.Reader() + try: + try: + stream = open(file,'r') + except: + stream = open(self.args[-1],'r') + except: + stream = sys.stdin + self.document = reader.fromStream(stream) + stream.close() + def getselected(self): + """Collect selected nodes""" + for id in self.options.ids: + path = '//*[@id="%s"]' % id + for node in xml.xpath.Evaluate(path,self.document): + self.selected[id] = node + def output(self): + """Serialize document into XML on stdout""" + xml.dom.ext.Print(self.document) + def affect(self): + """Affect an SVG document with a callback effect""" + self.getoptions() + self.parse() + self.getselected() + self.effect() + self.output()