Beispiel #1
0
    def store_result(
        self, name: str,
        response: Any,
        agate_table: Optional[agate.Table] = None
    ) -> str:
        if agate_table is None:
            agate_table = agate_helper.empty_table()

        self.sql_results[name] = AttrDict({
            'response': response,
            'data': agate_helper.as_matrix(agate_table),
            'table': agate_table
        })
        return ''
Beispiel #2
0
    def validation(self):
        def validate_any(*args) -> Callable[[T], None]:
            def inner(value: T) -> None:
                for arg in args:
                    if isinstance(arg, type) and isinstance(value, arg):
                        return
                    elif value == arg:
                        return
                raise ValidationException(
                    'Expected value "{}" to be one of {}'
                    .format(value, ','.join(map(str, args))))
            return inner

        return AttrDict({
            'any': validate_any,
        })