Skip to content

Commit

Permalink
Merge pull request #301 from jim-easterbrook/devel
Browse files Browse the repository at this point in the history
Devel
  • Loading branch information
jim-easterbrook authored Nov 13, 2024
2 parents 5a4ceb7 + c70c3ae commit 18784c0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see
<http://www.gnu.org/licenses/>.

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.
Expand Down
9 changes: 8 additions & 1 deletion src/photini/keywords.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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:
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 18784c0

Please sign in to comment.