(value)
Help with parsing color values prefixed with pound signs.

    Accepts:
    * '#RGB'
    * '#RGBA'
    * '#RRGGBB'
    * '#RRGGBBAA'
Help with parsing color values prefixed with pound signs.
Help with parsing color values prefixed with pound signs .
def pound_sign_color(value):
    """Help with parsing color values prefixed with pound signs.

    Accepts:
    * '#RGB'
    * '#RGBA'
    * '#RRGGBB'
    * '#RRGGBBAA'
    """

    if len(value) == 4:
        return rgb(
            r=int(value[1] + value[1], 16),
            g=int(value[2] + value[2], 16),
            b=int(value[3] + value[3], 16),
        )
    elif len(value) == 5:
        return rgb(
            r=int(value[1] + value[1], 16),
            g=int(value[2] + value[2], 16),
            b=int(value[3] + value[3], 16),
            a=int(value[4] + value[4], 16) / 0xff,
        )
    elif len(value) == 7:
        return rgb(
            r=int(value[1:3], 16),
            g=int(value[3:5], 16),
            b=int(value[5:7], 16),
        )
    elif len(value) == 9:
        return rgb(
            r=int(value[1:3], 16),
            g=int(value[3:5], 16),
            b=int(value[5:7], 16),
            a=int(value[7:9], 16) / 0xff,
        )
    else:
        raise ValueError('Unknown color %s' % value)
def pound_sign_color ( value ) : if len ( value ) == 4 : return rgb ( r = int ( value [ 1 ] + value [ 1 ] , 16 ) , g = int ( value [ 2 ] + value [ 2 ] , 16 ) , b = int ( value [ 3 ] + value [ 3 ] , 16 ) , ) elif len ( value ) == 5 : return rgb ( r = int ( value [ 1 ] + value [ 1 ] , 16 ) , g = int ( value [ 2 ] + value [ 2 ] , 16 ) , b = int ( value [ 3 ] + value [ 3 ] , 16 ) , a = int ( value [ 4 ] + value [ 4 ] , 16 ) / 0xff , ) elif len ( value ) == 7 : return rgb ( r = int ( value [ 1 : 3 ] , 16 ) , g = int ( value [ 3 : 5 ] , 16 ) , b = int ( value [ 5 : 7 ] , 16 ) , ) elif len ( value ) == 9 : return rgb ( r = int ( value [ 1 : 3 ] , 16 ) , g = int ( value [ 3 : 5 ] , 16 ) , b = int ( value [ 5 : 7 ] , 16 ) , a = int ( value [ 7 : 9 ] , 16 ) / 0xff , ) else : raise ValueError ( 'Unknown color %s' % value )