Updates for issue #223
Refactored get_configuration of the base rule class. It now reports attributes in the self.configuration list. This allows individual rules to add new configuration attributes without affecting the base class.
This commit is contained in:
parent
1d53fa7966
commit
70da1d4b01
|
|
@ -13,6 +13,7 @@ class rule():
|
|||
self.fixable = True
|
||||
self.dFix = {}
|
||||
self.dFix['violations'] = {}
|
||||
self.configuration = ['indentSize', 'phase', 'disable', 'fixable']
|
||||
|
||||
def configure(self, dConfiguration):
|
||||
'''Configures attributes on rules using a dictionary of the following form:
|
||||
|
|
@ -98,8 +99,6 @@ class rule():
|
|||
|
||||
def get_configuration(self):
|
||||
dConfig = {}
|
||||
dConfig['disable'] = self.disable
|
||||
dConfig['fixable'] = self.fixable
|
||||
dConfig['indentSize'] = self.indentSize
|
||||
dConfig['phase'] = self.phase
|
||||
for sParameter in self.configuration:
|
||||
dConfig[sParameter] = getattr(self, sParameter)
|
||||
return dConfig
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ class rule_011(rule.rule):
|
|||
self.port_direction = None
|
||||
self.phase = 7
|
||||
self.fixable = False # This requires the user to fix as this could cover multiple files.
|
||||
self.configuration.append('port_direction')
|
||||
|
||||
def analyze(self, oFile):
|
||||
select_solution(self)
|
||||
|
|
|
|||
|
|
@ -103,8 +103,6 @@ class testRuleMethods(unittest.TestCase):
|
|||
oRule = rule.rule()
|
||||
oRule.name = 'xyz'
|
||||
oRule.identifier = '010'
|
||||
oRule.disable = False
|
||||
oRule.fixable = True
|
||||
oRule.phase = 3
|
||||
dExpected = {}
|
||||
dExpected['disable'] = False
|
||||
|
|
@ -112,8 +110,8 @@ class testRuleMethods(unittest.TestCase):
|
|||
dExpected['indentSize'] = 2
|
||||
dExpected['phase'] = 3
|
||||
dActual = oRule.get_configuration()
|
||||
for sKey in dExpected['xyz_010'].keys():
|
||||
self.assertEqual(dActual['xyz_010'][sKey], dExpected['xyz_010'][sKey])
|
||||
for sKey in dActual['xyz_010'].keys():
|
||||
self.assertEqual(dActual['xyz_010'][sKey], dExpected['xyz_010'][sKey])
|
||||
for sKey in dExpected.keys():
|
||||
self.assertEqual(dActual[sKey], dExpected[sKey])
|
||||
for sKey in dActual.keys():
|
||||
self.assertEqual(dActual[sKey], dExpected[sKey])
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue