def get_tag_by_partial_match(partial_tag_match_list): tag_dict = load_tag_dict() possible_matches = [] for tag in tag_dict.keys(): tag = tag.strip().lower() if all([pt.lower() in tag for pt in partial_tag_match_list]): possible_matches.append(tag) choice = None if len(possible_matches) > 1: print_list(possible_matches) choice = choose_from_list(possible_matches) elif len(possible_matches) > 0: choice = possible_matches[0] return choice
def get_user_choices(tag_or_file_list): choice_list = [] print_list(tag_or_file_list) if len(tag_or_file_list) > 1: print "Enter number(s) separated by commas" try: input_ = raw_input() except EOFError: # pipes input_ = keypress_input() choices = input_.split(',') choices = map(int, choices) for choice in choices: choice_list.append(tag_or_file_list[choice - 1]) else: choice_list.append(tag_or_file_list[0]) return choice_list
def present_result(f_list_, display_full_filepath): f_list_ = [path.realpath(f) for f in f_list_] if args.list_files is not None or args.select_file is not None: if args.list_files == -1: if len(args.targ_words) > 0: args.list_files = len(f_list_) else: args.list_files = 10 if display_full_filepath: list_to_be_printed = f_list_ else: list_to_be_printed = [path.split(f)[1] for f in f_list_] print_list(list_to_be_printed, args.list_files, press_to_continue=stdout.isatty()) quoted_f_list = map(lambda x: "\"" + str(x) + "\"", f_list_) chosen_item = quoted_f_list[0] if args.select_file is not None: chosen_item = select_item_from_files(quoted_f_list, args.select_file) print chosen_item set_clipboard_data(chosen_item)
def present_result(file_list): if args.num_of_results is not None: file_list = file_list[:args.num_of_results] if args.show_all_file_tags: f_list_w_tags = [] for i in range(0, len(file_list)): tags = search_tags_for_file(path.realpath(file_list[i])) f_list_w_tags.append(file_list[i] + " [" + ", ".join(tags) + "]") print_list(f_list_w_tags, press_to_continue=stdout.isatty()) else: print_list(file_list, press_to_continue=stdout.isatty()) file_list = map(lambda f_: "\"" + f_ + "\"", file_list) if args.select: if len(file_list) == 1: choice = file_list[0] else: choice = choose_from_list(file_list) print choice set_clipboard_data(choice)
user_input = input_prompt() while user_input not in valid_inputs: print "Invalid input: {}".format(user_input) user_input = input_prompt() proc.terminate() print "End" if __name__ == "__main__": if len(sys.argv) == 2: if str(sys.argv[1]).isdigit(): s_dict = load_series_dict() play_series(s_dict, s_dict.keys()[(int(sys.argv[1]) - 1)]) else: add_to_series_dict(sys.argv[1]) elif len(sys.argv) == 1: s_dict = load_series_dict() s_list = s_dict.keys() if len(s_list) > 0: print_list(s_list) choice = choose_from_list(s_list) play_series(s_dict, choice) else: print "No series added" else: print "Unknown arguments"
def view_to_do_list(): task_list = load_task_list() map(str, task_list) print_list(task_list)
"jump_index", type=int, nargs='?', help="number index of directory to change directory in to") group.add_argument("-a", "--add-dir", action="store_true", help="add a directory to list") group.add_argument("-d", "--delete-dir", type=int, help="delete a directory from list") args = parser.parse_args() if args.add_dir: add_to_dir_jump(getcwd()) elif args.delete_dir: remove_from_dir_jump(args.delete_dir) elif args.jump_index is not None: sort_dir_jump(args.jump_index) else: jumpList = get_jump_list() print_list(jumpList[1:]) choice = choose_from_list( jumpList[1:]) # +1 for skipping first line of jumped route sort_dir_jump(jumpList.index(choice))
def choose_from_tags(t_list_): print_list(t_list_) choice = choose_from_list(t_list_) cf_list = get_files_from_tags(choice) present_result(cf_list)