aboutsummaryrefslogtreecommitdiff
path: root/dicofr.py
diff options
context:
space:
mode:
Diffstat (limited to 'dicofr.py')
-rwxr-xr-xdicofr.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/dicofr.py b/dicofr.py
index ea5741c..9bef7ac 100755
--- a/dicofr.py
+++ b/dicofr.py
@@ -12,7 +12,7 @@ sys.path.insert(-1, DIR_PATH)
import ui
-dico = 'wiktfr.sql'
+dico = 'dicofr.db'
def get_def_sql(word):
@@ -56,7 +56,11 @@ def matching(word):
matchingWord = []
- with open('list_word.msgpk', 'rb') as f:
+ if not exists(arg.wordList):
+ print(f'Error: Word list {arg.wordList} not found', file=sys.stderr)
+ return
+
+ with open(arg.wordList, 'rb') as f:
msgpackList = f.read()
listWord = msgpack.unpackb(msgpackList, raw=False)
@@ -81,8 +85,9 @@ def matching(word):
if __name__ == '__main__':
if len(sys.argv) < 2:
- print("Erreur: Rechercher un mot", file=sys.stderr)
- exit()
+ print("Erreur: Rechercher un mot\nUtilisez l'option -h pour avoir de l'aide",
+ file=sys.stderr)
+ exit(-1)
# Si on n'arrive pas à trouver le dictionnaire
if not exists(dico):
@@ -97,6 +102,8 @@ if __name__ == '__main__':
const=get_def_sql_reg, default=get_def_sql,
help='search a definition using SQL regex, '
'_ to match a letter, %% to match a group of letters')
+ parser.add_argument('-w', '--wordlist', dest='wordList',
+ action='store_const', default='list_word.msgpack')
parser.add_argument('-m', '--matching', dest='matching', action='store_true',
help='search the french words that match the regex')
parser.add_argument('word', metavar='PATTERN', type=str,
@@ -113,6 +120,4 @@ if __name__ == '__main__':
else:
for w in arg.action(arg.word):
ui.show_terminal(w)
- if not ret:
- exit(1)