summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbladictionary.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/bladictionary.py b/bladictionary.py
index 5d7f0bf..f7fcaec 100755
--- a/bladictionary.py
+++ b/bladictionary.py
@@ -207,6 +207,8 @@ def main():
if word_dict == "oed":
items = parse_oed(word)
else:
+ if word_dict == "" or word_dict is None:
+ word_dict = "wn"
xml = get_xml(word, word_dict)
if xml is None:
@@ -214,21 +216,24 @@ def main():
items = parse_xml(xml)
- num_printed = 0
+ line_length = 0
num_more = 0
suppress_print = False
for item in items:
- if num_printed == 3:
- suppress_print = True
-
if word_type is "" or word_type == item.word_type:
if suppress_print:
num_more+=1
else:
- print item.word_type + " " + item.id + ": " + item.definition,
- num_printed+=1
+ definition = item.word_type + " " + item.id + ": " + item.definition
+ if line_length + len(definition) > 455:
+ suppress_print = True
+ num_more+= 1
+ else:
+ print definition,
+
+ line_length += len(definition)
if suppress_print:
print "(" + str(num_more) + " more)"