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 parser.add_argument("-o", "--open",
41 help="specify the id of a specific phrase to print.")
42 return parser.parse_args()
44 def output(args, row, numx):
68 if os.path.isfile("phrases.db"):
70 elif os.path.isfile("/usr/local/share/phrases/phrases.db"):
71 return "/usr/local/share/phrases/phrases.db"
73 sys.exit("cannot find the phrase database!")
76 c = sqlite3.connect(find_file(args)).cursor()
77 c.execute("SELECT * FROM phrases WHERE length <= (?) AND length >= (?)",
80 output(args, list(data[randint(0, len(data))]), len(data))
82 if __name__ == "__main__":