-
Notifications
You must be signed in to change notification settings - Fork 0
/
rule.py
29 lines (23 loc) · 799 Bytes
/
rule.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from data import dbManager
class Rule():
def __init__(self, rule):
self.rule = rule
self.contexts = dbManager.getContexts()
self.ruleDictionary = self._generateDictionary()
def _generateDictionary(self):
dict = {}
for (context, bit) in zip(self.contexts, self.rule):
dict.update({
tuple(context) : bit
})
return dict
# returns the rule itself, the dictionary
def getRule(self):
return self.ruleDictionary
# returns the state list of the rule
def getRuleList(self):
return self.rule
# sets a new rule and creates a new dictionary
def setRule(self, newRule):
self.rule = newRule
self.ruleDictionary = self._generateDictionary()