From 5a1604ce202077da2823bf63f4400dd9343a17df Mon Sep 17 00:00:00 2001 From: Michael Schwarz Date: Thu, 6 Aug 2015 16:32:35 +0200 Subject: Use Python script to run Asymptote. --- support/asymptote/__init__.py | 0 support/asymptote/__main__.py | 24 ++++++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 support/asymptote/__init__.py create mode 100644 support/asymptote/__main__.py (limited to 'support/asymptote') diff --git a/support/asymptote/__init__.py b/support/asymptote/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/support/asymptote/__main__.py b/support/asymptote/__main__.py new file mode 100644 index 0000000..1816224 --- /dev/null +++ b/support/asymptote/__main__.py @@ -0,0 +1,24 @@ +import os, sys +from lib import util + + +def _asymptote(in_path, out_path, asymptote_dir): + util.command([os.environ['ASYMPTOTE'], '-f', 'pdf', '-o', out_path, in_path], set_env = { 'ASYMPTOTE_DIR': asymptote_dir }) + + +def main(in_path, out_path): + _, out_suffix = os.path.splitext(out_path) + + if out_suffix == '.pdf': + _asymptote(in_path, out_path, os.path.dirname(in_path)) + else: + raise Exception('Unknown file type: {}'.format(out_suffix)) + + +try: + main(*sys.argv[1:]) +except util.UserError as e: + print 'Error:', e + sys.exit(1) +except KeyboardInterrupt: + sys.exit(2) -- cgit