parameters: (self, fg_color, bg_color)
return_statement: return map(six.text_type, result)
docstring: Return a tuple with the vt100 values  that represent this color.
docstring_summary: Return a tuple with the vt100 values  that represent this color.
docstring_tokens: Return a tuple with the vt100 values that represent this color .
function: def _colors_to_code(self, fg_color, bg_color):
          " Return a tuple with the vt100 values  that represent this color. "
          # When requesting ANSI colors only, and both fg/bg color were converted
          # to ANSI, ensure that the foreground and background color are not the
          # same. (Unless they were explicitely defined to be the same color.)
          fg_ansi = [()]
  
          def get(color, bg):
              table = BG_ANSI_COLORS if bg else FG_ANSI_COLORS
  
              if color is None:
                  return ()
  
              # 16 ANSI colors. (Given by name.)
              elif color in table:
                  return (table[color], )
  
              # RGB colors. (Defined as 'ffffff'.)
              else:
                  try:
                      rgb = self._color_name_to_rgb(color)
                  except ValueError:
                      return ()
  
                  # When only 16 colors are supported, use that.
                  if self.ansi_colors_only():
                      if bg:  # Background.
                          if fg_color != bg_color:
                              exclude = (fg_ansi[0], )
                          else:
                              exclude = ()
                          code, name = _16_bg_colors.get_code(rgb, exclude=exclude)
                          return (code, )
                      else:  # Foreground.
                          code, name = _16_fg_colors.get_code(rgb)
                          fg_ansi[0] = name
                          return (code, )
  
                  # True colors. (Only when this feature is enabled.)
                  elif self.true_color:
                      r, g, b = rgb
                      return (48 if bg else 38, 2, r, g, b)
  
                  # 256 RGB colors.
                  else:
                      return (48 if bg else 38, 5, _256_colors[rgb])
  
          result = []
          result.extend(get(fg_color, False))
          result.extend(get(bg_color, True))
  
          return map(six.text_type, result)
function_tokens: def _colors_to_code ( self , fg_color , bg_color ) : # When requesting ANSI colors only, and both fg/bg color were converted # to ANSI, ensure that the foreground and background color are not the # same. (Unless they were explicitely defined to be the same color.) fg_ansi = [ ( ) ] def get ( color , bg ) : table = BG_ANSI_COLORS if bg else FG_ANSI_COLORS if color is None : return ( ) # 16 ANSI colors. (Given by name.) elif color in table : return ( table [ color ] , ) # RGB colors. (Defined as 'ffffff'.) else : try : rgb = self . _color_name_to_rgb ( color ) except ValueError : return ( ) # When only 16 colors are supported, use that. if self . ansi_colors_only ( ) : if bg : # Background. if fg_color != bg_color : exclude = ( fg_ansi [ 0 ] , ) else : exclude = ( ) code , name = _16_bg_colors . get_code ( rgb , exclude = exclude ) return ( code , ) else : # Foreground. code , name = _16_fg_colors . get_code ( rgb ) fg_ansi [ 0 ] = name return ( code , ) # True colors. (Only when this feature is enabled.) elif self . true_color : r , g , b = rgb return ( 48 if bg else 38 , 2 , r , g , b ) # 256 RGB colors. else : return ( 48 if bg else 38 , 5 , _256_colors [ rgb ] ) result = [ ] result . extend ( get ( fg_color , False ) ) result . extend ( get ( bg_color , True ) ) return map ( six . text_type , result )