forked from qt-creator/qt-creator
Squish: Make another helper tool compatible
Change-Id: I1fc4e268e311c628b541b76ae3a948854635a4a5 Reviewed-by: Robert Loehning <robert.loehning@qt.io>
This commit is contained in:
@@ -30,6 +30,9 @@ import sys
|
|||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
from toolfunctions import checkDirectory
|
from toolfunctions import checkDirectory
|
||||||
from toolfunctions import getFileContent
|
from toolfunctions import getFileContent
|
||||||
|
if sys.version_info.major == 3:
|
||||||
|
from functools import reduce
|
||||||
|
|
||||||
|
|
||||||
def parseCommandLine():
|
def parseCommandLine():
|
||||||
global directory, tsv
|
global directory, tsv
|
||||||
@@ -43,11 +46,12 @@ def parseCommandLine():
|
|||||||
elif len(args) == 1:
|
elif len(args) == 1:
|
||||||
directory = os.path.abspath(args[0])
|
directory = os.path.abspath(args[0])
|
||||||
else:
|
else:
|
||||||
print "\nERROR: Too many arguments\n"
|
print("\nERROR: Too many arguments\n")
|
||||||
parser.print_help()
|
parser.print_help()
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
tsv = options.tsv
|
tsv = options.tsv
|
||||||
|
|
||||||
|
|
||||||
def readProperties(line):
|
def readProperties(line):
|
||||||
def readOneProperty(rawProperties):
|
def readOneProperty(rawProperties):
|
||||||
name, rawProperties = rawProperties.split("=", 1)
|
name, rawProperties = rawProperties.split("=", 1)
|
||||||
@@ -64,6 +68,7 @@ def readProperties(line):
|
|||||||
properties[name] = value
|
properties[name] = value
|
||||||
return objectName, properties
|
return objectName, properties
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
global directory, tsv
|
global directory, tsv
|
||||||
objMap = checkDirectory(directory)
|
objMap = checkDirectory(directory)
|
||||||
@@ -74,20 +79,21 @@ def main():
|
|||||||
usedProperties = list(reduce(lambda x, y: x | y, eachObjectsProperties))
|
usedProperties = list(reduce(lambda x, y: x | y, eachObjectsProperties))
|
||||||
|
|
||||||
if tsv:
|
if tsv:
|
||||||
print "\t".join(["Squish internal name"] + usedProperties)
|
print("\t".join(["Squish internal name"] + usedProperties))
|
||||||
for name, properties in objects.items():
|
for name, properties in objects.items():
|
||||||
values = [name] + map(lambda x: properties.setdefault(x, ""), usedProperties)
|
values = [name] + map(lambda x: properties.setdefault(x, ""), usedProperties)
|
||||||
print "\t".join(values)
|
print("\t".join(values))
|
||||||
else:
|
else:
|
||||||
maxPropertyLength = max(map(len, usedProperties))
|
maxPropertyLength = max(map(len, usedProperties))
|
||||||
for name, properties in objects.items():
|
for name, properties in objects.items():
|
||||||
print "Squish internal name: %s" % name
|
print("Squish internal name: %s" % name)
|
||||||
print "Properties:"
|
print("Properties:")
|
||||||
for key, val in properties.items():
|
for key, val in properties.items():
|
||||||
print "%s: %s" % (key.rjust(maxPropertyLength + 4), val)
|
print("%s: %s" % (key.rjust(maxPropertyLength + 4), val))
|
||||||
print
|
print()
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
parseCommandLine()
|
parseCommandLine()
|
||||||
sys.exit(main())
|
sys.exit(main())
|
||||||
|
Reference in New Issue
Block a user