summaryrefslogtreecommitdiffstats
path: root/Tools
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>1998-10-02 15:59:20 (GMT)
committerBarry Warsaw <barry@python.org>1998-10-02 15:59:20 (GMT)
commit9f3ea211dd91968ddde9e3ed25cde755ac27fe2c (patch)
tree8b8c2a4bd7d8fba695cf896b9d1a3c02561a89ba /Tools
parentddb9fc1ebd0c019c0c651e4335d6cdfd043ef7c5 (diff)
downloadcpython-9f3ea211dd91968ddde9e3ed25cde755ac27fe2c.zip
cpython-9f3ea211dd91968ddde9e3ed25cde755ac27fe2c.tar.gz
cpython-9f3ea211dd91968ddde9e3ed25cde755ac27fe2c.tar.bz2
all_names(): => unique_names()
aliases_of(): New method
Diffstat (limited to 'Tools')
-rw-r--r--Tools/pynche/ColorDB.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/Tools/pynche/ColorDB.py b/Tools/pynche/ColorDB.py
index 435e0ad..ed7f6b1 100644
--- a/Tools/pynche/ColorDB.py
+++ b/Tools/pynche/ColorDB.py
@@ -104,14 +104,24 @@ class ColorDB:
nearest_name = name
return nearest_name
- def all_names(self):
+ def unique_names(self):
# sorted
if not self.__allnames:
self.__allnames = []
for name, aliases in self.__byrgb.values():
self.__allnames.append(name)
- self.__allnames.sort()
+ # sort irregardless of case
+ def nocase_cmp(n1, n2):
+ return cmp(string.lower(n1), string.lower(n2))
+ self.__allnames.sort(nocase_cmp)
return self.__allnames
+
+ def aliases_of(self, red, green, blue):
+ try:
+ name, aliases = self.__byrgb[(red, green, blue)]
+ except KeyError:
+ raise BadColor((red, green, blue))
+ return [name] + aliases
class RGBColorDB(ColorDB):