2005-12-04 14:46:37 +00:00
|
|
|
#!/usr/bin/python
|
|
|
|
#
|
|
|
|
# Spdl generator
|
|
|
|
#
|
|
|
|
import If
|
2005-12-04 16:41:43 +00:00
|
|
|
from misc import *
|
2005-12-04 14:46:37 +00:00
|
|
|
|
|
|
|
def processRole(rulelist, role):
|
|
|
|
|
|
|
|
print "Role", role
|
|
|
|
for rule in rulelist:
|
2005-12-04 16:41:43 +00:00
|
|
|
if role in rule.getActors():
|
|
|
|
for fact in rule.getFacts():
|
|
|
|
if type(fact) == If.MessageFact:
|
|
|
|
print fact.spdl()
|
2005-12-04 14:46:37 +00:00
|
|
|
|
|
|
|
print
|
|
|
|
return ""
|
|
|
|
|
|
|
|
|
|
|
|
def getRoles(rulelist):
|
|
|
|
roles = []
|
|
|
|
for rule in rulelist:
|
2005-12-04 16:41:43 +00:00
|
|
|
roles += rule.getActors()
|
|
|
|
return uniq(roles)
|
2005-12-04 14:46:37 +00:00
|
|
|
|
|
|
|
def generator(rulelist):
|
|
|
|
roles = getRoles(rulelist)
|
|
|
|
print "Found",len(rulelist),"rules."
|
|
|
|
print "Roles:", roles
|
|
|
|
res = ""
|
|
|
|
for role in roles:
|
|
|
|
res += processRole(rulelist,role)
|
|
|
|
return res
|
|
|
|
|