enhance reload file

This commit is contained in:
Mario Voigt 2021-12-19 18:00:43 +01:00
parent c8e93a5c66
commit 5778c1c9ee
1 changed files with 11 additions and 4 deletions

View File

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