-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpaths.py
54 lines (36 loc) · 1.07 KB
/
paths.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
48
49
50
51
52
53
from IFPathNode import IFPathNode
def getPaths(fn):
"Read paths from python 3 text file derived form python 2 pickle file"
with open(fn, 'r') as f:
ls = f.readlines()
return [eval(l) for l in ls]
def getIFPaths(receiver, filepath=None):
"Returns a list of paths from the pickled cabling file for given receiver"
if filepath is None:
fn = "zdb.pkl.%s.txt" % receiver
else:
fn = filepath
ps = getPaths(fn)
ifPaths = []
ifPath = None
for path in ps:
#print(path)
ifPath = []
for p in path:
pn = IFPathNode(p)
ifPath.append(pn)
ifPaths.append(ifPath)
return ifPaths
def test1():
rx = "Rcvr1_2"
fn = "zdb.201118.pkl.%s.txt" % rx
paths = getIFPaths(rx, filepath=fn)
for path in paths:
print(path)
for p in path:
print (p.name, p.device, p.deviceId, p.port, p.getPortNumber())
print(len(paths))
def main():
test1()
if __name__ == '__main__':
main()