X-Git-Url: https://git.armaanb.net/?p=phrases.git;a=blobdiff_plain;f=phrases.py;fp=phrases.py;h=e9875e16228eafc457ef1834ab578d2437498d7c;hp=3b41b80719e32f460ac84a0b4469d1882643db4c;hb=6df9d76a2000f8d8c4558f6e16bbb21e055952e8;hpb=fe0ed8de081c40ef95c7acec10f25f764c71df08 diff --git a/phrases.py b/phrases.py index 3b41b80..e9875e1 100755 --- a/phrases.py +++ b/phrases.py @@ -8,6 +8,7 @@ import sqlite3 from sys import exit from os import path + def parse_args(): parser = argparse.ArgumentParser( description="Latin famous phrases in the terminal.") @@ -41,6 +42,7 @@ def parse_args(): help="set the location of the phrase database.") return parser.parse_args() + def output(): data = c.fetchall() row = list(data[randint(0, len(data) - 1)]) @@ -68,6 +70,7 @@ def output(): print(len(data)) exit(0) + def find_file(): if args.file: return args.file @@ -78,16 +81,19 @@ def find_file(): else: exit("cannot find the phrase database!") + def get_rand(): c.execute("SELECT * FROM phrases WHERE length <= (?) AND length >= (?)", (args.max, args.min)) + def main(): get_rand() output() + if __name__ == "__main__": - version = "phrases 1.0.1" + version = "phrases 1.0.2" args = parse_args() c = sqlite3.connect(find_file()).cursor() main()