This puts the list of statuses in one place, a frozenset containing references to all of the status constants; and a set containing the strings of all of the statues. This should clean up a bunch of things in summary code
Signed-off-by: Dylan Baker <[email protected]> --- framework/status.py | 14 +++++++++++++- piglit-summary-html.py | 15 +++++++++------ 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/framework/status.py b/framework/status.py index bb7c594..9f1cf09 100644 --- a/framework/status.py +++ b/framework/status.py @@ -62,7 +62,10 @@ __all__ = ['NOTRUN', 'CRASH', 'DMESG_WARN', 'DMESG_FAIL', - 'SKIP'] + 'SKIP', + 'ALL', + 'ALL_TEXT'] + def status_lookup(status): """ Provided a string return a status object instance @@ -233,3 +236,12 @@ DMESG_FAIL = Status('dmesg-fail', 30) FAIL = Status('fail', 40) CRASH = Status('crash', 50) + +# A frozenset (unordered, immutable) of all statuses in this module +ALL = frozenset([NOTRUN, SKIP, PASS, DMESG_WARN, WARN, DMESG_FAIL, FAIL, + CRASH]) + +# A set (unordered, mutable) of all statuses as strings. +# This set is mutable since it might be useful to add or subtract from it, whic +# the list of statuses is set in stone +ALL_TEXT = set([str(x) for x in ALL]) diff --git a/piglit-summary-html.py b/piglit-summary-html.py index 4a51721..4a085e6 100755 --- a/piglit-summary-html.py +++ b/piglit-summary-html.py @@ -34,6 +34,11 @@ sys.path.append(path.dirname(path.realpath(sys.argv[0]))) def main(): + # Make a copy of the status text list and add all. This is used as the + # argument list for -e/--exclude + statuses = status.ALL_TEXT.copy() + statuses.add('all') + parser = argparse.ArgumentParser() parser.add_argument("-o", "--overwrite", action="store_true", @@ -46,8 +51,7 @@ def main(): parser.add_argument("-e", "--exclude-details", default=[], action="append", - choices=['skip', 'pass', 'warn', 'crash' 'fail', - 'all'], + choices=statuses, help="Optionally exclude the generation of HTML pages " "for individual test pages with the status(es) " "given as arguments. This speeds up HTML " @@ -71,11 +75,10 @@ def main(): if args.exclude_details: # If exclude-results has all, then change it to be all if 'all' in args.exclude_details: - args.exclude_details = [status.SKIP, status.PASS, status.WARN, - status.CRASH, status.FAIL] + args.exclude_details = status.ALL else: - args.exclude_details = [status.status_lookup(i) for i in - args.exclude_details] + args.exclude_details = frozenset( + [status.status_lookup(i) for i in args.exclude_details]) # if overwrite is requested delete the output directory -- 1.9.1 _______________________________________________ Piglit mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/piglit
