-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathexample.py
43 lines (34 loc) · 850 Bytes
/
example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
"""
Example of advanced batchfile module usage where the stdout is captured,
and the state is initialized with a Replay() and then set to a callback
"""
from batchfile import Batchfile
from batchfile.replay import Replay
class Page:
def __init__(self):
self.page = []
def append(self, line):
self.page.append(line)
print(line, end="")
def send_input(self, line=""):
# newline counts as the enter key here
return f"{input()}\n"
def clear(self):
self.page.clear()
def main():
actions = (
"a",
"a",
" ",
" ",
"Brianna",
)
page = Page()
bat = Replay(
actions=actions,
sleep_duration=0.5,
stdin=page.send_input,
stdout=page,
)
bat.run(["cd games/funtimes", "call funtimes.bat"])
main()