parameters: (hex_value)
return_statement: return '#%s' % hex_digits.lower()
docstring: Normalize a hexadecimal color value to the following form and
      return the result::
  
          #[a-f0-9]{6}
  
      In other words, the following transformations are applied as
      needed:
  
      * If the value contains only three hexadecimal digits, it is
        expanded to six.
  
      * The value is normalized to lower-case.
  
      If the supplied value cannot be interpreted as a hexadecimal color
      value, ``ValueError`` is raised.
  
      Examples:
  
      >>> normalize_hex('#09c')
      '#0099cc'
      >>> normalize_hex('#0099cc')
      '#0099cc'
      >>> normalize_hex('#09C')
      '#0099cc'
      >>> normalize_hex('#0099CC')
      '#0099cc'
      >>> normalize_hex('0099cc')
      Traceback (most recent call last):
          ...
      ValueError: '0099cc' is not a valid hexadecimal color value.
      >>> normalize_hex('#0099QX')
      Traceback (most recent call last):
          ...
      ValueError: '#0099QX' is not a valid hexadecimal color value.
      >>> normalize_hex('foobarbaz')
      Traceback (most recent call last):
          ...
      ValueError: 'foobarbaz' is not a valid hexadecimal color value.
      >>> normalize_hex('#0')
      Traceback (most recent call last):
          ...
      ValueError: '#0' is not a valid hexadecimal color value.
docstring_summary: Normalize a hexadecimal color value to the following form and
      return the result::
docstring_tokens: Normalize a hexadecimal color value to the following form and return the result ::
function: def normalize_hex(hex_value):
      """
      Normalize a hexadecimal color value to the following form and
      return the result::
  
          #[a-f0-9]{6}
  
      In other words, the following transformations are applied as
      needed:
  
      * If the value contains only three hexadecimal digits, it is
        expanded to six.
  
      * The value is normalized to lower-case.
  
      If the supplied value cannot be interpreted as a hexadecimal color
      value, ``ValueError`` is raised.
  
      Examples:
  
      >>> normalize_hex('#09c')
      '#0099cc'
      >>> normalize_hex('#0099cc')
      '#0099cc'
      >>> normalize_hex('#09C')
      '#0099cc'
      >>> normalize_hex('#0099CC')
      '#0099cc'
      >>> normalize_hex('0099cc')
      Traceback (most recent call last):
          ...
      ValueError: '0099cc' is not a valid hexadecimal color value.
      >>> normalize_hex('#0099QX')
      Traceback (most recent call last):
          ...
      ValueError: '#0099QX' is not a valid hexadecimal color value.
      >>> normalize_hex('foobarbaz')
      Traceback (most recent call last):
          ...
      ValueError: 'foobarbaz' is not a valid hexadecimal color value.
      >>> normalize_hex('#0')
      Traceback (most recent call last):
          ...
      ValueError: '#0' is not a valid hexadecimal color value.
  
      """
      try:
          hex_digits = HEX_COLOR_RE.match(hex_value).groups()[0]
      except AttributeError:
          raise ValueError("'%s' is not a valid hexadecimal color value." % hex_value)
      if len(hex_digits) == 3:
          hex_digits = ''.join(map(lambda s: 2 * s, hex_digits))
      return '#%s' % hex_digits.lower()
function_tokens: def normalize_hex ( hex_value ) : try : hex_digits = HEX_COLOR_RE . match ( hex_value ) . groups ( ) [ 0 ] except AttributeError : raise ValueError ( "'%s' is not a valid hexadecimal color value." % hex_value ) if len ( hex_digits ) == 3 : hex_digits = '' . join ( map ( lambda s : 2 * s , hex_digits ) ) return '#%s' % hex_digits . lower ( )