This method takes as an argument one of the keys to self.__colorMap, an uppercased color name. Its purpose
is to find any other entries in self.__colorMap
whose keys are less preferred names, and remove them.
# - - - P i c k L i s t . _ _ n a m e C l e a n e r
def __nameCleaner ( self, colorName ):
"""Remove any redundant names dominated by colorName.
[ colorName is a key in self.__colorMap ->
self.__colorMap := self.__colorMap with any entries
removed whose keys are less-preferred alternatives
to colorName ]
"""
For general remarks on the preference rules for color names, see
Section 14.11, “PickList.__cleanColorMap(): Remove redundant
colors”.
Because intercapitalized color names such as "DodgerBlue" are stored under their uppercase
equivalents such as "DODGERBLUE", we need
to pull out the original color name, or we won't know
where spaces are to be inserted. If this lookup fails, that's
okay, because the name may already have been purged. For
example, the name “DarkGray” might purge
“dark grey”, and then later when “dark
gray” comes along it will also try to purge “dark
grey”, but find that it's already gone.
#-- 1 --
# [ if colorName is a key in self.__colorMap ->
# origName := corresponding value's color
# else -> return ]
try:
origName = self.__colorMap [ colorName.upper() ] [ 2 ]
except KeyError:
return
There are two transformations on colorName to
convert to the key for a less-preferred version. The .__lowerize() method converts intercapitalized names
like “DodgerBlue” to their
space-embedded equivalents such as "dodger blue".
The .__anglicize() method converts the American
spelling “gray” to the English spelling
“grey”. However, we most also purge the list of
names to which both transformations are
applied.
#-- 2 --
# [ anglican := colorName with 'gray' -> 'grey' ]
anglican = self.__anglicize ( origName )
#-- 2 --
# [ if self.__colorMap has a key (anglican) ->
# self.__colorMap := self.__colorMap with that key's
# entry removed
# else -> I ]
self.__purgeName ( origName, anglican )
#-- 3 --
# [ if self.__colorMap has a key self.__lowerize(colorName) ->
# self.__colorMap := self.__colorMap with that key's
# entry removed
# else -> I ]
self.__purgeName ( origName, self.__lowerize ( origName ) )
#-- 4 --
# [ if self.__colorMap has a key self.__lowerize(anglican) ->
# self.__colorMap := self.__colorMap with that key's
# entry removed
# else -> I ]
self.__purgeName ( origName, self.__lowerize ( anglican ) )