remove itertools.product so pmacs works in python 2.5

--HG--
branch : pmacs2
This commit is contained in:
Erik Osheim 2010-05-22 20:00:22 -04:00
parent fedbd0d50c
commit 5cd69146a6
1 changed files with 15 additions and 13 deletions

View File

@ -33,24 +33,26 @@ def add_color(name, value, abbrev):
# assign every RGB triple (0-5) to one of six basic colors (red, yellow, green,
# cyan, blue, magenta) based on some semi-arbitrary rules i came up with.
def iter256():
ns = range(0, 6)
for r, g, b in itertools.product(ns, ns, ns):
if r >= g and g > b: name = 'yellow'
elif r >= b and b - g > 1: name = 'magenta'
ns = list(range(0, 6))
for r in ns:
for g in ns:
for b in ns:
if r >= g and g > b: name = 'yellow'
elif r >= b and b - g > 1: name = 'magenta'
elif b >= g and g - r > 2: name = 'cyan'
elif b >= r and r > g: name = 'magenta'
elif b >= g and g - r > 2: name = 'cyan'
elif b >= r and r > g: name = 'magenta'
elif g >= r and r - b > 2: name = 'yellow'
elif g >= b and b - r > 1: name = 'cyan'
elif g >= r and r - b > 2: name = 'yellow'
elif g >= b and b - r > 1: name = 'cyan'
elif r > b and r > g: name = 'red'
elif g > b and g > r: name = 'green'
elif b > r and b > g: name = 'blue'
elif r > b and r > g: name = 'red'
elif g > b and g > r: name = 'green'
elif b > r and b > g: name = 'blue'
else: continue
else: continue
yield (name, r, g, b)
yield (name, r, g, b)
raise StopIteration
# if we can support 256 colors, create all of the color names and map them to