From 36102ee26a1d6c1b90fa14ea30bb346c66164213 Mon Sep 17 00:00:00 2001 From: Joe Robinson Date: Sun, 21 Sep 2014 00:34:21 +0100 Subject: Print all definitions for words with only one type --- bladictionary.py | 14 ++++++++++++-- 1 file 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 -- cgit v1.2.3