Beispiel #1
0
 def execute(self, context):
     new_context = context.create_child_context()
     try:
         super(MethodBlock, self).execute(new_context)
     except exceptions.ReturnException as e:
         return e.value
     except exceptions.BreakException:
         raise exceptions.DslInvalidOperationError(
             'Break cannot be used on method level')
     except exceptions.ContinueException:
         raise exceptions.DslInvalidOperationError(
             'Continue cannot be used on method level')
     else:
         return None
Beispiel #2
0
 def execute(self, context, murano_class):
     new_context = yaql.context.Context(context)
     new_context.set_data(self._name, '?currentMethod')
     try:
         super(MethodBlock, self).execute(new_context, murano_class)
     except exceptions.ReturnException as e:
         return e.value
     except exceptions.BreakException:
         raise exceptions.DslInvalidOperationError(
             'Break cannot be used on method level')
     except exceptions.ContinueException:
         raise exceptions.DslInvalidOperationError(
             'Continue cannot be used on method level')
     else:
         return None
Beispiel #3
0
 def execute(self, context):
     res = self._condition(context)
     if not isinstance(res, types.BooleanType):
         raise exceptions.DslInvalidOperationError(
             'Condition must be evaluated to boolean type')
     if res:
         self._code1.execute(context)
     elif self._code2 is not None:
         self._code2.execute(context)
Beispiel #4
0
    def execute(self, context):
        matched = False
        for key, value in self._switch.iteritems():
            res = helpers.evaluate(key, context)
            if not isinstance(res, types.BooleanType):
                raise exceptions.DslInvalidOperationError(
                    'Switch case must be evaluated to boolean type')
            if res:
                matched = True
                CodeBlock(value).execute(context)

        if self._default is not None and not matched:
            self._default.execute(context)