def apply_rules( self, rule_file: Dict ) -> None: """ Apply rules to the dataset. Will ignore any field where manuallyMapped is set to YES. args: - rule_file: path to the rule file returns: N/A Note - See rules/rules.py for further information """ r = Rules(rule_file) for row in self._data: #add output headers for output_header in _REQ_OUTPUT_HEADERS: if output_header not in row.keys(): row[output_header] = "" self._std_header_map[output_header] = output_header #add manuallyMapped if 'manuallymapped'not in row.keys(): row['manuallymapped'] = '' self._std_header_map['manuallymapped'] = "manuallymapped" #skip manuallyMapped rows if row['manuallymapped'] == 'YES': continue #apply rules else: r.ApplyRules(row)
class RulesTest(unittest.TestCase): m_rules = Rules() def test_init(self): self.assertEqual(self.m_rules.PossibleMoves([]), self.m_rules.ALLMOVES) def test_mid(self): self.assertEqual(sorted(self.m_rules.PossibleMoves([1, 2, 3, 4])), [5, 6, 7, 8, 9]) def test_end(self): self.assertEqual(self.m_rules.PossibleMoves(self.m_rules.ALLMOVES), [])
def apply_rules(self, rule_file: Dict) -> None: """ Apply rules to the dataset. Will ignore any field where manuallyMapped is set to YES. args: - rule_file: path to the rule file returns: N/A Note - See rules/rules.py for further information """ r = Rules(rule_file) for row in self._data: if row['manuallyMapped'] == 'YES': continue else: r.ApplyRules(row)