-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnodes.py
More file actions
executable file
·40 lines (30 loc) · 982 Bytes
/
nodes.py
File metadata and controls
executable file
·40 lines (30 loc) · 982 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
38
39
40
# These are the nodes that hold information about a playlist
class NodePlaylist:
def __init__(self, label):
self._label = label
self._children = []
self._depth = 0
def addChild(self, child):
child.setParent(self)
child.setDepth(self._depth + 1)
self._children.append(child)
def getNumberOfChildren(self):
return len(self._children)
def getChild(self, index):
return self._children[index]
def setParent(self, parent):
self._parent = parent
def getParent(self):
return self._parent
def getLabel(self):
return self._label
def getIndex(self, childNode):
# return the index of the childNode
# (used for tree walking)
return self._children.index(childNode)
def setDepth(self, depth):
for c in self._children:
c.setDepth(depth + 1)
self._depth = depth
def getDepth(self):
return self._depth