From 906dd648455cac4c5c48fcb11c6bcc6ba9c02edb Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Tue, 14 Jan 2014 11:12:30 -0500 Subject: Merge in patch from bug #1267842 to fix Inkex module open order. Fixed bugs: - https://launchpad.net/bugs/1267842 (bzr r12925) --- share/extensions/inkex.py | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/share/extensions/inkex.py b/share/extensions/inkex.py index 5333ef52b..1203a4606 100755 --- a/share/extensions/inkex.py +++ b/share/extensions/inkex.py @@ -151,15 +151,31 @@ class Effect: """Collect command line arguments""" self.options, self.args = self.OptionParser.parse_args(args) - def parse(self,file=None): + def parse(self, filename=None): """Parse document in specified file or on stdin""" - try: + + # First try to open the file from the function argument + if filename != None: try: - stream = open(file,'r') - except: - stream = open(self.svg_file,'r') - except: + stream = open(filename, 'r') + except Exception: + errormsg(_("Unable to open specified file: %s") % filename) + sys.exit() + + # If it wasn't specified, try to open the file specified as + # an object member + elif self.svg_file != None: + try: + stream = open(self.svg_file, 'r') + except Exception: + errormsg(_("Unable to open specified file: %s") % self.svg_file) + sys.exit() + + # Finally, if the filename was not specified anywhere, use + # standard input stream + else: stream = sys.stdin + p = etree.XMLParser(huge_tree=True) self.document = etree.parse(stream, parser=p) self.original_document = copy.deepcopy(self.document) -- cgit v1.2.3