enhance reload file
This commit is contained in:
parent
c8e93a5c66
commit
5778c1c9ee
@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import os
|
||||||
import inkex
|
import inkex
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
|
|
||||||
@ -22,10 +23,16 @@ class Reload(inkex.EffectExtension):
|
|||||||
originalDefs = originalRoot.find("{http://www.w3.org/2000/svg}defs")
|
originalDefs = originalRoot.find("{http://www.w3.org/2000/svg}defs")
|
||||||
originalRoot.clear() #drop all children and attributes from root
|
originalRoot.clear() #drop all children and attributes from root
|
||||||
|
|
||||||
stream = open(self.document_path(), 'r')
|
if not os.path.exists(currentDoc):
|
||||||
p = etree.XMLParser(huge_tree=True)
|
self.msg("The input file does not exist (anymore). Please check and try again.")
|
||||||
doc = etree.parse(stream, parser=etree.XMLParser(huge_tree=True))
|
exit(1)
|
||||||
stream.close()
|
|
||||||
|
with open(currentDoc, 'r') as stream:
|
||||||
|
try:
|
||||||
|
doc = etree.parse(stream, parser=etree.XMLParser(huge_tree=True))
|
||||||
|
except Exception as e:
|
||||||
|
inkex.utils.debug("Malformed file: {}".format(e))
|
||||||
|
exit(1)
|
||||||
|
|
||||||
copyRoot = doc.getroot()
|
copyRoot = doc.getroot()
|
||||||
copyNamedview = copyRoot.find(inkex.addNS('namedview', 'sodipodi'))
|
copyNamedview = copyRoot.find(inkex.addNS('namedview', 'sodipodi'))
|
||||||
|
Reference in New Issue
Block a user