summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCasey Dahlin <cdahlin@redhat.com>2008-12-23 00:26:29 -0500
committerCasey Dahlin <cdahlin@redhat.com>2008-12-23 00:26:29 -0500
commitc331b82b6256ba132b6d34935892d05697a68317 (patch)
tree52679e967b7dbd2b5e458e3e0e302b39c73a498b
parenta65622d3b09e39092aba2adb75029e668c7cac51 (diff)
downloadupstate-c331b82b6256ba132b6d34935892d05697a68317.tar.gz
upstate-c331b82b6256ba132b6d34935892d05697a68317.tar.xz
upstate-c331b82b6256ba132b6d34935892d05697a68317.zip
Rewrite assert_state to behave properly and neatly
-rw-r--r--statemachine.py26
1 files changed, 18 insertions, 8 deletions
diff --git a/statemachine.py b/statemachine.py
index ced6b60..9c943e1 100644
--- a/statemachine.py
+++ b/statemachine.py
@@ -2,6 +2,7 @@ __docformat__ = 'restructuredtext'
from category import Category
from pattern import Pattern
+import setcross
class StateMachine:
"""
@@ -22,20 +23,29 @@ class StateMachine:
"""
found = None
for (match, dependency) in self.get_applicable_deps(cat):
- res = self.get_satisfied_states(cat, dependency)
- print dependency, res
+ res = self.get_satisfied_states(match, dependency)
if len(res) == 0:
- res = cat.subtract(match)
+ return False
if found == None:
- found = res
+ found = [res]
else:
- found = self.intersect_list(found, res)
+ found.append(res)
if found == None:
self.add_hold(cat)
return True
- if len(found) == 0:
- return False
- for x in found:
+ to_add = set()
+ for tup in setcross.cross(*found):
+ orig = tup
+ while len(tup) > 1:
+ newtup = (tup[0].intersect(tup[1]),)
+ if newtup[0] == None:
+ tup = ()
+ break
+ tup = newtup + tup[2:len(tup)]
+ if len(tup) == 0 or tup[0] == None:
+ continue
+ to_add.add(tup[0])
+ for x in to_add:
self.add_hold(x)
return True