def ask_list_selection(st_name_dict: dict): text = "Load Done!\n" text += "Please input one or more index to start:\n" text += "Example: 7 or 1,2,4-8,9~10 or 0 or -1 or -2\n" st_name_dict[-1] = 'Exit' st_name_dict[-2] = 'Review' for i, (k, v) in enumerate(st_name_dict.items()): text += "{}. {}".format(k, v) if i % 2: text += '\n' else: n_space = 4 text += ''.join([' ' for _ in range(n_space)]) print(pipeline_util.get_inbanner_text(text, body_width=BANNER_BODY_WIDTH, fix_width=True, canopy_switcher=[0, 1])) while True: inp = input("Your Input:").strip() if len(inp) == 0: continue selected = pipeline_util.parse_user_selection(inp) if selected is None: continue assert len(selected) > 0, selected if -1 in selected: assert len(selected) == 1, selected print(pipeline_util.get_inbanner_text("See you :D", body_width=BANNER_BODY_WIDTH, fix_width=True, canopy_switcher=[1, 1])) exit() if -2 in selected: assert len(selected) == 1, selected return -2 return selected
def prompt_rule(num_words): text = "Successfully loaded {} words".format(num_words) print(pipeline_util.get_inbanner_text(text, body_width=BANNER_BODY_WIDTH, fix_width=True, canopy_switcher=[1, 1])) text = '''RULE 1. Enter NOTHING to indicate you RECALL this word; Enter SOMETHING to indicate you FORGET it. 2. Enter NOTHING to indicate your answer is consistent with the given one; vice versa.\n''' if INP_TIMEOUT > 0: text += \ '''3. Give an input in {}s, or it will be consider as a failure of recall.'''.format(INP_TIMEOUT) print(pipeline_util.get_inbanner_text(text, body_width=BANNER_BODY_WIDTH, fix_width=True, canopy_switcher=[0, 1])) input()
def save_new_content(wb, all_content, selected, st_name_dict): def extract_sheet_content(sheet_idx): row_indces = np.where(all_content[:, 0] == sheet_idx)[0] st_content = all_content[row_indces, 1:] return st_content for sheet_idx in selected: sheet_name = st_name_dict[sheet_idx] st = wb.get_sheet_by_name(sheet_name) st_content = extract_sheet_content(sheet_idx) workbook_op.fill_sheet_with_new_content(st, st_content) saved_to = workbook_op.save_workbook(wb, WB_PATH) text = 'Work Saved to:\n{}'.format(saved_to) print(pipeline_util.get_inbanner_text(text, body_width=BANNER_BODY_WIDTH, fix_width=True, canopy_switcher=[1, 1]))
def load_wb(): text = "Loading, please wait..." print(pipeline_util.get_inbanner_text(text, body_width=BANNER_BODY_WIDTH, fix_width=True, canopy_switcher=[0, 1])) wb, st_name_dict = workbook_op.open_workbook(WB_PATH) return wb, st_name_dict
def prompt_welcome(): if TESTMODE: print(Color().colorize('red', '[TESTMODE IS ON]')) text = "Welcome to GRE3000 Helper. Wordlist from: {}".format(WB_PATH) print(pipeline_util.get_inbanner_text(text, body_width=BANNER_BODY_WIDTH, fix_width=True))
def prompt_oblivious(): text = '''Review oblivious words This section will help you review the words UNTIL you can correctly recall them all. ''' print(pipeline_util.get_inbanner_text(text, body_width=BANNER_BODY_WIDTH, fix_width=True, canopy_switcher=[1, 1]))