ATLAS Offline Software
CreateTrfArgs.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
2 
3 import pickle, os.path, sys, os
4 def fileExists(fp):
5  #caveats : http://stackoverflow.com/questions/82831/how-do-i-check-if-a-file-exists-using-python
6  return os.path.isfile(fp)
7 
8 def getPickle(fp):
9  f=open(fp,'r')
10  d=pickle.load(f)
11  return d
12 
13 def correctPath(myPickle):
14  thisPath=os.getcwd()
15  #find the variable which gives the SCTCalibConfig path
16  SCTCalibConfigFile=myPickle['SCTCalibConfig']
17  fileName='SCTCalibConfig.py'
18  dissectedPath=thisPath.split('/')
19  dissectedPath[-1]='share'
20  sharePath='/'.join(dissectedPath)
21  newFileName=sharePath+'/'+fileName
22  myPickle['SCTcalibConfig']=newFileName
23 
24 def writeNewPickle(newPickleName, data):
25  pickleFile=open(newPickleName,'w')
26  pickle.dump(data, pickleFile)
27 
28 def swapFiles(originalFile,newFile):
29  os.remove(originalFile)
30  os.rename(newFile,originalFile)
31 
32 
33 
34 def main():
35  existingPickleFilename='./newargdict.gpickle'
36  newPickleFileName='mynewpickle.gpickle'
37  data=getPickle(existingPickleFilename)
38  correctPath(data)
39  writeNewPickle(newPickleFileName,data)
40  swapFiles(existingPickleFilename,newPickleFileName)
41 
42 
43 if __name__=="__main__":
44  sys.exit(main())
CreateTrfArgs.main
def main()
Definition: CreateTrfArgs.py:34
CreateTrfArgs.swapFiles
def swapFiles(originalFile, newFile)
Definition: CreateTrfArgs.py:28
CreateTrfArgs.correctPath
def correctPath(myPickle)
Definition: CreateTrfArgs.py:13
CreateTrfArgs.fileExists
def fileExists(fp)
Definition: CreateTrfArgs.py:4
CreateTrfArgs.getPickle
def getPickle(fp)
Definition: CreateTrfArgs.py:8
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
Trk::open
@ open
Definition: BinningType.h:40
CreateTrfArgs.writeNewPickle
def writeNewPickle(newPickleName, data)
Definition: CreateTrfArgs.py:24