Passed
Push — master ( 09a9c5...672ba7 )
by Guibert
51s
created

tutorial_1.say_hello()   A

Complexity

Conditions 1

Size

Total Lines 2
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nop 1
dl 0
loc 2
rs 10
c 0
b 0
f 0
1
"""Tutorial 1 code."""
2
import curio
3
import async_btree as bt
4
5
6
def approach_object(name: str):
7
    print(f"approach_object: {name}")
8
9
10
def check_battery():
11
    print("battery ok")
12
13
14
async def say_hello(name: str):
15
    print(f"Hello: {name}")
16
17
18
class GripperInterface:
19
    def __init__(self):
20
        self._open = False
21
22
    def open(self):
23
        print("GripperInterface Open")
24
        self._open = True
25
26
    def close(self):
27
        print("GripperInterface Close")
28
        self._open = False
29
30
31
gripper = GripperInterface()
32
33
b_tree = bt.sequence(
34
    children=[
35
        bt.always_success(child=bt.action(target=say_hello, name="John")),
36
        bt.always_success(child=bt.action(target=gripper.open)),
37
        bt.always_success(child=bt.action(target=approach_object, name="house")),
38
        bt.always_success(child=bt.action(target=gripper.close)),
39
    ]
40
)
41
42
43
if __name__ == '__main__':
44
    curio.run(b_tree)
45