def identifier_from_name(name):
 if isinstance(name, str):
  identifier = name.decode('utf-8')
 else:
  identifier = name
 identifier = identifier.lower()
 identifier = identifier.replace(u'+', u' plus ')
 identifier = re.sub(u'[ _\u2013]+', u'-', identifier)
 identifier = re.sub(u"['./;\u2019(),:]", u'', identifier)
 identifier = identifier.replace(u'\xe9', u'e')
 identifier = identifier.replace(u'\u2640', u'-f')
 identifier = identifier.replace(u'\u2642', u'-m')
 if (identifier in (u'???', u'????')):
  identifier = u'unknown'
 elif (identifier == u'!'):
  identifier = u'exclamation'
 elif (identifier == u'?'):
  identifier = u'question'
 if (not identifier.replace(u'-', u'').isalnum()):
  raise ValueError(identifier)
 return identifier

def identifier_from_name ( name ) : if isinstance ( name , str ) : identifier = name . decode ( 'utf-8' ) else : identifier = name identifier = identifier . lower ( ) identifier = identifier . replace ( u'+' , u' plus ' ) identifier = re . sub ( u'[ _\u2013]+' , u'-' , identifier ) identifier = re . sub ( u"['./;\u2019(),:]" , u'' , identifier ) identifier = identifier . replace ( u'\xe9' , u'e' ) identifier = identifier . replace ( u'\u2640' , u'-f' ) identifier = identifier . replace ( u'\u2642' , u'-m' ) if ( identifier in ( u'???' , u'????' ) ) : identifier = u'unknown' elif ( identifier == u'!' ) : identifier = u'exclamation' elif ( identifier == u'?' ) : identifier = u'question' if ( not identifier . replace ( u'-' , u'' ) . isalnum ( ) ) : raise ValueError ( identifier ) return identifier
make a string safe to use as an identifier .