summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Owens <doctormo@gmail.com>2014-01-14 16:12:30 +0000
committerMartin Owens <doctormo@gmail.com>2014-01-14 16:12:30 +0000
commit906dd648455cac4c5c48fcb11c6bcc6ba9c02edb (patch)
tree5c48e66c470aec286b58d7e8e431e6f4d6f082f6
parentFix bug #1239779 by removing caching for symbols. (diff)
downloadinkscape-906dd648455cac4c5c48fcb11c6bcc6ba9c02edb.tar.gz
inkscape-906dd648455cac4c5c48fcb11c6bcc6ba9c02edb.zip
Merge in patch from bug #1267842 to fix Inkex module open order.
Fixed bugs: - https://launchpad.net/bugs/1267842 (bzr r12925)
-rwxr-xr-xshare/extensions/inkex.py28
1 files 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)