Next / Previous / Contents / Shipman's homepage

14.11. PickList.__cleanColorMap(): Remove redundant colors

This method removes duplicate color names. There are two mechanisms that create these:

Because of these variations, there may be as many as four names for the same color: “LightSlateGray” is also the same color as “light slate grey”.

We'll arbitrary prefer the intercapitalized forms such as “LightSlateGray” to the versions with embedded spaces such as “light slate gray”. Equally arbitrarily, because the author happened to be born in the USA, we'll cast out the “grey” variants.

# - - -   P i c k L i s t . _ _ c l e a n C o l o r M a p

    def __cleanColorMap ( self ):
        """Remove redundant colors from the color map.

          [ self.__colorMap  :=  self.__colorMap with redundant colors
                removed ]

        #-- 1 --
        # [ nameList  :=  keys of self.__colorMap ]
        nameList  =  self.__colorMap.keys()

The logic for removing less preferred names is in Section 14.12, “PickList.__nameCleaner(): Remove redundant color names”.

        #-- 2 --
        # [ self.__colorMap  :=  self.__colorMap with names removed
        #      when those names are less preferred alternatives to
        #      names in nameList ]
        for  colorName in nameList:
            self.__nameCleaner ( colorName )