add __repr__ to Q and QCombination
This commit is contained in:
parent
36c5f02bfb
commit
c09bfca634
@ -131,6 +131,10 @@ class QCombination(QNode):
|
|||||||
else:
|
else:
|
||||||
self.children.append(node)
|
self.children.append(node)
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
op = ' & ' if self.operation is self.AND else ' | '
|
||||||
|
return '(%s)' % op.join([repr(node) for node in self.children])
|
||||||
|
|
||||||
def accept(self, visitor):
|
def accept(self, visitor):
|
||||||
for i in range(len(self.children)):
|
for i in range(len(self.children)):
|
||||||
if isinstance(self.children[i], QNode):
|
if isinstance(self.children[i], QNode):
|
||||||
@ -151,6 +155,9 @@ class Q(QNode):
|
|||||||
def __init__(self, **query):
|
def __init__(self, **query):
|
||||||
self.query = query
|
self.query = query
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return 'Q(**%s)' % repr(self.query)
|
||||||
|
|
||||||
def accept(self, visitor):
|
def accept(self, visitor):
|
||||||
return visitor.visit_query(self)
|
return visitor.visit_query(self)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user