2 # Display Latin famous phrases in the terminal
6 from random import randint
13 parser = argparse.ArgumentParser(
14 description="Latin famous phrases in the terminal")
15 parser.add_argument("-i", "--id",
17 help="print the id of the phrase")
18 parser.add_argument("-l", "--latin",
20 help="print the Latin phrase (default)")
21 parser.add_argument("-e", "--english",
23 help="print the English translation")
24 parser.add_argument("-n", "--notes",
26 help="print any notes on phrase")
27 parser.add_argument("-v", "--version",
30 parser.add_argument("-m", "--min",
33 help="set the minimum length of the Latin phrase")
34 parser.add_argument("-M", "--max",
37 help="set the maximum length of Latin phrase")
38 parser.add_argument("-p", "--num",
40 help="print number of possible phrases")
41 parser.add_argument("-f", "--file",
42 help="set the location of the phrase database")
43 return parser.parse_args()
48 row = list(data[randint(0, len(data) - 1)])
77 if path.isfile("phrases.db"):
79 elif path.isfile("/usr/local/share/phrases/phrases.db"):
80 return "/usr/local/share/phrases/phrases.db"
82 exit("cannot find the phrase database!")
86 c.execute("SELECT * FROM phrases WHERE length <= (?) AND length >= (?)",
95 if __name__ == "__main__":
96 version = "phrases 1.0.2"
98 c = sqlite3.connect(find_file()).cursor()