summaryrefslogtreecommitdiff
path: root/bladictionary.py
diff options
context:
space:
mode:
authorJoe Robinson <joe@mumsnet.com>2014-09-18 16:24:41 +0100
committerJoe Robinson <joe@mumsnet.com>2014-09-18 16:24:41 +0100
commitf9587280f6c0e5540ed6386147b4acc61caf52c8 (patch)
tree917a2baf70e09f36c6e160ac3ec8516a159c6e22 /bladictionary.py
parente9f42da5fc980b302946aad6686017f3cc91b695 (diff)
Added version output
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)