From cc0451f30bbe16def8b56b14540f05dbd35c1e62 Mon Sep 17 00:00:00 2001
From: Guido Trotter <ultrotter@google.com>
Date: Mon, 29 Oct 2007 15:20:29 +0000
Subject: [PATCH] Convert ListOS to use the all helper function.

The predicate function gets build by a lambda function.
Also add a bit of debugging information to the 'unknown OS diagnose type'.


Reviewed-by: iustinp
---
 scripts/gnt-os | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/scripts/gnt-os b/scripts/gnt-os
index 82c2671f7..a13d2ca89 100755
--- a/scripts/gnt-os
+++ b/scripts/gnt-os
@@ -45,7 +45,7 @@ def _DiagnoseOSValid(obj):
   elif isinstance(obj, errors.InvalidOS):
     return False
   else:
-    raise errors.ProgrammerError('unknown OS diagnose type')
+    raise errors.ProgrammerError("unknown OS diagnose type: '%s'" % type(obj))
 
 
 def _DiagnoseOSName(obj):
@@ -126,12 +126,8 @@ def ListOS(opts, args):
   for os_name, os_node_data in all_os.iteritems():
     if len(os_node_data) != num_nodes:
       continue
-    valid = True
-    for l in os_node_data.values():
-      if not _DiagnoseOSValid(l[0]):
-        valid = False
-        break
-    if valid:
+
+    if utils.all(os_node_data.values(), lambda l: _DiagnoseOSValid(l[0])):
       valid_os.append(os_name)
 
   if not opts.no_headers:
-- 
GitLab