More shoveling around

This commit is contained in:
Behdad Esfahbod 2012-01-21 20:03:25 -05:00
parent c78c6e9844
commit 8f80f93491
3 changed files with 18 additions and 13 deletions

View File

@ -2,4 +2,4 @@
from hb_test_tools import * 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))

View File

@ -2,4 +2,4 @@
from hb_test_tools import * 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")

View File

@ -102,27 +102,32 @@ class DiffFilters:
def filter_failures (f): def filter_failures (f):
for l in f: for l in f:
if l[0] in '-+': if l[0] in '-+':
sys.stdout.writelines (l) yield l
class ShapeFilters: class ShapeFilters:
@staticmethod pass
def filter_failures (f):
for l in f:
if l[0] in '-+':
sys.stdout.writelines (l)
class UtilMains: class FilterHelpers:
@staticmethod @staticmethod
def filter_printer_function (callback): def filter_printer_function (filter_callback):
def printer (f): def printer (f):
for line in callback (f): for line in filter_callback (f):
print line print line
return printer 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 @staticmethod
def process_multiple_files (callback, mnemonic = "FILE"): def process_multiple_files (callback, mnemonic = "FILE"):
@ -249,7 +254,7 @@ class Manifest:
if not os.path.exists (s): if not os.path.exists (s):
if strict: 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) sys.exit (1)
return return
@ -265,7 +270,7 @@ class Manifest:
yield p yield p
except IOError: except IOError:
if strict: 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) sys.exit (1)
return return
else: else: