Exemple #1
0
    def convert(self, value, receiver, context, function_spec, engine, *args,
                **kwargs):
        if isinstance(value, expressions.Constant):
            value = value.value

        if value is None:
            if self.nullable:
                return None
            raise exceptions.ArgumentValueException()

        for smart_type in self.types:
            value = smart_type.convert(value, receiver, context, function_spec,
                                       engine, *args, **kwargs)
        return value
Exemple #2
0
    def convert(self, value, receiver, context, function_spec, engine, *args,
                **kwargs):
        if isinstance(value, expressions.Constant):
            value = value.value

        if value is None:
            if self.nullable:
                return None
            else:
                suitable_type = None
        else:
            suitable_type = self._check_match(value, context, engine, *args,
                                              **kwargs)
        if suitable_type:
            return suitable_type.convert(value, receiver, context,
                                         function_spec, engine, *args,
                                         **kwargs)
        raise exceptions.ArgumentValueException()
Exemple #3
0
 def convert(self, value, receiver, context, function_spec, engine, *args,
             **kwargs):
     if not self.check(value, context, engine, *args, **kwargs):
         raise exceptions.ArgumentValueException()
     utils.limit_memory_usage(engine, (1, value))
     return value