ArneBachmann / tagsplorer

A quick and resource-efficient OS-independent tagging filetree extension tool and library
Mozilla Public License 2.0
3 stars 1 forks source link

Change semantics of tag globs #84

Closed ArneBachmann closed 3 years ago

ArneBachmann commented 3 years ago

I just finished the rewrite for the tag globs, but found an issue. For inclusive globs on the same tag, we have a disjunction of conjunctions (OR of ANDs). For the exclusive patterns, we rather need a conjunction of disjunctions (AND of ORs).

Reason is, that the disjunction for excluding conjunctions will often exclude nothing, instead of allowing to exclude separate patterns.

Example: tag1;*;.ext2 excludes all .ext2 files (remaining, e.g., file1.ext1, filenot1.ext3). `tag1;;file1,.ext3` excludes all .ext3 files that start with file and end with 1.

Since both lines keep half of the files, the disjunction of both keep-lists leads to the exclusion of none instead of all.

ArneBachmann commented 3 years ago

OK, I solved it: If two lines for the same tag include a large number of files like * or .ext1 and exclude different sets, it simply cannot be matched correctly. Exclusion works only properly, if the inclusive patterns are mutually exclusive (disjunct) as well.

And they have to, intuitively, because we might add more and more pattern lines overtime. This cannot work, if any of them is over-generic and covers already more than the one we'd like to add.

To make the inclusive patterns distinct, it may be necessary to use the glob negation pattern [!chars]: https://docs.python.org/3.8/library/fnmatch.html

ArneBachmann commented 3 years ago

Closing as no need to fix, works as intended, but requires documentation.