@memoized
def getColor(value, default=None):
 if isinstance(value, Color):
  return value
 value = str(value).strip().lower()
 if ((value == 'transparent') or (value == 'none')):
  return default
 if (value in COLOR_BY_NAME):
  return COLOR_BY_NAME[value]
 if (value.startswith('#') and (len(value) == 4)):
  value = (((((('#' + value[1]) + value[1]) + value[2]) + value[2]) + value[3]) + value[3])
 elif rgb_re.search(value):
  (r, g, b) = [int(x) for x in rgb_re.search(value).groups()]
  value = ('#%02x%02x%02x' % (r, g, b))
 else:
  pass
 return toColor(value, default)

@ memoized def getColor ( value , default = None ) : if isinstance ( value , Color ) : return value value = str ( value ) . strip ( ) . lower ( ) if ( ( value == 'transparent' ) or ( value == 'none' ) ) : return default if ( value in COLOR_BY_NAME ) : return COLOR_BY_NAME [ value ] if ( value . startswith ( '#' ) and ( len ( value ) == 4 ) ) : value = ( ( ( ( ( ( '#' + value [ 1 ] ) + value [ 1 ] ) + value [ 2 ] ) + value [ 2 ] ) + value [ 3 ] ) + value [ 3 ] ) elif rgb_re . search ( value ) : ( r , g , b ) = [ int ( x ) for x in rgb_re . search ( value ) . groups ( ) ] value = ( '#%02x%02x%02x' % ( r , g , b ) ) else : pass return toColor ( value , default )
convert to color value .