def _start_transition(self, key): if regexs.regex_and(key): self.state = states.STATE_AND elif regexs.regex_or(key): self.state = states.STATE_OR elif utilities.includes(self.allowed_props, key): self.state = states.STATE_PROP else: raise exceptions.ERROR_INVALID_KEY_FOR_START_STATE
def test_includes(self): self.assertTrue(utilities.includes([1, 2, 3], 1)) self.assertTrue(utilities.includes(['a', 'b', 'c'], 'a')) self.assertFalse(utilities.includes([1, 2, 3], 4)) self.assertFalse(utilities.includes(['a', 'b', 'c'], 'd'))
def _prop_transition(self, key): if utilities.includes(self.operators, key): self.state = states.STATE_OPERATOR else: raise exceptions.ERROR_INVALID_KEY_FOR_PROP_STATE
def _or_transition(self, key): if utilities.includes(self.allowed_props, key): self.state = states.STATE_PROP else: raise exceptions.ERROR_INVALID_KEY_FOR_OR_STATE