-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpattern_printer.py
More file actions
114 lines (93 loc) · 3.72 KB
/
Copy pathpattern_printer.py
File metadata and controls
114 lines (93 loc) · 3.72 KB
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
import symbols
import patterns
import utils
class PatternPrinter:
def __init__(self):
self.findSymbolLoop = True
self.findPatternLoop = True
self.findSymbol()
self.findPattern()
self.executePattern()
def findSymbol(self):
while self.findSymbolLoop:
utils.newLine()
self.printSymbolList()
utils.newLine()
symbol_input = input("Wybierz symbol z listy: ")
if not symbol_input.isdigit() or int(symbol_input) >= len(symbols.symbols):
utils.clearTerminal()
self.err_InputNotFound()
continue
if symbol_input and int(symbol_input) < len(symbols.symbols):
index = int(symbol_input)
nazwa, znak = list(symbols.symbols.items())[index]
utils.newLine()
print(nazwa)
print(znak)
utils.clearTerminal()
symbolConfirm = input(f"{znak} - czy chcesz wybrać ten symbol? Y/N\n").strip().upper()
if symbolConfirm == "N":
continue
elif symbolConfirm == "Y":
self.selectedSymbol = znak
self.findSymbolLoop = False
break
else:
utils.clearTerminal()
self.err_InputNotFound()
continue
else:
utils.clearTerminal()
self.err_InputNotFound()
continue
def findPattern(self):
while self.findPatternLoop:
utils.newLine()
self.printPatternList()
utils.newLine()
pattern_input = input("Wybierz pattern z listy: ")
if not pattern_input.isdigit() or int(pattern_input) >= len(patterns.patterns):
utils.clearTerminal()
self.err_InputNotFound()
continue
if pattern_input and int(pattern_input) < len(patterns.patterns):
jndex = int(pattern_input)
pattern_name, pattern_function = list(patterns.patterns.items())[jndex]
utils.newLine()
print(pattern_name)
utils.clearTerminal()
patternConfirm = input(f"{pattern_name} - czy chcesz wybrać ten pattern? Y/N\n").strip().upper()
if patternConfirm == "N":
continue
elif patternConfirm == "Y":
self.selectedPatternFunction = pattern_function
self.findPatternLoop = False
break
else:
utils.clearTerminal()
self.err_InputNotFound()
continue
def executePattern(self):
utils.clearTerminal()
sizeInput = input("Podaj rozmiar wzoru: ")
utils.newLine()
if not sizeInput.isdigit():
utils.clearTerminal
self.err_InputNotFound()
input("Naciśnij Enter, by spróbować ponownie...")
return self.executePattern()
size = int(sizeInput)
utils.newLine()
self.selectedPatternFunction(self.selectedSymbol, size)
def printSymbolList(self):
for i, (_name, _symb) in enumerate(symbols.symbols.items()):
symbolsInTerminal = f"{i}. '{_name}' - '{_symb}'"
print(symbolsInTerminal)
def printPatternList(self):
for j, _patt in enumerate(patterns.patterns):
patternsInTerminal = f"{j}. '{_patt}'"
print(patternsInTerminal)
def err_InputNotFound(self):
print("Nieprawidłowy input! Wracam do poprzedniego ekranu.")
if __name__ == "__main__":
PatternPrinter()