bbscript/stdlib/conditions.py
def cmd_condition(ctx, op, left, right):
	"""
		To perform condition operations.

		Parameters:
		-----------
		op: operation to perform
		left: left value
		right: right value

	"""
	if op == "==":
		return left == right
	elif op == "!=":
		return left != right
	elif op == "IN":
		return right in left
	elif op == "NOT IN":
		return right not in left
	elif op == "~" or op == "!~":
		left = str(left)
		right = str(right)
		pattern = ".*?{}.*?".format(re.sub(r"[\s\.%]+", ".*?", right.strip().lower()))
		result = re.match(pattern, left.lower())
		if op == "~":
			return result != None
		elif op == "!~":
			return result == None
	elif op == ">":
		return left > right
	elif op == "<":
		return left < right
	elif op == ">=":
		return left >= right
	elif op == "<=":
		return left <= right
	elif op == "AND":
		return left and right
	elif op == "OR":
		return left or right
	elif op == "NOT":
		return not (left and right)
	elif op == "XOR":
		return bool(left) ^ bool(right)

	raise InvalidOperation("op must be one of ==, !=, ~, ~=, <, >, <=, >=, AND, OR, NOT, XOR")

		To perform condition operations.

		Parameters:
		-----------
		op: operation to perform
		left: left value
		right: right value

	
To perform condition operations.
Parameters.

operation to perform
left: left value
right: right value
To perform condition operations . Parameters . operation to perform left : left value right : right value
def cmd_condition(ctx, op, left, right):
	if op == "==":
		return left == right
	elif op == "!=":
		return left != right
	elif op == "IN":
		return right in left
	elif op == "NOT IN":
		return right not in left
	elif op == "~" or op == "!~":
		left = str(left)
		right = str(right)
		pattern = ".*?{}.*?".format(re.sub(r"[\s\.%]+", ".*?", right.strip().lower()))
		result = re.match(pattern, left.lower())
		if op == "~":
			return result != None
		elif op == "!~":
			return result == None
	elif op == ">":
		return left > right
	elif op == "<":
		return left < right
	elif op == ">=":
		return left >= right
	elif op == "<=":
		return left <= right
	elif op == "AND":
		return left and right
	elif op == "OR":
		return left or right
	elif op == "NOT":
		return not (left and right)
	elif op == "XOR":
		return bool(left) ^ bool(right)
	raise InvalidOperation("op must be one of ==, !=, ~, ~=, <, >, <=, >=, AND, OR, NOT, XOR")
def cmd_condition ( ctx , op , left , right ) : if op == "==" : return left == right elif op == "!=" : return left != right elif op == "IN" : return right in left elif op == "NOT IN" : return right not in left elif op == "~" or op == "!~" : left = str ( left ) right = str ( right ) pattern = ".*?{}.*?" . format ( re . sub ( r"[\s\.%]+" , ".*?" , right . strip ( ) . lower ( ) ) ) result = re . match ( pattern , left . lower ( ) ) if op == "~" : return result != None elif op == "!~" : return result == None elif op == ">" : return left > right elif op == "<" : return left < right elif op == ">=" : return left >= right elif op == "<=" : return left <= right elif op == "AND" : return left and right elif op == "OR" : return left or right elif op == "NOT" : return not ( left and right ) elif op == "XOR" : return bool ( left ) ^ bool ( right ) raise InvalidOperation ( "op must be one of ==, !=, ~, ~=, <, >, <=, >=, AND, OR, NOT, XOR" )
To perform condition operations.
To perform condition operations .
"""
		To perform condition operations.

		Parameters:
		-----------
		op: operation to perform
		left: left value
		right: right value

	"""
ctx
op
left
right