#NEWLINE# def canonicalName( command , preserve_spaces = False ) : #NEWLINE# #INDENT# 'Turn a command into its canonical form.\n\n    Currently, this makes everything lowercase and removes all dashes and\n    underscores.\n    ' #NEWLINE# if ( minisix . PY2 and isinstance ( command , unicode ) ) : #NEWLINE# #INDENT# command = command . encode ( 'utf-8' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( minisix . PY3 and isinstance ( command , bytes ) ) : #NEWLINE# #INDENT# command = command . decode ( ) #NEWLINE# #UNINDENT# #UNINDENT# special = '\t-_' #NEWLINE# if ( not preserve_spaces ) : #NEWLINE# #INDENT# special += ' ' #NEWLINE# #UNINDENT# reAppend = '' #NEWLINE# while ( command and ( command [ ( - 1 ) ] in special ) ) : #NEWLINE# #INDENT# reAppend = ( command [ ( - 1 ) ] + reAppend ) #NEWLINE# command = command [ : ( - 1 ) ] #NEWLINE# #UNINDENT# return ( '' . join ( [ x for x in command if ( x not in special ) ] ) . lower ( ) + reAppend )