How to use the djangoql.ast.Node function in djangoql

To help you get started, we’ve selected a few djangoql examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ivelum / djangoql / djangoql / ast.py View on Github external
class Name(Node):
    def __init__(self, parts):
        if isinstance(parts, list):
            self.parts = parts
        elif isinstance(parts, tuple):
            self.parts = list(parts)
        else:
            self.parts = [parts]

    @property
    def value(self):
        return '.'.join(self.parts)


class Const(Node):
    def __init__(self, value):
        self.value = value


class List(Node):
    def __init__(self, items):
        self.items = items

    @property
    def value(self):
        return [i.value for i in self.items]


class Operator(Node):
    def __init__(self, operator):
        self.operator = operator
github ivelum / djangoql / djangoql / ast.py View on Github external
class Const(Node):
    def __init__(self, value):
        self.value = value


class List(Node):
    def __init__(self, items):
        self.items = items

    @property
    def value(self):
        return [i.value for i in self.items]


class Operator(Node):
    def __init__(self, operator):
        self.operator = operator


class Logical(Operator):
    pass


class Comparison(Operator):
    pass
github ivelum / djangoql / djangoql / ast.py View on Github external
elif isinstance(parts, tuple):
            self.parts = list(parts)
        else:
            self.parts = [parts]

    @property
    def value(self):
        return '.'.join(self.parts)


class Const(Node):
    def __init__(self, value):
        self.value = value


class List(Node):
    def __init__(self, items):
        self.items = items

    @property
    def value(self):
        return [i.value for i in self.items]


class Operator(Node):
    def __init__(self, operator):
        self.operator = operator


class Logical(Operator):
    pass
github ivelum / djangoql / djangoql / schema.py View on Github external
def validate(self, node):
        """
        Validate DjangoQL AST tree vs. current schema
        """
        assert isinstance(node, Node)
        if isinstance(node.operator, Logical):
            self.validate(node.left)
            self.validate(node.right)
            return
        assert isinstance(node.left, Name)
        assert isinstance(node.operator, Comparison)
        assert isinstance(node.right, (Const, List))

        # Check that field and value types are compatible
        field = self.resolve_name(node.left)
        value = node.right.value
        if field is None:
            if value is not None:
                raise DjangoQLSchemaError(
                    'Related model %s can be compared to None only, but not to '
                    '%s' % (node.left.value, type(value).__name__)
github ivelum / djangoql / djangoql / ast.py View on Github external
if getattr(other, k) != v:
                return False
        return True

    def __ne__(self, other):
        return not self.__eq__(other)


class Expression(Node):
    def __init__(self, left, operator, right):
        self.left = left
        self.operator = operator
        self.right = right


class Name(Node):
    def __init__(self, parts):
        if isinstance(parts, list):
            self.parts = parts
        elif isinstance(parts, tuple):
            self.parts = list(parts)
        else:
            self.parts = [parts]

    @property
    def value(self):
        return '.'.join(self.parts)


class Const(Node):
    def __init__(self, value):
        self.value = value
github ivelum / djangoql / djangoql / ast.py View on Github external
__repr__ = __str__

    def __eq__(self, other):
        if not isinstance(other, self.__class__):
            return False
        for k, v in self.__dict__.items():
            if getattr(other, k) != v:
                return False
        return True

    def __ne__(self, other):
        return not self.__eq__(other)


class Expression(Node):
    def __init__(self, left, operator, right):
        self.left = left
        self.operator = operator
        self.right = right


class Name(Node):
    def __init__(self, parts):
        if isinstance(parts, list):
            self.parts = parts
        elif isinstance(parts, tuple):
            self.parts = list(parts)
        else:
            self.parts = [parts]

    @property