def validateBGColor(color):
 if (type(color) == str):
  if (color[0] != '#'):
   color = ('#' + color)
  if (len(color) != 7):
   raise ValidationException(('%r is not a valid color.  Expected HTML color syntax (i.e. #RRGGBB)' % color))
  try:
   r = int(color[1:3], 16)
   g = int(color[3:5], 16)
   b = int(color[5:7], 16)
   return (r, g, b, 0)
  except ValueError:
   raise ValidationException(('%r is not a valid color.  Expected HTML color syntax (i.e. #RRGGBB)' % color))
 elif (type(color) == tuple):
  if (len(color) != 4):
   raise ValidationException(('%r is not a valid color.  Expected a 4-tuple' % (color,)))
  return color

def validateBGColor ( color ) : if ( type ( color ) == str ) : if ( color [ 0 ] != '#' ) : color = ( '#' + color ) if ( len ( color ) != 7 ) : raise ValidationException ( ( '%r is not a valid color.  Expected HTML color syntax (i.e. #RRGGBB)' % color ) ) try : r = int ( color [ 1 : 3 ] , 16 ) g = int ( color [ 3 : 5 ] , 16 ) b = int ( color [ 5 : 7 ] , 16 ) return ( r , g , b , 0 ) except ValueError : raise ValidationException ( ( '%r is not a valid color.  Expected HTML color syntax (i.e. #RRGGBB)' % color ) ) elif ( type ( color ) == tuple ) : if ( len ( color ) != 4 ) : raise ValidationException ( ( '%r is not a valid color.  Expected a 4-tuple' % ( color , ) ) ) return color
bg color must be an html color .