parameters: (encoding)
return_statement: return ''.join(chars)
docstring: Normalize an encoding name.
  
          Normalization works as follows: all non-alphanumeric
          characters except the dot used for Python package names are
          collapsed and replaced with a single underscore, e.g. '  -;#'
          becomes '_'. Leading and trailing underscores are removed.
  
          Note that encoding names should be ASCII only; if they do use
          non-ASCII characters, these must be Latin-1 compatible.
docstring_summary: Normalize an encoding name.
docstring_tokens: Normalize an encoding name .
function: def normalize_encoding(encoding):
  
      """ Normalize an encoding name.
  
          Normalization works as follows: all non-alphanumeric
          characters except the dot used for Python package names are
          collapsed and replaced with a single underscore, e.g. '  -;#'
          becomes '_'. Leading and trailing underscores are removed.
  
          Note that encoding names should be ASCII only; if they do use
          non-ASCII characters, these must be Latin-1 compatible.
  
      """
      if isinstance(encoding, bytes):
          encoding = str(encoding, "ascii")
  
      chars = []
      punct = False
      for c in encoding:
          if c.isalnum() or c == '.':
              if punct and chars:
                  chars.append('_')
              chars.append(c)
              punct = False
          else:
              punct = True
      return ''.join(chars)
function_tokens: def normalize_encoding ( encoding ) : if isinstance ( encoding , bytes ) : encoding = str ( encoding , "ascii" ) chars = [ ] punct = False for c in encoding : if c . isalnum ( ) or c == '.' : if punct and chars : chars . append ( '_' ) chars . append ( c ) punct = False else : punct = True return '' . join ( chars )