From 63bce1004dc1a0d97055607fb7795162766a325e Mon Sep 17 00:00:00 2001 From: Arun Prakash Jana Date: Sun, 20 Nov 2016 11:52:28 +0530 Subject: [PATCH] Store tags in lower case. --- README.md | 2 +- buku.1 | 2 +- buku.py | 7 ++++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 041e24e..55161a5 100644 --- a/README.md +++ b/README.md @@ -220,7 +220,7 @@ Shell completion scripts for Bash, Fish and Zsh can be found in respective subdi - URLs are unique in DB. The same URL cannot be added twice. - Bookmarks with immutable titles are listed with bold `(L)` after the URL. - **Tags**: - - Comma (`,`) is the tag delimiter in DB. A tag cannot have comma(s) in it. Tags are filtered (for unique tags) and sorted. Tags can be replaced. + - Comma (`,`) is the tag delimiter in DB. A tag cannot have comma(s) in it. Tags are filtered (for unique tags) and sorted. Tags are stored in lower case and can be replaced, appended or deleted. - **Update** operation: - If --title, --tag or --comment is passed without argument, clear the corresponding field from DB. - If --url is passed (and --title is omitted), update the title from web using the URL. diff --git a/buku.1 b/buku.1 index 0fa601e..2e3c4cd 100644 --- a/buku.1 +++ b/buku.1 @@ -34,7 +34,7 @@ URLs are unique in DB. The same URL cannot be added twice. Bookmarks with immutable titles are listed with bold '(L)' after the URL. .PP \fITags\fR: - - Comma (',') is the tag delimiter in DB. A tag cannot have comma(s) in it. Tags are filtered (for unique tags) and sorted. Tags can be replaced. + - Comma (',') is the tag delimiter in DB. A tag cannot have comma(s) in it. Tags are filtered (for unique tags) and sorted. Tags are stored in lower case and can be replaced, appended or deleted. .PP \fIUpdate\fR operation: - If --title, --tag or --comment is passed without argument, clear the corresponding field from DB. diff --git a/buku.py b/buku.py index 36bcbb9..2783ea9 100755 --- a/buku.py +++ b/buku.py @@ -1624,11 +1624,12 @@ def parse_tags(keywords=None): orig_tags += tags.strip(DELIM).split(DELIM) for tag in orig_tags: - if tag not in unique_tags: - unique_tags += (tag, ) # Select unique tags + if tag.lower() not in unique_tags: + # Add unique tags in lowercase + unique_tags += (tag.lower(), ) # Sort the tags - sorted_tags = sorted(unique_tags, key=str.lower) + sorted_tags = sorted(unique_tags) # Wrap with delimiter return '%s%s%s' % (DELIM, DELIM.join(sorted_tags), DELIM)