diff --git a/ttCompile.py b/ttCompile.py index 9f107f534..ea803f8dd 100644 --- a/ttCompile.py +++ b/ttCompile.py @@ -23,7 +23,14 @@ usage: %s [-hvbf] [-d output-dir] [-i TTF-input-file] [TTX-file...] import sys, os, getopt from fontTools import ttLib -options, args = getopt.getopt(sys.argv[1:], "hvbfd:i:") +def usage(): + print __doc__ % sys.argv[0] + sys.exit(2) + +try: + options, args = getopt.getopt(sys.argv[1:], "hvbfd:i:") +except getopt.GetoptError: + usage() # default values verbose = 0 @@ -48,8 +55,7 @@ for option, value in options: forceOverwrite = 1 if not args: - print __doc__ % sys.argv[0] - sys.exit(2) + usage() if ttInFile and len(args) > 1: print "Must specify exactly one TTX file (or directory) when using -i" diff --git a/ttDump.py b/ttDump.py index c550e74ac..3e4b31f13 100644 --- a/ttDump.py +++ b/ttDump.py @@ -31,7 +31,14 @@ usage: %s [-hvisf] [-t ] [-x
] [-d ] TrueType-file(s) import sys, os, getopt from fontTools import ttLib -options, args = getopt.getopt(sys.argv[1:], "hvisft:x:d:") +def usage(): + print __doc__ % sys.argv[0] + sys.exit(2) + +try: + options, args = getopt.getopt(sys.argv[1:], "hvisft:x:d:") +except getopt.GetoptError: + usage() # default values verbose = 0 @@ -76,8 +83,7 @@ if tables and skipTables: sys.exit(2) if not args: - print __doc__ % sys.argv[0] - sys.exit(2) + usage() for ttPath in args: path, ext = os.path.splitext(ttPath)