This method takes two arguments. The goodName
argument is a color name; badName is a
less-preferred alternative.
# - - - P i c k L i s t . _ _ p u r g e N a m e
def __purgeName ( self, goodName, badName ):
"""If badName is redundant for goodName, remove it.
[ (goodName is a color name in self.__colorMap) and
(badName is a string) ->
if goodName == badName ->
I
else if badName is a color name in self.__colorMap
that is the same color as self.__colorMap[goodName] ->
self.__colorMap := self.__colorName with its
entry for badName removed
else -> I ]
"""
First we test to see if goodName and badName are the same. For example, the .__lowerize() transformation on "red"
yields "red". In this case we return.
#-- 1 --
if goodName == badName:
return
Next, test to see if badName is even in the color
map. If not, return. If it is there, retrieve the colors for
both names.
#-- 2 --
# [ if badName is a key in self.__colorMap ->
# goodColor := self's color for goodName
# badColor := self's color for badName
# else ->
# return ]
badColor = self.lookupName ( badName )
if badColor is None:
return
else:
goodColor = self.lookupName ( goodName )
If the colors are the same, we can safely remove the less preferred one. If they don't match, just for safety, retain the bad color.
#-- 3 --
# [ if badColor == goodColor ->
# self.__colorMap := self.__colorMap with the entry
# for badColor removed
# else -> I ]
if badColor == goodColor:
badKey = badName.upper()
del self.__colorMap [ badKey ]