#!/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)