27def readFile(name):
28 mydict = {}
29 if not os.path.exists(name):
30 print(
"MergeCalibFiles - ERROR File name %22s not found" % name)
31 return mydict
32 else:
33 print(
"MergeCalibFiles - Reading: %22s"% name)
34
35 with open(name) as fp:
36 lines = fp.readlines()
37 mod = -1
38 for line in lines:
39
40 if line.startswith("L") or line.startswith("D"):
41 line = line.rstrip("\n")
42 splittedline = line.split(" ")
43
44 if int(splittedline[1]) in mydict.keys():
45 print(
"MergeCalibFiles - ERROR Module key exists already - Contact pixel offline team")
46 exit(1)
47 else:
48 mydict[int(splittedline[1])] = splittedline[0]+' '+splittedline[1]+"\n"
49 mod = int(splittedline[1])
50
51
52 elif line.startswith("I"):
53 mydict[mod] = mydict[mod] + line
54 else:
55 print(
"MergeCalibFiles - ERROR Line is not a module or a frontend - Contact pixel offline team")
56 exit(1)
57
58 return mydict
59
60