@@ -167,3 +167,105 @@ def __init__(self) -> None:
167167
168168 def value (self ) -> int :
169169 return 1 if self .lhs .value () == self .rhs .value () else 0
170+
171+
172+ class IsNot (Operator ):
173+ def __init__ (self ) -> None :
174+ super ().__init__ (- 1 , True )
175+
176+ def value (self ) -> int :
177+ return 1 if self .lhs .value () != self .rhs .value () else 0
178+
179+
180+ class In (Operator ):
181+ def __init__ (self ) -> None :
182+ super ().__init__ (- 1 , True )
183+
184+ def value (self ) -> int :
185+ lst = self .rhs .value ()
186+ if not isinstance (lst , list ):
187+ raise ValueError ("Right operand of IN must be a list" )
188+ return 1 if self .lhs .value () in lst else 0
189+
190+
191+ class NotIn (Operator ):
192+ def __init__ (self ) -> None :
193+ super ().__init__ (- 1 , True )
194+
195+ def value (self ) -> int :
196+ lst = self .rhs .value ()
197+ if not isinstance (lst , list ):
198+ raise ValueError ("Right operand of NOT IN must be a list" )
199+ return 0 if self .lhs .value () in lst else 1
200+
201+
202+ class Contains (Operator ):
203+ def __init__ (self ) -> None :
204+ super ().__init__ (0 , True )
205+
206+ def value (self ) -> int :
207+ s = self .lhs .value ()
208+ search = self .rhs .value ()
209+ if not isinstance (s , str ) or not isinstance (search , str ):
210+ raise ValueError ("CONTAINS requires string operands" )
211+ return 1 if search in s else 0
212+
213+
214+ class NotContains (Operator ):
215+ def __init__ (self ) -> None :
216+ super ().__init__ (0 , True )
217+
218+ def value (self ) -> int :
219+ s = self .lhs .value ()
220+ search = self .rhs .value ()
221+ if not isinstance (s , str ) or not isinstance (search , str ):
222+ raise ValueError ("NOT CONTAINS requires string operands" )
223+ return 0 if search in s else 1
224+
225+
226+ class StartsWith (Operator ):
227+ def __init__ (self ) -> None :
228+ super ().__init__ (0 , True )
229+
230+ def value (self ) -> int :
231+ s = self .lhs .value ()
232+ search = self .rhs .value ()
233+ if not isinstance (s , str ) or not isinstance (search , str ):
234+ raise ValueError ("STARTS WITH requires string operands" )
235+ return 1 if s .startswith (search ) else 0
236+
237+
238+ class NotStartsWith (Operator ):
239+ def __init__ (self ) -> None :
240+ super ().__init__ (0 , True )
241+
242+ def value (self ) -> int :
243+ s = self .lhs .value ()
244+ search = self .rhs .value ()
245+ if not isinstance (s , str ) or not isinstance (search , str ):
246+ raise ValueError ("NOT STARTS WITH requires string operands" )
247+ return 0 if s .startswith (search ) else 1
248+
249+
250+ class EndsWith (Operator ):
251+ def __init__ (self ) -> None :
252+ super ().__init__ (0 , True )
253+
254+ def value (self ) -> int :
255+ s = self .lhs .value ()
256+ search = self .rhs .value ()
257+ if not isinstance (s , str ) or not isinstance (search , str ):
258+ raise ValueError ("ENDS WITH requires string operands" )
259+ return 1 if s .endswith (search ) else 0
260+
261+
262+ class NotEndsWith (Operator ):
263+ def __init__ (self ) -> None :
264+ super ().__init__ (0 , True )
265+
266+ def value (self ) -> int :
267+ s = self .lhs .value ()
268+ search = self .rhs .value ()
269+ if not isinstance (s , str ) or not isinstance (search , str ):
270+ raise ValueError ("NOT ENDS WITH requires string operands" )
271+ return 0 if s .endswith (search ) else 1
0 commit comments