Best Python code snippet using molecule_python
expressions.py
Source:expressions.py
...19 def __init__(self, children=None, connector=None, negated=False):20 if children is not None and len(children) > 1 and connector is None:21 raise TypeError('You have to specify a connector.')22 super(ExpressionNode, self).__init__(children, connector, negated)23 def _combine(self, other, connector, reversed, node=None):24 if reversed:25 obj = ExpressionNode([other], connector)26 obj.add(node or self, connector)27 else:28 obj = node or ExpressionNode([self], connector)29 obj.add(other, connector)30 return obj31 ###################32 # VISITOR METHODS #33 ###################34 def prepare(self, evaluator, query, allow_joins):35 return evaluator.prepare_node(self, query, allow_joins)36 def evaluate(self, evaluator, qn, connection):37 return evaluator.evaluate_node(self, qn, connection)38 #############39 # OPERATORS #40 #############41 def __add__(self, other):42 return self._combine(other, self.ADD, False)43 def __sub__(self, other):44 return self._combine(other, self.SUB, False)45 def __mul__(self, other):46 return self._combine(other, self.MUL, False)47 def __div__(self, other):48 return self._combine(other, self.DIV, False)49 def __mod__(self, other):50 return self._combine(other, self.MOD, False)51 def __and__(self, other):52 return self._combine(other, self.AND, False)53 def __or__(self, other):54 return self._combine(other, self.OR, False)55 def __radd__(self, other):56 return self._combine(other, self.ADD, True)57 def __rsub__(self, other):58 return self._combine(other, self.SUB, True)59 def __rmul__(self, other):60 return self._combine(other, self.MUL, True)61 def __rdiv__(self, other):62 return self._combine(other, self.DIV, True)63 def __rmod__(self, other):64 return self._combine(other, self.MOD, True)65 def __rand__(self, other):66 return self._combine(other, self.AND, True)67 def __ror__(self, other):68 return self._combine(other, self.OR, True)69 def prepare_database_save(self, unused):70 return self71class F(ExpressionNode):72 """73 An expression representing the value of the given field.74 """75 def __init__(self, name):76 super(F, self).__init__(None, None, False)77 self.name = name78 def __deepcopy__(self, memodict):79 obj = super(F, self).__deepcopy__(memodict)80 obj.name = self.name81 return obj82 def prepare(self, evaluator, query, allow_joins):...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!