From 6120b4244d17b8b956470bc253f2d4d858b3bba0 Mon Sep 17 00:00:00 2001 From: Jim Easterbrook Date: Wed, 13 Nov 2024 13:30:34 +0000 Subject: [PATCH 1/2] Allow near-duplicate hierarchical keywords If the user's keywords.json file contains keywords whose case folded versions are the same (e.g. 'Paris' and 'paris') the auto synching of keywords could get confused and try to delete the same flat keyword more than once. --- src/photini/keywords.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/photini/keywords.py b/src/photini/keywords.py index 620f717c..8a963334 100644 --- a/src/photini/keywords.py +++ b/src/photini/keywords.py @@ -652,6 +652,7 @@ def sync_nested_from_flat(self, images, remove=False, silent=False): for image in images: new_tags = [] keywords = image.metadata.keywords or [] + cf_keywords = [x.casefold() for x in keywords] for keyword in keywords: votes = {} for match in self.data_model.find_name(keyword): @@ -661,6 +662,11 @@ def sync_nested_from_flat(self, images, remove=False, silent=False): votes[nested_tag] = 0 while match: if match.text() in keywords: + # exact match worth a lot + votes[nested_tag] += 10 + elif (match.data(HierarchicalTagDataItem.sort_role) + in cf_keywords): + # case-folded match worth less votes[nested_tag] += 1 match = match.parent() if len(votes) == 1: @@ -722,7 +728,8 @@ def sync_flat_from_nested(self, images, remove=False, silent=False): if keyword in new_keywords: continue for match in self.data_model.find_name(keyword): - if match.checked('copyable'): + if (match.text() in keywords + and match.checked('copyable')): keywords.remove(keyword) # set new values changed = image.metadata.changed() From c70c3aec8723e5ac1191499dbe7eda5952063229 Mon Sep 17 00:00:00 2001 From: Jim Easterbrook Date: Wed, 13 Nov 2024 13:44:12 +0000 Subject: [PATCH 2/2] Update change log --- CHANGELOG.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 79b7a191..c1da8549 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -16,6 +16,9 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . +Changes in v2024.11.1: + 1/ Fix bug with case insensitivity of hierarchical keywords. + Changes in v2024.11.0: 1/ Sync of hierarchical and "flat" keywords is now automatic. 2/ Importer "refresh" button now reloads file list.