summaryrefslogtreecommitdiff
path: root/bladictionary.py
diff options
context:
space:
mode:
Diffstat (limited to 'bladictionary.py')
-rwxr-xr-xbladictionary.py19
1 files changed, 15 insertions, 4 deletions
diff --git a/bladictionary.py b/bladictionary.py
index a64eb1c..7034988 100755
--- a/bladictionary.py
+++ b/bladictionary.py
@@ -4,9 +4,10 @@
import requests
import sys
import shlex
+import optparse
from lxml import etree
-version = "2.0.9b"
+VERSION = "2.0.10b"
class Definition(object):
#ID is relative to the word type, eg noun 1, noun 2, verb 1, verb 2, not to the entire list
@@ -142,12 +143,18 @@ def parse_args():
if not args:
args = shlex.split(sys.stdin.read())
+ parser = optparse.OptionParser( usage = "!define <term> <type> <dictionary>" )
+ parser.add_option( "-v", "--version", action = "store_true" )
+ options, args = parser.parse_args( args )
types = ["n", "noun", "v", "verb", "adj", "adjective", "adv", "adverb"]
dicts = ["wn", "wordnet", "oed"]
- word = args[0]
word_type = ""
word_dict = ""
+
+ if len(args) > 0:
+ word = args[0]
+
if len(args) > 1:
for arg in args[1:]:
if arg in types:
@@ -155,7 +162,7 @@ def parse_args():
elif arg in dicts:
word_dict = arg
- return word, word_type, word_dict
+ return word, word_type, word_dict, options.version
def parse_oed(word):
types = ["n.", "—n.", "v.", "—v.", "adj.", "—adj.", "adv.", "—adv."]
@@ -205,7 +212,11 @@ def parse_oed(word):
def main():
- word, word_type, word_dict = parse_args()
+ word, word_type, word_dict, version = parse_args()
+
+ if version:
+ print VERSION
+ sys.exit( 0 )
if word_dict == "oed":
items = parse_oed(word)