ATLAS Offline Software
Loading...
Searching...
No Matches
InnerDetector
InDetCalibAlgs
SCT_CalibAlgs
scripts
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
main()
Definition
CreateTrfArgs.py:34
CreateTrfArgs.writeNewPickle
writeNewPickle(newPickleName, data)
Definition
CreateTrfArgs.py:24
CreateTrfArgs.correctPath
correctPath(myPickle)
Definition
CreateTrfArgs.py:13
CreateTrfArgs.fileExists
fileExists(fp)
Definition
CreateTrfArgs.py:4
CreateTrfArgs.swapFiles
swapFiles(originalFile, newFile)
Definition
CreateTrfArgs.py:28
CreateTrfArgs.getPickle
getPickle(fp)
Definition
CreateTrfArgs.py:8
Generated on
for ATLAS Offline Software by
1.14.0