def find_nearest_color_hexstr(hexdigits, color_table=None, method='<STR_LIT>'):
triplet = []<EOL>try:<EOL><INDENT>if len(hexdigits) == <NUM_LIT:3>:<EOL><INDENT>for digit in hexdigits:<EOL><INDENT>digit = int(digit, <NUM_LIT:16>)<EOL>triplet.append((digit * <NUM_LIT:16>) + digit)<EOL><DEDENT><DEDENT>elif len(hexdigits) == <NUM_LIT:6>:<EOL><INDENT>triplet.extend(int(hexdigits[i:i+<NUM_LIT:2>], <NUM_LIT:16>) for i in (<NUM_LIT:0>, <NUM_LIT:2>, <NUM_LIT:4>))<EOL><DEDENT>else:<EOL><INDENT>raise ValueError('<STR_LIT>' % hexdigits)<EOL><DEDENT><DEDENT>except ValueError:<EOL><INDENT>return None<EOL><DEDENT>return find_nearest_color_index(*triplet,<EOL>color_table=color_table,<EOL>method=method)<EOL>
Given a three or six-character hex digit string, return the nearest
        color index.

        Arguments:
            hexdigits:  a three/6 digit hex string, e.g. 'b0b', '123456'

        Returns:
            int, None: index, or None on error.