def parse_color(color):
if len(color) not in (<NUM_LIT:3>, <NUM_LIT:4>, <NUM_LIT:6>, <NUM_LIT:8>):<EOL><INDENT>raise ValueError('<STR_LIT>' % repr(color))<EOL><DEDENT>if len(color) in (<NUM_LIT:3>, <NUM_LIT:4>):<EOL><INDENT>r = int(color[<NUM_LIT:0>], <NUM_LIT:16>) * <NUM_LIT><EOL>g = int(color[<NUM_LIT:1>], <NUM_LIT:16>) * <NUM_LIT><EOL>b = int(color[<NUM_LIT:2>], <NUM_LIT:16>) * <NUM_LIT><EOL><DEDENT>elif len(color) in (<NUM_LIT:6>, <NUM_LIT:8>):<EOL><INDENT>r = int(color[<NUM_LIT:0>:<NUM_LIT:2>], <NUM_LIT:16>)<EOL>g = int(color[<NUM_LIT:2>:<NUM_LIT:4>], <NUM_LIT:16>)<EOL>b = int(color[<NUM_LIT:4>:<NUM_LIT:6>], <NUM_LIT:16>)<EOL><DEDENT>if len(color) == <NUM_LIT:4>:<EOL><INDENT>a = int(color[<NUM_LIT:3>], <NUM_LIT:16>) * <NUM_LIT><EOL><DEDENT>elif len(color) == <NUM_LIT:8>:<EOL><INDENT>a = int(color[<NUM_LIT:6>:<NUM_LIT:8>], <NUM_LIT:16>)<EOL><DEDENT>else:<EOL><INDENT>a = <NUM_LIT><EOL><DEDENT>return (r, g, b, a)<EOL>
Parse a color value.

    I've decided not to expect a leading '#' because it's a comment character
    in some shells.

        >>> parse_color('4bf') == (0x44, 0xbb, 0xff, 0xff)
        True
        >>> parse_color('ccce') == (0xcc, 0xcc, 0xcc, 0xee)
        True
        >>> parse_color('d8b4a2') == (0xd8, 0xb4, 0xa2, 0xff)
        True
        >>> parse_color('12345678') == (0x12, 0x34, 0x56, 0x78)
        True

    Raises ValueError on errors.