From 8f80f93491be73f05eba908591c856339acda51e Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sat, 21 Jan 2012 20:03:25 -0500 Subject: [PATCH] More shoveling around --- test/shaping/hb-diff-filter-failures | 2 +- test/shaping/hb-manifest-read | 2 +- test/shaping/hb_test_tools.py | 27 ++++++++++++++++----------- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/test/shaping/hb-diff-filter-failures b/test/shaping/hb-diff-filter-failures index 5b00eae..4fe218a 100755 --- a/test/shaping/hb-diff-filter-failures +++ b/test/shaping/hb-diff-filter-failures @@ -2,4 +2,4 @@ from hb_test_tools import * -UtilMains.filter_multiple_strings_or_stdin (Unicode.decode, "UNICODE_STRING") +UtilMains.process_multiple_files (FilterHelpers.filter_printer_function_no_newline (DiffFilters.filter_failures)) diff --git a/test/shaping/hb-manifest-read b/test/shaping/hb-manifest-read index 754e491..f486bcc 100755 --- a/test/shaping/hb-manifest-read +++ b/test/shaping/hb-manifest-read @@ -2,4 +2,4 @@ from hb_test_tools import * -UtilMains.process_multiple_args (UtilMains.filter_printer_function (Manifest.read), mnemonic="DIR") +UtilMains.process_multiple_args (FilterHelpers.filter_printer_function (Manifest.read), mnemonic="DIR") diff --git a/test/shaping/hb_test_tools.py b/test/shaping/hb_test_tools.py index d53aa4a..b78cdca 100644 --- a/test/shaping/hb_test_tools.py +++ b/test/shaping/hb_test_tools.py @@ -102,27 +102,32 @@ class DiffFilters: def filter_failures (f): for l in f: if l[0] in '-+': - sys.stdout.writelines (l) + yield l class ShapeFilters: - @staticmethod - def filter_failures (f): - for l in f: - if l[0] in '-+': - sys.stdout.writelines (l) + pass -class UtilMains: +class FilterHelpers: @staticmethod - def filter_printer_function (callback): + def filter_printer_function (filter_callback): def printer (f): - for line in callback (f): + for line in filter_callback (f): print line return printer + @staticmethod + def filter_printer_function_no_newline (filter_callback): + def printer (f): + for line in filter_callback (f): + sys.stdout.writelines ([line]) + return printer + + +class UtilMains: @staticmethod def process_multiple_files (callback, mnemonic = "FILE"): @@ -249,7 +254,7 @@ class Manifest: if not os.path.exists (s): if strict: - print >> sys.stderr, "%s: %s does not exist" (sys.argv[0], s) + print >> sys.stderr, "%s: %s does not exist" % (sys.argv[0], s) sys.exit (1) return @@ -265,7 +270,7 @@ class Manifest: yield p except IOError: if strict: - print >> sys.stderr, "%s: %s does not exist" (sys.argv[0], os.path.join (s, "MANIFEST")) + print >> sys.stderr, "%s: %s does not exist" % (sys.argv[0], os.path.join (s, "MANIFEST")) sys.exit (1) return else: -- 2.7.4