diff options
Diffstat (limited to 'dicofr.py')
-rwxr-xr-x | dicofr.py | 28 |
1 files changed, 12 insertions, 16 deletions
@@ -1,18 +1,19 @@ #!/bin/env python -""" +''' # Main file. -A program to retrieve the definition of a french word (in french). +A program to retrieve the definition of a french word (in french language). Maybe extended to other languages later. -""" +''' import sys import argparse import msgpack import sqlite3 from os.path import exists +import os import ui @@ -20,15 +21,11 @@ import ui DEBUG = False if DEBUG: - DIR_PATH = 'assets/' + DIR_PATH = os.getcwd() else: - DIR_PATH = '/usr/share/dicofr/assets/' + DIR_PATH = '/usr/share/dfr/' -sys.path.insert(-1, DIR_PATH) - - - -dico = 'dicofr.db' +dico = 'dfr.db' def get_def_sql(word): @@ -41,7 +38,7 @@ def get_def_sql(word): return list(map(lambda w: {'mot': w[0], 'cat-gram': w[1], 'API': w[2], - 'infos': w[3].split("\t"), + 'infos': w[3].split('\t'), 'genre': w[4], 'accord': w[5], 'def': msgpack.unpackb(w[6], raw=False), @@ -58,7 +55,7 @@ def get_def_sql_reg(word): return list(map(lambda w: {'mot': w[0], 'cat-gram': w[1], 'API': w[2], - 'infos': w[3].split("\t"), + 'infos': w[3].split('\t'), 'genre': w[4], 'accord': w[5], 'def': msgpack.unpackb(w[6], raw=False), @@ -66,9 +63,9 @@ def get_def_sql_reg(word): def matching(word): - """ + ''' Find matching words in the list of words - """ + ''' matchingWord = [] @@ -86,7 +83,7 @@ def matching(word): matchingWord.append(w) else: if word[-1] != '/' or len(word) <= 2: - print("Erreur: Le format matching pour les regex est /MOT/", + print('Erreur: Le format matching pour les regex est /MOT/', file=sys.stderr) return [] import re @@ -135,4 +132,3 @@ if __name__ == '__main__': else: for w in arg.action(arg.word): ui.show_terminal(w) - |