-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNode.py
More file actions
32 lines (22 loc) · 717 Bytes
/
Node.py
File metadata and controls
32 lines (22 loc) · 717 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
import sys,re
import File
import itertools
'''
Node Object Structure
id attribute to be used by heap for prioritizing in a situation where two items have the same value for currentSpaceUsed
'''
class Node(object):
newid = itertools.count().next #object level attibute
def __init__(self, name, availSpace):
#unique sequence count
self.name = name
self.availSpace = int(availSpace)
self.currentSpaceUsed = 0
self.id = Node.newid()
def storeFile(self, file):
self.currentSpaceUsed += file.size
self.availSpace -= file.size
file.location = self.name
def heapItem(self):
#triple representation of Node object for storage in priority array
return (self.currentSpaceUsed,self.id, self)