-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserverSwitches.py
More file actions
49 lines (33 loc) · 1.09 KB
/
serverSwitches.py
File metadata and controls
49 lines (33 loc) · 1.09 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
import serverFunctions
INPUT_ERROR = "[!] Switch Invalid input"
DELIMITER = "*"
def logic(data, user_input, chosen_switch):
user_data = user_input.split(DELIMITER)
print(user_data)
try:
choice = int(user_data[0])
except ValueError:
print(INPUT_ERROR)
if len(user_data) > 1:
param = user_data[1]
ans = chosen_switch(choice, data, param)
return ans
def song_info_switch(i, data, param):
switcher = {
1: serverFunctions.get_song_length(data, param),
2: serverFunctions.get_song_lyrics(data, param),
3: serverFunctions.get_source_album(data, param)
}
return switcher.get(i, INPUT_ERROR)
def find_switch(i, data, param):
switcher = {
1: serverFunctions.find_song_name(data, param),
2: serverFunctions.find_song_lyrics(data, param)
}
return switcher.get(i, INPUT_ERROR)
def stat_switch(i, data, param):
switcher = {
1: serverFunctions.get_list_top_words(data, param),
2: serverFunctions.get_longest_albums(data)
}
return switcher.get(i, INPUT_ERROR)