-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsometools.py
41 lines (35 loc) · 1 KB
/
sometools.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
'''
Eine neue Auswahl in die Liste eingaben aufnehmen.
Eine Abkürzung in Klammern dahinter schreiben. -
'''
eingaben = ['collatz(col)','ggt','binhextest(bht)', 'QR_Helper(QR-H)']
eingaben.append('zeige_unicode_zeichen(zuz)')
eingaben.append('BaumDarstellung(Baum)')
def help_():
print('Verfügbare Kommandos (Abkürzung in Klammern):')
print(*eingaben)
edict = {} # dictionary mit den gültigen Eingaben
for x in eingaben:
p1 = x.find('(')
if p1 > 0:
p2 = x.find(')',p1)
abk = x[p1+1:p2] # abkürzung
cmd = x[:p1] # kommando
edict[cmd] = cmd
edict[abk] = cmd
else:
edict[x] = x
print('Eingabe oder q(quit), h(help)')
while True:
print('-> ',end='')
eingabe = input()
if eingabe == 'q':
print('Goodbye')
break
elif eingabe == 'h':
help_()
elif eingabe not in edict:
print('Ungültige Eingabe')
else:
exec('from ' + edict[eingabe] + ' import *')
exec(edict[eingabe]+'_ui()')