def hex_to_name(hex_value, spec=u'<STR_LIT>'):
if spec not in SUPPORTED_SPECIFICATIONS:<EOL><INDENT>raise ValueError(SPECIFICATION_ERROR_TEMPLATE.format(spec=spec))<EOL><DEDENT>normalized = normalize_hex(hex_value)<EOL>name = {u'<STR_LIT>': CSS2_HEX_TO_NAMES,<EOL>u'<STR_LIT>': CSS21_HEX_TO_NAMES,<EOL>u'<STR_LIT>': CSS3_HEX_TO_NAMES,<EOL>u'<STR_LIT>': HTML4_HEX_TO_NAMES}[spec].get(normalized)<EOL>if name is None:<EOL><INDENT>raise ValueError(<EOL>u"<STR_LIT>".format(hex_value, spec)<EOL>)<EOL><DEDENT>return name<EOL>
Convert a hexadecimal color value to its corresponding normalized
color name, if any such name exists.

The optional keyword argument ``spec`` determines which
specification's list of color names will be used; valid values are
``html4``, ``css2``, ``css21`` and ``css3``, and the default is
``css3``.

When no color name for the value is found in the given
specification, ``ValueError`` is raised.