From 1e58df603457cb4b57da78b5d4a8df66aa7d7be4 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sat, 21 Jan 2012 19:37:31 -0500 Subject: [PATCH] Cleanup manifest code --- test/shaping/hb_test_tools.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/test/shaping/hb_test_tools.py b/test/shaping/hb_test_tools.py index 67d817e58..94c37b239 100644 --- a/test/shaping/hb_test_tools.py +++ b/test/shaping/hb_test_tools.py @@ -231,30 +231,36 @@ class FileHelpers: class Manifest: @staticmethod - def print_to_stdout (s, strict = True): + def read (s, strict = True): + if not os.path.exists (s): if strict: print >> sys.stderr, "%s: %s does not exist" (sys.argv[0], s) sys.exit (1) return - if os.path.isdir (s): + s = os.path.normpath (s) - if s[-1] in '/\\': - s = s[:-1] + if os.path.isdir (s): try: m = file (os.path.join (s, "MANIFEST")) items = [x.strip () for x in m.readlines ()] for f in items: - Manifest.print_to_stdout (s + f) + for p in Manifest.read (os.path.join (s, f)): + yield p except IOError: if strict: print >> sys.stderr, "%s: %s does not exist" (sys.argv[0], os.path.join (s, "MANIFEST")) sys.exit (1) return else: - print s + yield s + + @staticmethod + def print_to_stdout (s, strict = True): + for f in Manifest.read (s, strict=strict): + print f @staticmethod def update_recursive (s):