-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustom_queue.py
More file actions
37 lines (30 loc) · 913 Bytes
/
custom_queue.py
File metadata and controls
37 lines (30 loc) · 913 Bytes
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
class CustomQueue:
def __init__(self):
self.loops = {}
self.data = {}
def set_loop(self, id, value):
self.loops[id] = value
def get_loop(self, id):
if not id in self.loops:
return False
return self.loops[id]
def add(self, id, audio_name):
if id in self.data:
self.data[id].append(audio_name)
else:
self.data[id] = [audio_name]
def clear(self, id):
self.data[id] = []
self.loops[id] = False
def pop(self, id):
if not id in self.data or self.data[id] == []:
return None
return self.data[id].pop(0)
def front(self, id):
if not id in self.data or self.data[id] == []:
return None
return self.data[id][0]
def get_len(self, id):
if not id in self.data:
return 0
return len(self.data[id])