diff options
| author | Lex Neva <github.com@lexneva.name> | 2018-04-28 21:26:53 -0400 |
|---|---|---|
| committer | Lex Neva <github.com@lexneva.name> | 2018-04-29 21:45:36 -0400 |
| commit | 32695e195a286276846f0b4f7133c30cf5a62b18 (patch) | |
| tree | 85b28eb36b110f0d77e6a894b79faf7368758363 /inkstitch.py | |
| parent | a42726679aaf49ecfbabaa236cae10027c37a1f7 (diff) | |
move extension classes into inkstitch/extensions and add inkstitch.py
Diffstat (limited to 'inkstitch.py')
| -rw-r--r-- | inkstitch.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/inkstitch.py b/inkstitch.py new file mode 100644 index 00000000..bd3f3f48 --- /dev/null +++ b/inkstitch.py @@ -0,0 +1,36 @@ +import sys +import traceback +from argparse import ArgumentParser +from inkstitch.utils import save_stderr, restore_stderr +from inkstitch import extensions + + +def get_extension(): + parser = ArgumentParser() + parser.add_argument("--extension") + args, extras = parser.parse_known_args() + + return args.extension + + +extension_name = get_extension() +extension_class = getattr(extensions, extension_name.capitalize()) +extension = extension_class() + +exception = None + +save_stderr() +try: + extension.affect() +except (SystemExit, KeyboardInterrupt): + raise +except Exception: + exception = traceback.format_exc() +finally: + restore_stderr() + +if exception: + print >> sys.stderr, exception + sys.exit(1) +else: + sys.exit(0) |
