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 *
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 *
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):
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: