def setUpClass(cls): buffers = GeneratorBuffers() gen = GeneratorStateMaster() gen.init('stub_screen', buffers) commander = Commander() commander.init( os.path.realpath( os.path.join(os.path.dirname(__file__), 'out', 'test.out')))
def __init__(self): super().__init__() def _decorator_action(): command = _create_command( abs_path(__file__, '..', 'scripts', 'function', 'decorator')) Commander().append_command(command) Commander().execute() def _definition_action(): command = _create_command( abs_path(__file__, '..', 'scripts', 'function', 'definition')) Commander().append_command(command) Commander().execute() def _create_command(script_path): decorator_name = GeneratorBuffers().input.peek() return create_script(script_path, decorator_name) self._options = { '0': _decorator_action, '1': _definition_action, '2': lambda: GeneratorStateMaster().pop_state() }
def make_pop_entry(): """ Convenience function for generating common action which is popping state """ return { 'caption': COMMON_CAPTIONS['back'], 'action': lambda: GeneratorStateMaster().pop_state(), }
def setup_generator(screen): output_file = os.path.join(os.path.realpath(os.environ['HOME']), 'tmp', 'willpower.out') commander = Commander() commander.init(output_file) buffers = GeneratorBuffers() gen = GeneratorStateMaster() gen.init(screen, buffers) gen.set_start_state(WidgetsFactory.make_top_level()) gen.reset_state() return gen
def _handle_submission_code(self, u_in): if u_in == '300': self._execution_observer.notify(self._internal_buffer) elif u_in == '301': self._internal_buffer = self._internal_buffer[:-1] elif u_in == '302': self._internal_buffer = '' elif u_in == '310': GeneratorStateMaster().pop_state() else: self._add_to_internal_buffer(u_in) self.current_option_code = ''
def make_generator_entry(caption, state): """ Convenience function used to return one option 'row' using the caption and state append action (the common operation) :param caption: string to be used as an action's caption :param state: state to be appended to state_chain in action :return: """ return { 'caption': caption, 'action': lambda: GeneratorStateMaster().append_state(state), }
def handle_input(self, u_in): GeneratorStateMaster().reset_state()