def filterChoice(filterFile): filterTerms = [] noOfFilters = int(input('Do you want to filter ' + filterFile +' by 1 or multiple terms? Choose \n 1. 1 term' \ '\n 2. Multiple terms \n')) if noOfFilters == 1: print("What term to you want to filter by? Here are the categories:") for k, v in CV.items(): print('{key}: {values}'.format( key=k, values=', '.join('{}'.format(', '.join(x.split())) for x in v))) filterTerm = input("What term do you want to filter by? \n") if (any(filterTerm in value for value in CV.values())): print('Filter by ' + filterTerm) else: print("Please choose a category to filter by") elif noOfFilters == 2: print("What term to you want to filter by? Here are the categories:") for k, v in CV.items(): print('{key}: {values}'.format( key=k, values=', '.join('{}'.format(', '.join(x.split())) for x in v))) filterTerms = input( "What terms do you want to filter by? (Split up the terms with a ', ' (comma)) \n" ) terms_list = re.split("[, ] ", filterTerms) #print(terms_list) else: print('Choose either options 1 or 2')
"\t [cont.] --output C:\Program Files\example.json" "\n\t The following terms are valid filters:") for k, v in CV.items(): print('\t\t {key}: {values}'.format(key=k, values=', '.join('{}'.format(', '.join(x.split())) for x in v))) break if was_option: continue elif last_option == "--url" or last_option == "-u": url = args[i] import urllib.request with urllib.request.urlopen('http://python.org/') as response: html = response.read() elif last_option == "--headline" or last_option == "-i": headlines.append(args[i]) elif last_option == "--filter" or last_option == "-f": CV_vals = CV.values() CV_single = [] for sublist in CV_vals: for item in sublist: CV_single.append(item) CV_single_lower = [x.lower() for x in CV_single] if args[i].lower() in CV_single_lower: filterTerms.append(args[i]) elif last_option == "--output" or last_option == "-o": output = args[i] if not headlines: uc.run_guide() else: while not output: output = uc.GetOutputDir()