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 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)
def select_item_from_files(f_list_, numbered_index): chosen_item = f_list_[numbered_index - 1] if numbered_index == -1: # prompt to select chosen_item = choose_from_list(f_list_) return chosen_item
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"
"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)