From d46f272a30568c8383829602327067dc440121b1 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 16 Oct 2017 11:31:18 -0400 Subject: [PATCH] Use set() to create list of unique tags (#224) --- buku.py | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/buku.py b/buku.py index 1d04f96..8e95ec8 100755 --- a/buku.py +++ b/buku.py @@ -2878,20 +2878,14 @@ def parse_tags(keywords=[]): if tags == DELIM: return tags - orig_tags = tags.strip(DELIM).split(DELIM) + # original tags in lower case + orig_tags = tags.lower().strip(DELIM).split(DELIM) - # Add unique tags in lower case - unique_tags = [] - for tag in orig_tags: - tag = tag.lower() - if tag not in unique_tags: - unique_tags += (tag, ) - - # Sort the tags - sorted_tags = sorted(unique_tags) + # Create list of unique tags and sort + unique_tags = sorted(set(orig_tags)) # Wrap with delimiter - return delim_wrap(DELIM.join(sorted_tags)) + return delim_wrap(DELIM.join(unique_tags)) def prep_tag_search(tags):