def getcolor(self, color):
        # experimental: given an rgb tuple, allocate palette entry
        if self.rawmode:
            raise ValueError("palette contains raw palette data")
        if Image.isTupleType(color):
            try:
                return self.colors[color]
            except __HOLE__:
                # allocate new color slot
                if Image.isStringType(self.palette):
                    self.palette = map(int, self.palette)
                index = len(self.colors)
                if index >= 256:
                    raise ValueError("cannot allocate more than 256 colors")
                self.colors[color] = index
                self.palette[index] = color[0]
                self.palette[index+256] = color[1]
                self.palette[index+512] = color[2]
                self.dirty = 1
                return index
        else:
            raise ValueError("unknown color specifier: %r" % color)
dataset/ETHPy150Open kleientertainment/ds_mod_tools/pkg/win32/Python27/Lib/site-packages/PIL/ImagePalette.py/ImagePalette.getcolor