diff options
author | ache <ache@ache.one> | 2020-02-21 06:01:13 +0100 |
---|---|---|
committer | ache <ache@ache.one> | 2020-02-21 06:01:13 +0100 |
commit | d9ffc8393bcf57c8f365ad5be32b095f5c99c87e (patch) | |
tree | 85b6b0832b2b2042a9890987e119863b27712aac /dicofr.py |
Init commit
Diffstat (limited to 'dicofr.py')
-rwxr-xr-x | dicofr.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/dicofr.py b/dicofr.py new file mode 100755 index 0000000..6c2042c --- /dev/null +++ b/dicofr.py @@ -0,0 +1,35 @@ +#!/bin/env python +# To load with python interpreter + +import msgpack +import ui +import sqlite3 +import sys + + +def get_def_sql(word): + with sqlite3.connect("result_all.sql") as con: + cur = con.cursor() + data = (word, ) + cur.execute('''SELECT * FROM entry WHERE word = ?''', data) + + res = cur.fetchall() + return list(map(lambda w: {'mot': w[0], + 'cat-gram': w[1], + 'API': w[2], + 'infos': w[3].split("\t"), + 'genre': w[4], + 'accord': w[5], + 'def': msgpack.unpackb(w[6], raw=False), + }, res)) + + +if __name__ == '__main__': + + if len(sys.argv) < 2: + print("Erreur: Rechercher un mot", file=sys.stderr) + exit() + + for w in get_def_sql(sys.argv[1]): + ui.show_terminal(w) + |