def create_operation(arg1, operator, arg2):
 if (operator not in OPERATORS):
  raise OperatorCreationError('unknown operator "{0}"'.format(operator))
 opfunc = OPERATORS[operator]
 if (opfunc in (is_null, is_not_null)):
  return opfunc(arg1)
 if (arg2 is None):
  message = 'To compare a value to NULL, use the unary is_null/is_not_null operators.'
  raise OperatorCreationError(message)
 if (arg2 is NO_ARGUMENT):
  msg = 'expected an argument for this operator but none was given'
  raise OperatorCreationError(msg)
 return opfunc(arg1, arg2)

def create_operation ( arg1 , operator , arg2 ) : if ( operator not in OPERATORS ) : raise OperatorCreationError ( 'unknown operator "{0}"' . format ( operator ) ) opfunc = OPERATORS [ operator ] if ( opfunc in ( is_null , is_not_null ) ) : return opfunc ( arg1 ) if ( arg2 is None ) : message = 'To compare a value to NULL, use the unary is_null/is_not_null operators.' raise OperatorCreationError ( message ) if ( arg2 is NO_ARGUMENT ) : msg = 'expected an argument for this operator but none was given' raise OperatorCreationError ( msg ) return opfunc ( arg1 , arg2 )
creates a sqlalchemy expression for the given operation .