-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path3demo.py
executable file
·34 lines (28 loc) · 974 Bytes
/
3demo.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
#!/usr/bin/env python3
#
# Demonstration of Interro
#
# Copyright (c) 2012 Dominic van Berkel. See LICENSE for details.
#
import interro as inter
c = inter.Interro(msg_callback=print)
c.add(inter.YesNoQ('TOS',
question='Do you agree to the TOS?',
onanswer={True: 'email'},
default_next='noTOS'))
c.add(inter.TextQ('email',
question='What is your email address?',
message='We will not share this with bad people',
validation=[(lambda x: '@' in x, 'Invalid address.')],
confirm=True,
default_next='age'))
c.add(inter.NumberQ('age',
question='How old are you?',
req_positive=True))
c.add(inter.MessageQ('noTOS',
message='Well, that\'s unfortunate. Bye!'))
c.start('TOS')
while not c.complete:
response = input('> ')
c.answer(response)
print(c.results())