From 122fdf6e5aab22a8241ca9cff6a04adf24c0cb71 Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Mon, 28 Sep 2020 08:54:12 +0200 Subject: [PATCH] Squish: Make another helper tool compatible Change-Id: I1fc4e268e311c628b541b76ae3a948854635a4a5 Reviewed-by: Robert Loehning --- tests/system/tools/objectsToTable.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/tests/system/tools/objectsToTable.py b/tests/system/tools/objectsToTable.py index 430e3cee2d8..bce82ef4a8d 100755 --- a/tests/system/tools/objectsToTable.py +++ b/tests/system/tools/objectsToTable.py @@ -30,6 +30,9 @@ import sys from optparse import OptionParser from toolfunctions import checkDirectory from toolfunctions import getFileContent +if sys.version_info.major == 3: + from functools import reduce + def parseCommandLine(): global directory, tsv @@ -43,11 +46,12 @@ def parseCommandLine(): elif len(args) == 1: directory = os.path.abspath(args[0]) else: - print "\nERROR: Too many arguments\n" + print("\nERROR: Too many arguments\n") parser.print_help() sys.exit(1) tsv = options.tsv + def readProperties(line): def readOneProperty(rawProperties): name, rawProperties = rawProperties.split("=", 1) @@ -64,6 +68,7 @@ def readProperties(line): properties[name] = value return objectName, properties + def main(): global directory, tsv objMap = checkDirectory(directory) @@ -71,23 +76,24 @@ def main(): # Which properties have been used at least once? eachObjectsProperties = [set(properties.keys()) for properties in objects.values()] - usedProperties = list(reduce(lambda x,y: x | y, eachObjectsProperties)) + usedProperties = list(reduce(lambda x, y: x | y, eachObjectsProperties)) if tsv: - print "\t".join(["Squish internal name"] + usedProperties) + print("\t".join(["Squish internal name"] + usedProperties)) for name, properties in objects.items(): values = [name] + map(lambda x: properties.setdefault(x, ""), usedProperties) - print "\t".join(values) + print("\t".join(values)) else: maxPropertyLength = max(map(len, usedProperties)) for name, properties in objects.items(): - print "Squish internal name: %s" % name - print "Properties:" + print("Squish internal name: %s" % name) + print("Properties:") for key, val in properties.items(): - print "%s: %s" % (key.rjust(maxPropertyLength + 4), val) - print + print("%s: %s" % (key.rjust(maxPropertyLength + 4), val)) + print() return 0 + if __name__ == '__main__': parseCommandLine() sys.exit(main())