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("-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()
44 def output(args, row, numx, version):
71 if os.path.isfile("phrases.db"):
73 elif os.path.isfile("/usr/local/share/phrases/phrases.db"):
74 return "/usr/local/share/phrases/phrases.db"
76 sys.exit("cannot find the phrase database!")
79 version = "phrases 1.0.0"
80 c = sqlite3.connect(find_file(args)).cursor()
81 c.execute("SELECT * FROM phrases WHERE length <= (?) AND length >= (?)",
84 output(args, list(data[randint(0, len(data))]), len(data,), version)
86 if __name__ == "__main__":