#NEWLINE# def set_mode( self , mode ) : #NEWLINE# #INDENT# if ( self . version [ 0 ] < 3 ) : #NEWLINE# #INDENT# raise ValueError ( 'Mode Switching requires version >= 3' ) #NEWLINE# #UNINDENT# config = ykp_alloc_device_config ( ) #NEWLINE# ykp_set_device_mode ( config , mode ) #NEWLINE# try : #NEWLINE# #INDENT# if ( not yk_write_device_config ( self . _dev , config ) ) : #NEWLINE# #INDENT# raise ModeSwitchError ( ) #NEWLINE# #UNINDENT# #UNINDENT# finally : #NEWLINE# #INDENT# ykp_free_device_config ( config ) #NEWLINE# #UNINDENT# self . _mode = config