minor, use sys.exit print shorthand
This commit is contained in:
parent
08f1d95a50
commit
7554f618ec
|
@ -47,8 +47,7 @@ def get_arch(filename):
|
|||
try:
|
||||
return type2arch[pe.PE_TYPE]
|
||||
except KeyError:
|
||||
sys.stderr.write('Error: unknown architecture')
|
||||
sys.exit(1)
|
||||
sys.exit ('Error: unknown architecture')
|
||||
|
||||
if __name__ == '__main__':
|
||||
filename = sys.argv[1]
|
||||
|
|
|
@ -11,8 +11,7 @@ Input files:
|
|||
import io, os.path, sys
|
||||
|
||||
if len (sys.argv) != 4:
|
||||
print (__doc__, file=sys.stderr)
|
||||
sys.exit (1)
|
||||
sys.exit (__doc__)
|
||||
|
||||
files = [io.open (x, encoding='utf-8') for x in sys.argv[1:]]
|
||||
|
||||
|
|
|
@ -12,8 +12,7 @@ from collections import OrderedDict
|
|||
import packTab
|
||||
|
||||
if len (sys.argv) != 2:
|
||||
print(__doc__, file=sys.stderr)
|
||||
sys.exit (1)
|
||||
sys.exit (__doc__)
|
||||
|
||||
f = open(sys.argv[1])
|
||||
header = [f.readline () for _ in range(10)]
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
import io, os, re, sys
|
||||
|
||||
if len (sys.argv) < 3:
|
||||
sys.exit(__doc__)
|
||||
sys.exit (__doc__)
|
||||
|
||||
output_file = sys.argv[1]
|
||||
source_paths = sys.argv[2:]
|
||||
|
|
|
@ -11,8 +11,7 @@ Input files:
|
|||
import io, sys
|
||||
|
||||
if len (sys.argv) != 4:
|
||||
print (__doc__, file=sys.stderr)
|
||||
sys.exit (1)
|
||||
sys.exit (__doc__)
|
||||
|
||||
ALLOWED_SINGLES = [0x00A0, 0x25CC]
|
||||
ALLOWED_BLOCKS = [
|
||||
|
|
|
@ -36,8 +36,7 @@ import sys
|
|||
import unicodedata
|
||||
|
||||
if len (sys.argv) != 3:
|
||||
print (__doc__, file=sys.stderr)
|
||||
sys.exit (1)
|
||||
sys.exit (__doc__)
|
||||
|
||||
from html import unescape
|
||||
def html_unescape (parser, entity):
|
||||
|
|
|
@ -11,8 +11,7 @@ import logging
|
|||
logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO)
|
||||
|
||||
if len (sys.argv) not in (2, 3):
|
||||
print(__doc__, file=sys.stderr)
|
||||
sys.exit(1)
|
||||
sys.exit (__doc__)
|
||||
|
||||
# https://github.com/harfbuzz/packtab
|
||||
import packTab
|
||||
|
|
|
@ -14,8 +14,7 @@ import io
|
|||
import sys
|
||||
|
||||
if len (sys.argv) != 5:
|
||||
print (__doc__, file=sys.stderr)
|
||||
sys.exit (1)
|
||||
sys.exit (__doc__)
|
||||
|
||||
BLACKLISTED_BLOCKS = ["Thai", "Lao"]
|
||||
|
||||
|
|
|
@ -23,8 +23,7 @@ import io
|
|||
import sys
|
||||
|
||||
if len (sys.argv) != 3:
|
||||
print (__doc__, file=sys.stderr)
|
||||
sys.exit (1)
|
||||
sys.exit (__doc__)
|
||||
|
||||
with io.open (sys.argv[2], encoding='utf-8') as f:
|
||||
scripts_header = [f.readline () for i in range (2)]
|
||||
|
|
|
@ -28,9 +28,8 @@ hb_draw_fuzzer = os.path.join (top_builddir, "hb-draw-fuzzer" + EXEEXT)
|
|||
|
||||
if not os.path.exists (hb_draw_fuzzer):
|
||||
if len (sys.argv) == 1 or not os.path.exists (sys.argv[1]):
|
||||
print ("""Failed to find hb-draw-fuzzer binary automatically,
|
||||
sys.exit ("""Failed to find hb-draw-fuzzer binary automatically,
|
||||
please provide it as the first argument to the tool""")
|
||||
sys.exit (1)
|
||||
|
||||
hb_draw_fuzzer = sys.argv[1]
|
||||
|
||||
|
@ -42,8 +41,7 @@ valgrind = None
|
|||
if os.environ.get ('RUN_VALGRIND', ''):
|
||||
valgrind = shutil.which ('valgrind')
|
||||
if valgrind is None:
|
||||
print ("""Valgrind requested but not found.""")
|
||||
sys.exit (1)
|
||||
sys.exit ("""Valgrind requested but not found.""")
|
||||
if libtool is None:
|
||||
print ("""Valgrind support is currently autotools only and needs libtool but not found.""")
|
||||
|
||||
|
@ -69,5 +67,4 @@ for file in os.listdir (parent_path):
|
|||
|
||||
|
||||
if fails:
|
||||
print ("%i draw fuzzer related tests failed." % fails)
|
||||
sys.exit (1)
|
||||
sys.exit ("%d draw fuzzer related tests failed." % fails)
|
||||
|
|
|
@ -28,9 +28,8 @@ hb_shape_fuzzer = os.path.join (top_builddir, "hb-shape-fuzzer" + EXEEXT)
|
|||
|
||||
if not os.path.exists (hb_shape_fuzzer):
|
||||
if len (sys.argv) == 1 or not os.path.exists (sys.argv[1]):
|
||||
print ("""Failed to find hb-shape-fuzzer binary automatically,
|
||||
sys.exit ("""Failed to find hb-shape-fuzzer binary automatically,
|
||||
please provide it as the first argument to the tool""")
|
||||
sys.exit (1)
|
||||
|
||||
hb_shape_fuzzer = sys.argv[1]
|
||||
|
||||
|
@ -42,8 +41,7 @@ valgrind = None
|
|||
if os.environ.get ('RUN_VALGRIND', ''):
|
||||
valgrind = shutil.which ('valgrind')
|
||||
if valgrind is None:
|
||||
print ("""Valgrind requested but not found.""")
|
||||
sys.exit (1)
|
||||
sys.exit ("""Valgrind requested but not found.""")
|
||||
if libtool is None:
|
||||
print ("""Valgrind support is currently autotools only and needs libtool but not found.""")
|
||||
|
||||
|
@ -68,5 +66,4 @@ for file in os.listdir (parent_path):
|
|||
|
||||
|
||||
if fails:
|
||||
print ("%i shape fuzzer related tests failed." % fails)
|
||||
sys.exit (1)
|
||||
sys.exit ("%d shape fuzzer related tests failed." % fails)
|
||||
|
|
|
@ -28,9 +28,8 @@ hb_subset_fuzzer = os.path.join (top_builddir, "hb-subset-fuzzer" + EXEEXT)
|
|||
|
||||
if not os.path.exists (hb_subset_fuzzer):
|
||||
if len (sys.argv) < 2 or not os.path.exists (sys.argv[1]):
|
||||
print ("""Failed to find hb-subset-fuzzer binary automatically,
|
||||
sys.exit ("""Failed to find hb-subset-fuzzer binary automatically,
|
||||
please provide it as the first argument to the tool""")
|
||||
sys.exit (1)
|
||||
|
||||
hb_subset_fuzzer = sys.argv[1]
|
||||
|
||||
|
@ -42,8 +41,7 @@ valgrind = None
|
|||
if os.environ.get('RUN_VALGRIND', ''):
|
||||
valgrind = shutil.which ('valgrind')
|
||||
if valgrind is None:
|
||||
print ("""Valgrind requested but not found.""")
|
||||
sys.exit (1)
|
||||
sys.exit ("""Valgrind requested but not found.""")
|
||||
if libtool is None:
|
||||
print ("""Valgrind support is currently autotools only and needs libtool but not found.""")
|
||||
|
||||
|
@ -75,5 +73,4 @@ run_dir (os.path.join (srcdir, "..", "subset", "data", "fonts"))
|
|||
run_dir (os.path.join (srcdir, "fonts"))
|
||||
|
||||
if fails:
|
||||
print ("%i subset fuzzer related tests failed." % fails)
|
||||
sys.exit (1)
|
||||
sys.exit ("%d subset fuzzer related tests failed." % fails)
|
||||
|
|
|
@ -57,4 +57,5 @@ for elt in html.findall(".//*[@class='expected-no-crash'][@ft:id]", namespaces):
|
|||
opts = '--variations=%s' % variations
|
||||
print ("../fonts/%s:%s:%s:*" % (font, opts, unistr(text)))
|
||||
|
||||
sys.exit(0 if found else 1)
|
||||
if not found:
|
||||
sys.exit (1)
|
||||
|
|
|
@ -4,7 +4,6 @@ from hb_test_tools import *
|
|||
import sys, os
|
||||
|
||||
if len (sys.argv) < 2:
|
||||
print ("usage: %s FILES..." % sys.argv[0])
|
||||
sys.exit (1)
|
||||
sys.exit ("usage: %s FILES..." % sys.argv[0])
|
||||
|
||||
ZipDiffer.diff_files (FileHelpers.open_file_or_stdin (f) for f in sys.argv[1:])
|
||||
|
|
|
@ -145,8 +145,7 @@ class ZipDiffer:
|
|||
sys.stdout.writelines ([symbols[i], l])
|
||||
except IOError as e:
|
||||
if e.errno != errno.EPIPE:
|
||||
print ("%s: %s: %s" % (sys.argv[0], e.filename, e.strerror), file=sys.stderr)
|
||||
sys.exit (1)
|
||||
sys.exit ("%s: %s: %s" % (sys.argv[0], e.filename, e.strerror))
|
||||
|
||||
|
||||
class DiffFilters:
|
||||
|
@ -321,8 +320,7 @@ class UtilMains:
|
|||
def process_multiple_files (callback, mnemonic = "FILE"):
|
||||
|
||||
if "--help" in sys.argv:
|
||||
print ("Usage: %s %s..." % (sys.argv[0], mnemonic))
|
||||
sys.exit (1)
|
||||
sys.exit ("Usage: %s %s..." % (sys.argv[0], mnemonic))
|
||||
|
||||
try:
|
||||
files = sys.argv[1:] if len (sys.argv) > 1 else ['-']
|
||||
|
@ -330,23 +328,20 @@ class UtilMains:
|
|||
callback (FileHelpers.open_file_or_stdin (s))
|
||||
except IOError as e:
|
||||
if e.errno != errno.EPIPE:
|
||||
print ("%s: %s: %s" % (sys.argv[0], e.filename, e.strerror), file=sys.stderr)
|
||||
sys.exit (1)
|
||||
sys.exit ("%s: %s: %s" % (sys.argv[0], e.filename, e.strerror))
|
||||
|
||||
@staticmethod
|
||||
def process_multiple_args (callback, mnemonic):
|
||||
|
||||
if len (sys.argv) == 1 or "--help" in sys.argv:
|
||||
print ("Usage: %s %s..." % (sys.argv[0], mnemonic))
|
||||
sys.exit (1)
|
||||
sys.exit ("Usage: %s %s..." % (sys.argv[0], mnemonic))
|
||||
|
||||
try:
|
||||
for s in sys.argv[1:]:
|
||||
callback (s)
|
||||
except IOError as e:
|
||||
if e.errno != errno.EPIPE:
|
||||
print ("%s: %s: %s" % (sys.argv[0], e.filename, e.strerror), file=sys.stderr)
|
||||
sys.exit (1)
|
||||
sys.exit ("%s: %s: %s" % (sys.argv[0], e.filename, e.strerror))
|
||||
|
||||
@staticmethod
|
||||
def filter_multiple_strings_or_stdin (callback, mnemonic, \
|
||||
|
@ -354,9 +349,12 @@ class UtilMains:
|
|||
concat_separator = False):
|
||||
|
||||
if "--help" in sys.argv:
|
||||
print ("Usage:\n %s %s...\nor:\n %s\n\nWhen called with no arguments, input is read from standard input." \
|
||||
% (sys.argv[0], mnemonic, sys.argv[0]))
|
||||
sys.exit (1)
|
||||
sys.exit ("""Usage:
|
||||
%s %s...
|
||||
or:
|
||||
%s
|
||||
When called with no arguments, input is read from standard input.
|
||||
""" % (sys.argv[0], mnemonic, sys.argv[0]))
|
||||
|
||||
try:
|
||||
if len (sys.argv) == 1:
|
||||
|
@ -374,8 +372,7 @@ class UtilMains:
|
|||
print (separator.join (callback (x) for x in (args)))
|
||||
except IOError as e:
|
||||
if e.errno != errno.EPIPE:
|
||||
print ("%s: %s: %s" % (sys.argv[0], e.filename, e.strerror), file=sys.stderr)
|
||||
sys.exit (1)
|
||||
sys.exit ("%s: %s: %s" % (sys.argv[0], e.filename, e.strerror))
|
||||
|
||||
|
||||
class Unicode:
|
||||
|
@ -448,8 +445,7 @@ class Manifest:
|
|||
|
||||
if not os.path.exists (s):
|
||||
if strict:
|
||||
print ("%s: %s does not exist" % (sys.argv[0], s), file=sys.stderr)
|
||||
sys.exit (1)
|
||||
sys.exit ("%s: %s does not exist" % (sys.argv[0], s))
|
||||
return
|
||||
|
||||
s = os.path.normpath (s)
|
||||
|
@ -464,8 +460,7 @@ class Manifest:
|
|||
yield p
|
||||
except IOError:
|
||||
if strict:
|
||||
print ("%s: %s does not exist" % (sys.argv[0], os.path.join (s, "MANIFEST")), file=sys.stderr)
|
||||
sys.exit (1)
|
||||
sys.exit ("%s: %s does not exist" % (sys.argv[0], os.path.join (s, "MANIFEST")))
|
||||
return
|
||||
else:
|
||||
yield s
|
||||
|
|
|
@ -11,8 +11,7 @@ if len (args) and args[0] == "--reference":
|
|||
args = args[1:]
|
||||
|
||||
if not args or args[0].find('hb-shape') == -1 or not os.path.exists (args[0]):
|
||||
print ("""First argument does not seem to point to usable hb-shape.""")
|
||||
sys.exit (1)
|
||||
sys.exit ("""First argument does not seem to point to usable hb-shape.""")
|
||||
hb_shape, args = args[0], args[1:]
|
||||
|
||||
def cmd(command):
|
||||
|
|
|
@ -127,13 +127,11 @@ def check_ots (path):
|
|||
|
||||
args = sys.argv[1:]
|
||||
if not args or sys.argv[1].find ('hb-subset') == -1 or not os.path.exists (sys.argv[1]):
|
||||
print ("First argument does not seem to point to usable hb-subset.")
|
||||
sys.exit (1)
|
||||
sys.exit ("First argument does not seem to point to usable hb-subset.")
|
||||
hb_subset, args = args[0], args[1:]
|
||||
|
||||
if not len (args):
|
||||
print ("No tests supplied.")
|
||||
sys.exit (1)
|
||||
sys.exit ("No tests supplied.")
|
||||
|
||||
has_ots = has_ots()
|
||||
|
||||
|
@ -146,7 +144,6 @@ for path in args:
|
|||
fails += run_test (test, has_ots)
|
||||
|
||||
if fails != 0:
|
||||
print (str (fails) + " test(s) failed.")
|
||||
sys.exit(1)
|
||||
sys.exit ("%d test(s) failed." % fails)
|
||||
else:
|
||||
print ("All tests passed.")
|
||||
|
|
Loading…
Reference in New Issue