2 # Display Latin famous phrases in the terminal
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("-v", "--version",
28 help="print version.")
29 parser.add_argument("-m", "--min",
32 help="set the minimum length of the Latin phrase.")
33 parser.add_argument("-M", "--max",
36 help="set the maximum length of Latin phrase.")
37 parser.add_argument("-p", "--num",
39 help="print number of possible phrases.")
40 parser.add_argument("-f", "--file",
41 help="set the location of the phrase database.")
42 return parser.parse_args()
46 row = list(data[randint(0, len(data) - 1)])
74 if path.isfile("phrases.db"):
76 elif path.isfile("/usr/local/share/phrases/phrases.db"):
77 return "/usr/local/share/phrases/phrases.db"
79 exit("cannot find the phrase database!")
82 c.execute("SELECT * FROM phrases WHERE length <= (?) AND length >= (?)",
89 if __name__ == "__main__":
90 version = "phrases 1.0.1"
92 c = sqlite3.connect(find_file()).cursor()