- # iterate through all the phrases
- for row in all_lines:
- try: # generate a shortlist of phrases of the right length
- if args.max >= int(row[4]) >= args.min:
- right_length.append(row[0])
- except: # skip malformed rows without exiting
- pass
+def find_file():
+ if args.file:
+ return args.file
+ if path.isfile("phrases.db"):
+ return "phrases.db"
+ elif path.isfile("/usr/local/share/phrases/phrases.db"):
+ return "/usr/local/share/phrases/phrases.db"
+ else:
+ exit("cannot find the phrase database!")