summaryrefslogtreecommitdiff
path: root/support/inkscape
diff options
context:
space:
mode:
authorMichael Schwarz <michi.schwarz@gmail.com>2015-09-30 18:12:10 +0200
committerMichael Schwarz <michi.schwarz@gmail.com>2015-09-30 18:14:50 +0200
commit39be44f16d1a817c10a268808fdcaed6628db261 (patch)
tree7ca51e8f8d5776b29f52acba1f1f1dc0d9a374d6 /support/inkscape
parent9f3e7bf14de8b5a45c8e4a6b86b6af0f787aa5ad (diff)
downloadpogojig-39be44f16d1a817c10a268808fdcaed6628db261.tar.gz
pogojig-39be44f16d1a817c10a268808fdcaed6628db261.tar.bz2
pogojig-39be44f16d1a817c10a268808fdcaed6628db261.zip
Include input file path in error messages.
Diffstat (limited to 'support/inkscape')
-rw-r--r--support/inkscape/__main__.py38
1 files changed, 21 insertions, 17 deletions
diff --git a/support/inkscape/__main__.py b/support/inkscape/__main__.py
index a2c9341..e68341e 100644
--- a/support/inkscape/__main__.py
+++ b/support/inkscape/__main__.py
@@ -38,22 +38,26 @@ def _unfuck_svg_document(temp_svg_path):
@util.main
def main(in_path, out_path):
- _, out_suffix = os.path.splitext(out_path)
-
- with util.TemporaryDirectory() as temp_dir:
- temp_svg_path = os.path.join(temp_dir, os.path.basename(in_path))
-
- shutil.copyfile(in_path, temp_svg_path)
-
- _unfuck_svg_document(temp_svg_path)
+ try:
+ _, out_suffix = os.path.splitext(out_path)
- export_effect = effect.ExportEffect()
- export_effect.affect(args = [temp_svg_path], output = False)
- with open(out_path, 'w') as file:
- if out_suffix == '.dxf':
- export_effect.write_dxf(file)
- elif out_suffix == '.asy':
- export_effect.write_asy(file)
- else:
- raise Exception('Unknown file type: {}'.format(out_suffix))
+ with util.TemporaryDirectory() as temp_dir:
+ temp_svg_path = os.path.join(temp_dir, os.path.basename(in_path))
+
+ shutil.copyfile(in_path, temp_svg_path)
+
+ _unfuck_svg_document(temp_svg_path)
+
+ export_effect = effect.ExportEffect()
+ export_effect.affect(args = [temp_svg_path], output = False)
+
+ with open(out_path, 'w') as file:
+ if out_suffix == '.dxf':
+ export_effect.write_dxf(file)
+ elif out_suffix == '.asy':
+ export_effect.write_asy(file)
+ else:
+ raise Exception('Unknown file type: {}'.format(out_suffix))
+ except util.UserError as e:
+ raise util.UserError('While processing {}: {}', in_path, e)