def do_save(self, line): """ Outputs team or room data to the console. Filter options are available. """ cmd_args = io.parse_cmd_args(line, io.output_cmd_pattern) if cmd_args: success = self.manager.save_to_file(**cmd_args) if success: self.console_print("Yippee! saved successfully!", settings.INFO_FORMAT) else: self.console_print("Sorry, something kinda went wrong! You can try again tho.", settings.ERROR_FORMAT) else: self.console_print(settings.COMMMAND_ARGS_ERROR_MSG, settings.ERROR_FORMAT)
def do_allocate(self, line): """ Allocates persons to rooms using optional or default constraints. e.g. allocate g+ r- """ cmd_args = io.parse_cmd_args(line, io.allocate_cmd_pattern) if cmd_args: success = self.manager.allocate(**cmd_args) if success: self.console_print("Noice! Allocation complete!", settings.INFO_FORMAT) else: self.console_print("Awww...something went wrong while allocating.", settings.ERROR_FORMAT) else: self.console_print(settings.COMMMAND_ARGS_ERROR_MSG, settings.ERROR_FORMAT)
def do_load(self, line): """ Loads data from text files to populate either the 'team' or 'rooms' lists. e.g. load team './data/input_persons.txt' a """ cmd_args = io.parse_cmd_args(line, io.load_cmd_pattern) if cmd_args: success = self.manager.load(**cmd_args) if success: self.console_print("Yippee! load successful!", settings.INFO_FORMAT) else: self.console_print("Sorry, the data could not be loaded from file.", settings.ERROR_FORMAT) else: self.console_print(settings.COMMMAND_ARGS_ERROR_MSG, settings.ERROR_FORMAT)
def do_print(self, line): """ Outputs team or room data to the console. Filter options are available. """ cmd_args = io.parse_cmd_args(line, io.output_cmd_pattern) if cmd_args: success = self.manager.print_to_console( cmd_args.get('target'), cmd_args.get('filters') ) if success: self.console_print("There, you asked for it!", settings.INFO_FORMAT) else: self.console_print("Sorry, something kinda went wrong! You can try again.", settings.ERROR_FORMAT) else: self.console_print(settings.COMMMAND_ARGS_ERROR_MSG, settings.ERROR_FORMAT)
def do_input(self, line): """ Collects data from command line to populate either the 'team' or 'rooms'. e.g. input team 'ANDREW PHILLIPS FELLOW Y M, MATTHEW O'CONNOR STAFF' :o """ cmd_args = io.parse_cmd_args(line, io.input_cmd_pattern) if cmd_args: success = self.manager.input( cmd_args.get('target'), cmd_args.get('cslist'), mode=cmd_args.get('mode') ) if success: self.console_print("Yippee! input successfull!", settings.INFO_FORMAT) else: self.console_print("Sorry, something kinda went wrong! You can try again.", settings.ERROR_FORMAT) else: self.console_print(settings.COMMMAND_ARGS_ERROR_MSG, settings.ERROR_FORMAT)