Skip to content

Commit

Permalink
FolderNameFilter: allow multiple tags per folder
Browse files Browse the repository at this point in the history
So far, the last entry wins when a folder is specified multiple times as
a folder transform. The reason is that the folder name is a key in a
dict whose values are tags. On the other hand, if a message has copies
in several folders then all these rules apply.

Change (fix?) afew's FolderNameFilter so that multiple transforms for
the same folder lead to multiple tags being added. Technically, this is
done by using sets as values in the transform dict.

In the future, we might think about implementing notmuch-tag style
notation (with the obvious quoting issues).
  • Loading branch information
mjg committed Feb 28, 2024
1 parent a3f6f6a commit 8edec78
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions afew/filters/FolderNameFilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def __transform_folders(self, folders):
transformations = set()
for folder in folders:
if folder in self.__folder_transforms:
transformations.add(self.__folder_transforms[folder])
transformations.update(self.__folder_transforms[folder])
else:
transformations.add(folder)
if self.__folder_lowercases:
Expand All @@ -71,5 +71,8 @@ def __parse_transforms(self, transformation_description):
transformations = dict()
for rule in shlex.split(transformation_description):
folder, tag = rule.split(':')
transformations[folder] = tag
try:
transformations[folder].add(tag)
except KeyError:
transformations[folder] = set([tag])
return transformations

0 comments on commit 8edec78

Please sign in to comment.