def match_list(self, setting, value, context, attrs, metas): """Match a list of values with the given context. returns a tuple containing number of matched and all values. """ matched = 0 for item in value: if self.is_valid_item(setting, item, attrs, metas): matched += 1 elif setting.required == ContextSetting.REQUIRED: raise IncompatibleContext() return matched, len(value)
def match_value(self, setting, value, attrs, metas): """Match a single value """ if value[1] < 0: return 0, 0 if self._var_exists(setting, value, attrs, metas): return 1, 1 elif setting.required == setting.OPTIONAL: return 0, 1 else: raise IncompatibleContext()
def migrate_context(context, _): if context.foo == 13: raise IncompatibleContext()