-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUtils.py
47 lines (38 loc) · 1.22 KB
/
Utils.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
42
43
44
45
46
47
import hashlib
from Container import Container
class Util:
def __init__(self):
pass
@staticmethod
def printContainers(containers):
for i in range(len(containers)):
print(str(i) + "| " + str(containers[i]))
@staticmethod
def takeSnapshot(containers):
snapshot = []
for i in range(len(containers)):
snapshot.append(containers[i].takeSnapshot())
return snapshot
@staticmethod
def loadSnapshot(snapshot):
containers = []
for i in range(len(snapshot)):
container = Container([])
container.loadSnapshot(snapshot[i])
containers.append(container)
return containers
@staticmethod
def takeSnapshotFingerprint(containers):
return hashlib.md5(str(Util.takeSnapshot(containers))).hexdigest()
@staticmethod
def vectorFullArrange(endpoint):
arranges = []
for i in range(len(endpoint)):
for j in range(len(endpoint)):
if i == j:
continue
arranges.append({"from": endpoint[i], "to": endpoint[j]})
return arranges
@staticmethod
def getVectorScore(vector):
return vector['score']