aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorache <ache@ache.one>2021-09-16 03:42:32 +0200
committerache <ache@ache.one>2021-09-16 03:42:32 +0200
commitc8fa0b2d8d96157c53b79396b9e2475acec59f27 (patch)
tree1acf0173e66074e3dc22c926b6071c13748cdd1e
parentInstall fix (diff)
Add the dfrf command
-rwxr-xr-xdfr.py14
-rwxr-xr-xdfrf.py18
2 files changed, 30 insertions, 2 deletions
diff --git a/dfr.py b/dfr.py
index 720e239..e664264 100755
--- a/dfr.py
+++ b/dfr.py
@@ -117,6 +117,8 @@ if __name__ == '__main__':
parser.add_argument('-d', '--dico', dest='dico', action='store',
help='the filename of the dictionnary',
default='dfr.db')
+ parser.add_argument('-f', '--first', dest='first', action='store_true',
+ help='get only the first definition')
parser.add_argument('-u', '--update', dest='update', type=str, nargs='?', const=dico,
help='update the database')
@@ -153,5 +155,13 @@ if __name__ == '__main__':
if not ret:
exit(1)
else:
- for w in arg.action(arg.word):
- ui.show_terminal(w)
+ if arg.first:
+ a = arg.action(arg.word)
+ if a :
+ if a[0]['def']:
+ a[0]['def'] = [a[0]['def'][0]]
+ a[0]['def'][0]['ex'] = []
+ ui.show_terminal(a[0])
+ else:
+ for w in arg.action(arg.word):
+ ui.show_terminal(w)
diff --git a/dfrf.py b/dfrf.py
new file mode 100755
index 0000000..9f1df9b
--- /dev/null
+++ b/dfrf.py
@@ -0,0 +1,18 @@
+#!/bin/env python
+
+'''
+# Secondary file
+
+A program to retrieve the definition of a french word (in french language).
+Only the first defintion, have a look at dfr.py to the main file.
+'''
+
+import sys
+import os
+
+
+if __name__ == '__main__':
+ import sys
+ if sys.executable:
+ os.execlp(sys.executable, 'python', os.getcwd() + '/dfr.py', *sys.argv[1:], '-f')
+