def normalize_hex(hex_value):
match = HEX_COLOR_RE.match(hex_value)<EOL>if match is None:<EOL><INDENT>raise ValueError(<EOL>u"<STR_LIT>".format(hex_value)<EOL>)<EOL><DEDENT>hex_digits = match.group(<NUM_LIT:1>)<EOL>if len(hex_digits) == <NUM_LIT:3>:<EOL><INDENT>hex_digits = u'<STR_LIT>'.join(<NUM_LIT:2> * s for s in hex_digits)<EOL><DEDENT>return u'<STR_LIT>'.format(hex_digits.lower())<EOL>
Normalize a hexadecimal color value to 6 digits, lowercase.