class_docstr: Color palette for palette mapped images
  
  :param mode: The mode to use for the Palette. See:
      :ref:`concept-modes`. Defaults to "RGB"
  :param palette: An optional palette. If given, it must be a bytearray,
      an array or a list of ints between 0-255 and of length ``size``
      times the number of colors in ``mode``. The list must be aligned
      by channel (All R values must be contiguous in the list before G
      and B values.) Defaults to 0 through 255 per channel.
  :param size: An optional palette size. If given, it cannot be equal to
      or greater than 256. Defaults to 0.
class_docstr_tok: ["Color","palette","for","palette","mapped","images",":","param","mode",":","The","mode","to","use","for","the","Palette",".","See",":",":","ref",":","`","concept-modes","`",".","Defaults","to","``","RGB","''",":","param","palette",":","An","optional","palette",".","If","given",",","it","must","be","a","bytearray",",","an","array","or","a","list","of","ints","between","0-255","and","of","length","``","size","``","times","the","number","of","colors","in","``","mode","``",".","The","list","must","be","aligned","by","channel","(","All","R","values","must","be","contiguous","in","the","list","before","G","and","B","values",".",")","Defaults","to","0","through","255","per","channel",".",":","param","size",":","An","optional","palette","size",".","If","given",",","it","can","not","be","equal","to","or","greater","than","256",".","Defaults","to","0","."]
docstr: Given an rgb tuple, allocate palette entry.
  
  .. warning:: This method is experimental.
docstr_tok: ["Given","an","rgb","tuple",",","allocate","palette","entry",".","..","warning",":",":","This","method","is","experimental","."]
code: def getcolor(self, color):
      """Given an rgb tuple, allocate palette entry.
  
      .. warning:: This method is experimental.
      """
      if self.rawmode:
          raise ValueError("palette contains raw palette data")
      if isinstance(color, tuple):
          try:
              return self.colors[color]
          except KeyError:
              # allocate new color slot
              if isinstance(self.palette, bytes):
                  self.palette = bytearray(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)
  
file_path: catboost/contrib/python/Pillow/py2/PIL/ImagePalette.py
imports: import array
  from .None import GimpGradientFile, GimpPaletteFile, ImageColor, PaletteFile
label_desc: Use image node_id 5 for calling the ImagePalette obj's underlying member method code with example usage: obj.getcolor(color) and returns: self, index