예제 #1
0
class UpperCaser:
    in_lines = flowbase.Port()
    out_lines = flowbase.Port()

    async def run(self):
        while not self.in_lines.empty():
            s = await self.in_lines.get()
            await self.out_lines.put(s.upper())
예제 #2
0
class StringJoiner:
    in_leftpart = flowbase.Port()
    in_rightpart = flowbase.Port()
    out_lines = flowbase.Port()

    async def run(self):
        while not self.in_leftpart.empty() or not self.in_rightpart.empty():
            leftpart = await self.in_leftpart.get()
            rightpart = await self.in_rightpart.get()
            await self.out_lines.put(f"{leftpart}{rightpart}")
예제 #3
0
class StringSplitter:
    in_lines = flowbase.Port()
    out_leftpart = flowbase.Port()
    out_rightpart = flowbase.Port()

    async def run(self):
        while not self.in_lines.empty():
            s = await self.in_lines.get()
            await self.out_leftpart.put(s[:int(len(s) / 2)])
            await self.out_rightpart.put(s[int(len(s) / 2):])
예제 #4
0
class Printer:
    in_lines = flowbase.Port()

    async def run(self):
        while not self.in_lines.empty():
            s = await self.in_lines.get()
            print(f"Printer got line: {s}")
예제 #5
0
class HiSayer:
    out_lines = flowbase.Port()

    async def run(self):
        for i in range(20):
            await self.out_lines.put(f"Hi hi for the {i+1}:th time...")