def _create_context_manager(self, mode):
        " Create a context manager that sends 'mode' commands to the client. "
        class mode_context_manager(object):
            def __enter__(*a):
                self.send_packet({'cmd': 'mode', 'data': mode})

            def __exit__(*a):
                self.send_packet({'cmd': 'mode', 'data': 'restore'})

        return mode_context_manager()
def _create_context_manager ( self , mode ) : class mode_context_manager ( object ) : def __enter__ ( * a ) : self . send_packet ( { 'cmd' : 'mode' , 'data' : mode } ) def __exit__ ( * a ) : self . send_packet ( { 'cmd' : 'mode' , 'data' : 'restore' } ) return mode_context_manager ( )
Create a context manager that sends 'mode' commands to the client.