#NEWLINE# def sanitize( self , name , valid_fn ) : #NEWLINE# #INDENT# 'Accumulate blocks of hex and separate blocks by underscores' #NEWLINE# invalid = { #NEWLINE# #INDENT# '\x07' : 'a' , #NEWLINE# '\x08' : 'b' , #NEWLINE# '\x0b' : 'v' , #NEWLINE# '\x0c' : 'f' , #NEWLINE# '\r' : 'r' , #NEWLINE# #UNINDENT# } #NEWLINE# for cc in filter ( ( lambda el : ( el in name ) ) , invalid . keys ( ) ) : #NEWLINE# #INDENT# raise Exception ( ( "Please use a raw string or escape control code '\\%s'" % invalid [ cc ] ) ) #NEWLINE# #UNINDENT# ( sanitized , chars ) = ( [ ] , '' ) #NEWLINE# for split in name . split ( ) : #NEWLINE# #INDENT# for c in split : #NEWLINE# #INDENT# if valid_fn ( c ) : #NEWLINE# #INDENT# chars += ( str ( sanitized ) if ( c == '_' ) else c ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# short = self . shortened_character_name ( c , self . eliminations , self . substitutions , self . transforms ) #NEWLINE# sanitized . extend ( ( [ chars ] if chars else [ ] ) ) #NEWLINE# if ( short != '' ) : #NEWLINE# #INDENT# sanitized . append ( short ) #NEWLINE# #UNINDENT# chars = '' #NEWLINE# #UNINDENT# #UNINDENT# if chars : #NEWLINE# #INDENT# sanitized . extend ( [ chars ] ) #NEWLINE# chars = '' #NEWLINE# #UNINDENT# #UNINDENT# return self . _process_underscores ( ( sanitized + ( [ chars ] if chars else [ ] ) ) )