Commit bf220bf7 authored by Pino Toscano's avatar Pino Toscano
Browse files

colorchecker.py: make colorList a set

It is used as such already.
parent b5513a55
...@@ -50,7 +50,7 @@ for fileIndex in range(1, len(sys.argv)): ...@@ -50,7 +50,7 @@ for fileIndex in range(1, len(sys.argv)):
print ("Error: Map file {} does not exist".format(imagePath)) print ("Error: Map file {} does not exist".format(imagePath))
sys.exit(2) sys.exit(2)
colorList = []; colorList = set()
divisionTag = root.firstChildElement("division"); divisionTag = root.firstChildElement("division");
while not divisionTag.isNull(): while not divisionTag.isNull():
colorTag = divisionTag.firstChildElement("color"); colorTag = divisionTag.firstChildElement("color");
...@@ -59,7 +59,7 @@ for fileIndex in range(1, len(sys.argv)): ...@@ -59,7 +59,7 @@ for fileIndex in range(1, len(sys.argv)):
blue = int(colorTag.firstChildElement("blue").text()) blue = int(colorTag.firstChildElement("blue").text())
rgba = (red, green, blue, 255) rgba = (red, green, blue, 255)
if rgba not in colorList: if rgba not in colorList:
colorList.append(rgba) colorList.add(rgba)
else: else:
print("Error: The color {},{},{} is used more than once in the kgm file".format(red, green, blue)) print("Error: The color {},{},{} is used more than once in the kgm file".format(red, green, blue))
...@@ -71,7 +71,7 @@ for fileIndex in range(1, len(sys.argv)): ...@@ -71,7 +71,7 @@ for fileIndex in range(1, len(sys.argv)):
print("Error: The PNG file should be in indexed color mode") print("Error: The PNG file should be in indexed color mode")
image = image.convert('RGBA') image = image.convert('RGBA')
usedColors = set([rgba for count, rgba in image.getcolors()]) usedColors = set([rgba for count, rgba in image.getcolors()])
notFoundColors = usedColors - set(colorList) notFoundColors = usedColors - colorList
error |= len(notFoundColors) > 0 error |= len(notFoundColors) > 0
if notFoundColors: if notFoundColors:
...@@ -86,7 +86,7 @@ for fileIndex in range(1, len(sys.argv)): ...@@ -86,7 +86,7 @@ for fileIndex in range(1, len(sys.argv)):
x, y, rgba[0], rgba[1], rgba[2], rgba[3])) x, y, rgba[0], rgba[1], rgba[2], rgba[3]))
notFoundColorsToSearch.remove(rgba) notFoundColorsToSearch.remove(rgba)
nonUsedColors = set(colorList) nonUsedColors = colorList
nonUsedColors.difference_update(usedColors) nonUsedColors.difference_update(usedColors)
error |= len(nonUsedColors) > 0 error |= len(nonUsedColors) > 0
for rgba in nonUsedColors: for rgba in nonUsedColors:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment