예제 #1
0
 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)
예제 #2
0
    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()
예제 #3
0
 def migrate_context(context, _):
     if context.foo == 13:
         raise IncompatibleContext()