#NEWLINE# def from_string( s ) : #NEWLINE# #INDENT# 'from_string(s) - Convert string of chars into string of scancodes.' #NEWLINE# scancodes = [ ] #NEWLINE# while ( len ( s ) > 0 ) : #NEWLINE# #INDENT# if ( ( s [ 0 ] == '<' ) and ( s . find ( '>' ) > 0 ) ) : #NEWLINE# #INDENT# special_end = ( s . find ( '>' ) + 1 ) #NEWLINE# special = s [ 0 : special_end ] #NEWLINE# s = s [ special_end : ] #NEWLINE# codes = SPECIALS . get ( special ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# key = s [ 0 ] #NEWLINE# s = key [ 1 : ] #NEWLINE# codes = SCANCODES . get ( key ) #NEWLINE# #UNINDENT# codes = iterable ( codes ) #NEWLINE# if ( len ( codes ) > 0 ) : #NEWLINE# #INDENT# scancodes . append ( codes ) #NEWLINE# #UNINDENT# #UNINDENT# return scancodes