summaryrefslogtreecommitdiffstats
path: root/Tools
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>1998-10-02 14:43:30 (GMT)
committerBarry Warsaw <barry@python.org>1998-10-02 14:43:30 (GMT)
commit8be2594a2428a18ade0cfa3e6d5d256308c1c8dd (patch)
tree59c99a1717da74f943284644822225314fdfc88b /Tools
parentad678af89b7f60c82f78111fac144065e861a0aa (diff)
downloadcpython-8be2594a2428a18ade0cfa3e6d5d256308c1c8dd.zip
cpython-8be2594a2428a18ade0cfa3e6d5d256308c1c8dd.tar.gz
cpython-8be2594a2428a18ade0cfa3e6d5d256308c1c8dd.tar.bz2
all_names(): Return just the unique names of rgb colors
Diffstat (limited to 'Tools')
-rw-r--r--Tools/pynche/ColorDB.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/Tools/pynche/ColorDB.py b/Tools/pynche/ColorDB.py
index 5191d2b..435e0ad 100644
--- a/Tools/pynche/ColorDB.py
+++ b/Tools/pynche/ColorDB.py
@@ -40,6 +40,8 @@ class ColorDB:
# key is name, value is (red, green, blue)
self.__byname = {}
#
+ # all unique names (non-aliases). built-on demand
+ self.__allnames = None
while 1:
line = fp.readline()
if not line:
@@ -101,6 +103,15 @@ class ColorDB:
nearest = distance
nearest_name = name
return nearest_name
+
+ def all_names(self):
+ # sorted
+ if not self.__allnames:
+ self.__allnames = []
+ for name, aliases in self.__byrgb.values():
+ self.__allnames.append(name)
+ self.__allnames.sort()
+ return self.__allnames
class RGBColorDB(ColorDB):