summaryrefslogtreecommitdiff
path: root/support/asymptote
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/asymptote
parent9f3e7bf14de8b5a45c8e4a6b86b6af0f787aa5ad (diff)
downloadpogojig-39be44f16d1a817c10a268808fdcaed6628db261.tar.gz
pogojig-39be44f16d1a817c10a268808fdcaed6628db261.tar.bz2
pogojig-39be44f16d1a817c10a268808fdcaed6628db261.zip
Include input file path in error messages.
Diffstat (limited to 'support/asymptote')
-rw-r--r--support/asymptote/__main__.py37
1 files changed, 20 insertions, 17 deletions
diff --git a/support/asymptote/__main__.py b/support/asymptote/__main__.py
index 9d712ef..705649a 100644
--- a/support/asymptote/__main__.py
+++ b/support/asymptote/__main__.py
@@ -34,21 +34,24 @@ def _asymptote(in_path, out_path, asymptote_dir, working_dir):
@util.main
def main(in_path, out_path):
- _, out_suffix = os.path.splitext(out_path)
-
- with util.TemporaryDirectory() as temp_dir:
- absolute_in_path = os.path.abspath(in_path)
- temp_out_path = os.path.join(temp_dir, 'out.pdf')
-
- # Asymptote creates A LOT of temp files (presumably when invoking LaTeX) and leaves some of them behind. Thus we run asymptote in a temporary directory.
- loaded_files = _asymptote(absolute_in_path, 'out', os.path.dirname(absolute_in_path), temp_dir)
-
- if not os.path.exists(temp_out_path):
- raise util.UserError('Asymptote did not generate a PDF file for input file {}.', in_path)
-
- # All dependencies as paths relative to the project root.
- dependencies = set(map(os.path.relpath, loaded_files))
+ try:
+ _, out_suffix = os.path.splitext(out_path)
- # Write output files.
- make.write_dependencies(out_path + '.d', out_path, dependencies - { in_path })
- shutil.copyfile(temp_out_path, out_path)
+ with util.TemporaryDirectory() as temp_dir:
+ absolute_in_path = os.path.abspath(in_path)
+ temp_out_path = os.path.join(temp_dir, 'out.pdf')
+
+ # Asymptote creates A LOT of temp files (presumably when invoking LaTeX) and leaves some of them behind. Thus we run asymptote in a temporary directory.
+ loaded_files = _asymptote(absolute_in_path, 'out', os.path.dirname(absolute_in_path), temp_dir)
+
+ if not os.path.exists(temp_out_path):
+ raise util.UserError('Asymptote did not generate a PDF file.', in_path)
+
+ # All dependencies as paths relative to the project root.
+ dependencies = set(map(os.path.relpath, loaded_files))
+
+ # Write output files.
+ make.write_dependencies(out_path + '.d', out_path, dependencies - { in_path })
+ shutil.copyfile(temp_out_path, out_path)
+ except util.UserError as e:
+ raise util.UserError('While processing {}: {}', in_path, e)