2 # Display Latin famous phrases in the terminal - python version
6 from random import randint
12 parser = argparse.ArgumentParser(
13 description="Latin famous phrases in the terminal.")
14 parser.add_argument("-i", "--id",
16 help="print the id of the phrase.")
17 parser.add_argument("-l", "--latin",
19 help="print the Latin phrase (default)")
20 parser.add_argument("-e", "--english",
22 help="print the English translation.")
23 parser.add_argument("-n", "--notes",
25 help="print any notes on phrase.")
26 parser.add_argument("-m", "--min",
29 help="set the minimum length of the Latin phrase.")
30 parser.add_argument("-M", "--max",
33 help="set the maximum length of Latin phrase.")
34 parser.add_argument("-p", "--num",
36 help="print number of possible phrases.")
37 parser.add_argument("-f", "--file",
38 help="set the location of the phrase database.")
39 return parser.parse_args()
41 def output(args, row, numx):
65 if os.path.isfile("phrases.db"):
67 elif os.path.isfile("/usr/local/share/phrases/phrases.db"):
68 return "/usr/local/share/phrases/phrases.db"
70 sys.exit("cannot find the phrase database!")
73 c = sqlite3.connect(find_file(args)).cursor()
74 c.execute("SELECT * FROM phrases WHERE length <= (?) AND length >= (?)",
77 output(args, list(data[randint(0, len(data))]), len(data))
79 if __name__ == "__main__":