summaryrefslogtreecommitdiff
path: root/bladictionary.py
diff options
context:
space:
mode:
authorJoe Robinson <joe@lc8n.com>2014-09-21 00:34:21 +0100
committerJoe Robinson <joe@lc8n.com>2014-09-21 00:34:21 +0100
commit36102ee26a1d6c1b90fa14ea30bb346c66164213 (patch)
tree3e0b245352f23d78cb5799ec21d0398432c806e6 /bladictionary.py
parent39849003414737add90a5f6e6fb3e5f4ff9c46bb (diff)
Print all definitions for words with only one type
Diffstat (limited to 'bladictionary.py')
-rwxr-xr-xbladictionary.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/bladictionary.py b/bladictionary.py
index 03ebb26..e7038b7 100755
--- a/bladictionary.py
+++ b/bladictionary.py
@@ -294,11 +294,10 @@ def get_sql(word):
item.uses = rows
items.append(item)
+ return items
- return items
-
def main():
word, word_type, word_dict, options = parse_args()
@@ -342,6 +341,17 @@ def main():
all_types = word_type is ""
+ #Normally we try and display 1 of each type if no type is specified
+ #But if the word only has one type of definition, display all of them
+ if all_types:
+ word_types = []
+ for item in items:
+ if item.word_type not in word_types:
+ word_types.append(item.word_type)
+ if len(word_types) == 1:
+ word_type = word_types[0]
+ all_types = False
+
for item in items:
#If no type is specified, we display one of each