index 65176652fb61624318b3bbe1171d4d323150ab7e..994f74dea7b25064e79568b3e16c4e5e81c6dd83 100644 (file)
def addInkWebJSCode(self, scriptEl):
js = open( os.path.join(sys.path[0], "inkweb.js"), 'r' )
- scriptEl.text = \
- inkex.etree.CDATA(
- "\n/* inkweb.js - InkWebEffect:AutoUpdate */\n" + js.read()
- )
+ if hasattr(inkex.etree, "CDATA"):
+ scriptEl.text = \
+ inkex.etree.CDATA(
+ "\n/* inkweb.js - InkWebEffect:AutoUpdate */\n" + js.read()
+ )
+ else:
+ scriptEl.text = \
+ "\n/* inkweb.js - InkWebEffect:AutoUpdate */\n" + js.read()
js.close()
def ensureInkWebSupport(self):
# Search for the script tag with the inkweb.js code:
- scriptEl = False
- scripts = self.document.xpath('//script', namespaces=inkex.NSS)
+ scriptEl = None
+ scripts = self.document.xpath('//svg:script', namespaces=inkex.NSS)
for s in scripts:
- inkex.errormsg(s)
if re.search(self.reUpdateJS, s.text):
- inkex.errormsg("OK!")
scriptEl = s
- if not scriptEl:
+ if scriptEl is None:
root = self.document.getroot()
scriptEl = inkex.etree.Element( "script" )
scriptEl.set( "id", "inkwebjs" )
scriptEl.set( "type", "text/javascript" )
root.insert( 0, scriptEl )
- if self.mustAddInkWebJSCode(scriptEl): self.addInkWebJSCode(scriptEl)
+ if self.mustAddInkWebJSCode(scriptEl):
+ self.addInkWebJSCode(scriptEl)