summaryrefslogtreecommitdiffstats
path: root/category.py
diff options
context:
space:
mode:
Diffstat (limited to 'category.py')
-rw-r--r--category.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/category.py b/category.py
index 61458dc..3acc16e 100644
--- a/category.py
+++ b/category.py
@@ -47,6 +47,21 @@ class Category:
if args[key].nonempty():
retval.add(Category(self.name, **args))
+ def inverse_set(self):
+ """
+ Returns a set of Categories that will match any state NOT matched by
+ this one (provided it specifies the same or more arguments).
+ """
+ retval = set()
+ for key, value in self.args.iteritems():
+ value = value.complement()
+ if not value.nonempty():
+ continue
+ newargs = self.args.copy()
+ newargs[key] = value
+ retval.add(Category(self.name, **newargs))
+ return retval
+
def intersect(self, other):
"""
Returns a new category consisting only of states that are in this