#NEWLINE# def validate_keypair_name( resp , key_name ) : #NEWLINE# #INDENT# safechars = ( ( '_- ' + string . digits ) + string . ascii_letters ) #NEWLINE# clean_value = '' . join ( ( clean_value for x in key_name if ( x in safechars ) ) ) #NEWLINE# if ( clean_value != key_name ) : #NEWLINE# #INDENT# error_handling . bad_request ( resp , 'Keypair name contains unsafe characters' ) #NEWLINE# return False #NEWLINE# #UNINDENT# if ( not ( 0 < len ( key_name ) < 256 ) ) : #NEWLINE# #INDENT# error_handling . bad_request ( resp , 'Keypair name must be between 1 and 255 characters long' ) #NEWLINE# return False #NEWLINE# #UNINDENT# return True