-
Notifications
You must be signed in to change notification settings - Fork 0
/
floormat.py
136 lines (108 loc) · 3.34 KB
/
floormat.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
import abc
import string
import random
FLAG = 'REDACTED'
class Design(abc.ABC):
def __init__(self, design=[]):
self._design = design
self._i = -1
def items(self):
return "".join(self._design)
def get_next(self):
self._i = (self._i + 1) % len(self._design)
return self._design[self._i]
def __str__(self):
return self.get_next()
class Rotate(Design):
def __init__(self):
super().__init__(design=["-", "/", "|", "\\"])
class Circles(Design):
def __init__(self):
super().__init__(design=[".", "o", "0", "O", "0", "o"])
class Random(Design):
def __init__(self):
super().__init__(design=string.ascii_lowercase)
def get_next(self):
return random.choice(self._design)
designs = {
'Flutter': Rotate(),
'Fragment': Circles(),
'Festival': Random()
}
templates = {
'Fundamental': '\n'.join([
"+" + "-"*20 + "+",
"|" + "{f}"*20 + "|",
"|" + "{f}"*20 + "|",
"|" + "{f}"*20 + "|",
"|" + "{f}"*20 + "|",
"|" + "{f}"*20 + "|",
"+" + "-"*20 + "+"
]),
'Flabbergasting': '\n'.join([
"+-----+-----+-----+-----+",
"|"+"{f}"*5+"|"+"{f}"*5+"|"+"{f}"*5+"|"+"{f}"*5+"|",
"|"+"{f}"*5+"|"+"{f}"*5+"|"+"{f}"*5+"|"+"{f}"*5+"|",
"+-----+-----+-----+-----+",
"|"+"{f}"*5+"|"+"{f}"*5+"|"+"{f}"*5+"|"+"{f}"*5+"|",
"|"+"{f}"*5+"|"+"{f}"*5+"|"+"{f}"*5+"|"+"{f}"*5+"|",
"+-----+-----+-----+-----+"
])
}
def get_happy_f():
return random.choice(["Fun", "Foxy", "Fetching"])
def get_sad_f():
return random.choice(["Fail", "Foolish", "Foul"])
def custom_template():
print('Fascinating! Forgoing the featured furniture and finding the flexible function.')
print('Fill in your floormat format. {f} flags fancy fabric, F finalizes')
print('For example, Fundamental:')
print(templates['Fundamental'])
print('F')
print('')
print('Format:')
buffer = ""
while (l := input()) != 'F':
buffer += l
return buffer
def get_template():
print("FFF features a few foundational floormat forms:")
for nm, floormat in templates.items():
print('[{}]:'.format(nm))
print(floormat.format(f=' '))
print('')
selection = input("Fill in your favorite: ")
try:
template = templates[selection.title()]
except KeyError:
print('')
template = custom_template()
print(get_happy_f() + "!")
print('')
return template
def get_pattern():
print('Finally, find the fairest felt furnishings!')
for nm, pattern in designs.items():
print('[{}]:'.format(nm))
print(pattern.items())
print('')
while True:
selection = input('Favorite: ')
try:
return designs[selection.title()]
except KeyError:
print(get_sad_f() + '!')
pass
if __name__ == '__main__':
import sys
sys.tracebacklimit = 0
sys.excepthook = lambda t,e,b: print('\n\n' + ('Farewell!' if t is KeyboardInterrupt or t is EOFError else 'F***!'))
template = get_template()
pattern = get_pattern()
print('')
print('Formulating...')
floormat = template.format(f=pattern)
print('Finished! Felicitations on your Floormat!')
print('')
print(floormat)
print('')