def assertIdentity(self, query):
        input_query = parseString(query)
        result_query = CqlIdentityVisitor(input_query).visit()
        self.assertEqual(input_query, result_query)

        input_ids = set(id(n) for n in allnodes(input_query))
        result_ids = set(id(n) for n in allnodes(result_query))
        self.assertEqual(0, len(input_ids.intersection(result_ids)),
                         'Expected new ast to be a deepcopy.')
Example #2
0
 def visitTERM(self, node):
     if node.children[0] == self._oldTerm:
         return node.__class__(self._newTerm)
     return CqlIdentityVisitor.visitTERM(self, node)
Example #3
0
 def doVisit():
     for i in range(10):
         CqlIdentityVisitor(p).visit()
Example #4
0
 def __init__(self, ast, oldTerm, newTerm):
     CqlIdentityVisitor.__init__(self, ast)
     self._oldTerm = oldTerm
     self._newTerm = newTerm
Example #5
0
 def visitINDEX(self, node):
     indexTerm = node.children[0].children[0]
     if indexTerm in self._mapping:
         return INDEX(TERM(self._mapping[indexTerm])) 
     return CqlIdentityVisitor.visitINDEX(self, node)
Example #6
0
 def __init__(self, ast, mapping):
     CqlIdentityVisitor.__init__(self, ast)
     self._mapping = mapping
Example #7
0
 def visitTERM(self, node):
     if node.children[0] == self._oldTerm:
         return node.__class__(self._newTerm)
     return CqlIdentityVisitor.visitTERM(self, node)
Example #8
0
 def __init__(self, ast, oldTerm, newTerm):
     CqlIdentityVisitor.__init__(self, ast)
     self._oldTerm = oldTerm
     self._newTerm = newTerm