Example #1
0

# A class that prints A 'x' times
class PrintA(Aktion):
    def __init__(self):
        super().__init__()

    def __act__(self, times):
        print("A".join(['' for i in range(times + 1)]))


# A class that prints B 'x' times
class PrintB(Aktion):
    def __init__(self):
        super().__init__()
        self.retryin = []

    def __act__(self, times):
        print("B".join(['' for i in range(times + 1)]))


if __name__ == "__main__":

    factory = ActionFactory()
    factory.register(PrintA)
    factory.register(PrintB)

    plan = ExecutionPlan("simple_actions.json")

    plan.run()
Example #2
0
class GenerateB(Aktion):

    def __init__(self):
        super().__init__()
        self.retryin = []

    def __act__(self, times):
        return "B".join(['' for i in range(times+1)])


class ConcatSrt(Aktion):

    def __init__(self):
        super().__init__()

    def __act__(self, items, times=1):
        result = "".join([i for i in items])
        result = result.join(['' for i in range(times+1)])
        print(result)


if __name__ == "__main__":

    factory = ActionFactory()
    factory.register(GenerateA)
    factory.register(GenerateB)
    factory.register(ConcatSrt)

    plan = ExecutionPlan(r"chain_actions.json")
    plan.run()