def color_to_reportlab(color):
 if isinstance(color, colors.Color):
  return color
 elif isinstance(color, str):
  if color.startswith('0x'):
   color.replace('0x', '#')
  if (len(color) == 7):
   return colors.HexColor(color)
  else:
   try:
    return colors.HexColor(color, hasAlpha=True)
   except TypeError:
    raise RuntimeError('Your reportlab seems to be too old, try 2.7 onwards')
 elif isinstance(color, tuple):
  return colors.Color(*color)
 return color

def color_to_reportlab ( color ) : if isinstance ( color , colors . Color ) : return color elif isinstance ( color , str ) : if color . startswith ( '0x' ) : color . replace ( '0x' , '#' ) if ( len ( color ) == 7 ) : return colors . HexColor ( color ) else : try : return colors . HexColor ( color , hasAlpha = True ) except TypeError : raise RuntimeError ( 'Your reportlab seems to be too old, try 2.7 onwards' ) elif isinstance ( color , tuple ) : return colors . Color ( * color ) return color
returns the passed color in reportlab color format .