From a144d5ed3112d3fdf58f176c6ac3a4042c63b71c Mon Sep 17 00:00:00 2001 From: rhishikesh Date: Wed, 19 Jan 2022 00:00:30 +0530 Subject: [PATCH 1/2] adding constant handler for for comaptibality of python versions > 3.7 --- pql/matching.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pql/matching.py b/pql/matching.py index 22625b2..2f3e152 100644 --- a/pql/matching.py +++ b/pql/matching.py @@ -117,6 +117,7 @@ def handle_Name(self, name): return name.id def handle_Attribute(self, attr): return '{0}.{1}'.format(self.handle(attr.value), attr.attr) + class OperatorMap(object): def resolve_field(self, node): @@ -366,6 +367,15 @@ def handle_Call(self, node): def handle_Str(self, node): return node.s +class ConstantField(AlgebricField): + """ + Converting constants into a string (ast parser assigns a value of "Constant" to quoted strings and constant numeric values to the right + and lef part of comparison expression(comparison operators). for handling these constants we convert this constant into a string. + adding a ConsatntField handler class which we pass in a GenericField class) + """ + def handle_Constant(self, node): + return node.s + class IntField(AlgebricField): def handle_Num(self, node): return node.n @@ -424,6 +434,6 @@ def handle_Str(self, node): def handle_Call(self, node): return IdFunc().handle(node) -class GenericField(IntField, BoolField, StringField, ListField, DictField, GeoField): +class GenericField(IntField, BoolField, StringField, ListField, DictField, GeoField,ConstantField): def handle_Call(self, node): return GenericFunc().handle(node) From a86a0f9c26c75c6335bd66563df74737fa8bc2c4 Mon Sep 17 00:00:00 2001 From: rhishikesh Date: Wed, 19 Jan 2022 00:17:27 +0530 Subject: [PATCH 2/2] adding constant handler for for comaptibality of python versions > 3.7 --- pql/matching.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pql/matching.py b/pql/matching.py index 2f3e152..f13a952 100644 --- a/pql/matching.py +++ b/pql/matching.py @@ -369,7 +369,8 @@ def handle_Str(self, node): class ConstantField(AlgebricField): """ - Converting constants into a string (ast parser assigns a value of "Constant" to quoted strings and constant numeric values to the right + Converting constants into a string + (ast parser assigns a value of "Constant" to quoted strings and constant numeric values to the right and lef part of comparison expression(comparison operators). for handling these constants we convert this constant into a string. adding a ConsatntField handler class which we pass in a GenericField class) """