2 # Display Latin famous phrases in the terminal
10 # Create list of phrases from phrase file
11 def read_phrases(phrase_file):
12 f = open(phrase_file, 'r')
15 lines = [line.rstrip() for line in contents.split('\n')]
16 delim = re.compile(r'^%$')
22 phrase = '\n'.join(cur)
24 phrases.append(phrase)
32 def main(args=sys.argv[1:]):
33 parser = argparse.ArgumentParser(description="Latin famous phrases in the terminal.")
34 parser.add_argument("-e", "--english", action='store_true', help="Output English.")
35 parser.add_argument("-l", "--latin", action='store_true', help="Output Latin (default)")
36 parser.add_argument("-n", "--notes", action='store_true', help="Output notes on phrase")
37 parser.add_argument("-m", "--min", type=int, help="Set the minimum length of latin")
38 parser.add_argument("-M", "--max", type=int, help="Set the maximum length of latin")
39 args = parser.parse_args()
41 phrases = list(read_phrases("/usr/share/phrases/phrases"))
42 randomRecord = random.randint(0, len(phrases) - 1)
43 randphrase = phrases[randomRecord]
47 randomRecord = random.randint(0, len(phrases) - 1)
48 randphrase = phrases[randomRecord]
49 if args.min <= len(randphrase.split('\n')[0]) <= args.max:
52 print(randphrase.split('\n')[0])
54 print(randphrase.split('\n')[1])
56 print(randphrase.split('\n')[2])
57 if not len(sys.argv) > 1:
58 print(randphrase.split('\n')[0])