docs: def normalize(s, replace_spaces=True):
      """Normalize non-ascii characters to their closest ascii counterparts
      """
      whitelist = (' -' + string.ascii_letters + string.digits)
  
      if type(s) == six.binary_type:
          s = six.text_type(s, 'utf-8', 'ignore')
  
      table = {}
      for ch in [ch for ch in s if ch not in whitelist]:
          if ch not in table:
              try:
                  replacement = unicodedata.normalize('NFKD', ch)[0]
                  if replacement in whitelist:
                      table[ord(ch)] = replacement
                  else:
                      table[ord(ch)] = u'_'
              except:
                  table[ord(ch)] = u'_'
  
      if replace_spaces:
          return s.translate(table).replace(u'_', u'').replace(' ', '_')
      else:
          return s.translate(table).replace(u'_', u'')