104 Open json files and load all merged contents
105 in a dictionary, which is later converted to a
106 list of strings, each to be parsed in a
107 (flattened) json format
109 log = logging.getLogger(
"getPlotsDefList" )
112 log.debug(
"plotsDefFileList : %s", flags.PhysVal.IDTPM.plotsDefFileList )
113 listPath =
find_datafile( flags.PhysVal.IDTPM.plotsDefFileList )
115 log.error(
"plotsDefFileList not found" )
118 plotsDefFileNames = []
119 with open( listPath,
"r" )
as input_flist :
120 plotsDefFileNames = input_flist.read().splitlines()
125 for plotsDefFileName
in plotsDefFileNames :
127 log.debug(
"Reading input plots definitions : %s", dataPath )
129 log.error(
"plotsDefFile %s not found", plotsDefFileName )
132 with open( dataPath,
"r" )
as input_json_file :
133 plotsDefDict.update( json.load( input_json_file ) )
137 plotsDefStrList_v1 = []
138 for plotName, plotDict
in plotsDefDict.items():
139 newPlotDict = plotDict.copy()
140 newPlotDict[
"name" ] = plotName
146 plotDefStr =
str( json.dumps( plotDictFlat ) )
149 plotsDefStrList_v1.append( plotDefStr )
153 commonValuesDict = {}
154 commonValuesPath =
find_datafile( flags.PhysVal.IDTPM.plotsCommonValuesFile )
155 if commonValuesPath
is None :
156 log.error(
"plotsCommonValuesFile not found" )
159 with open( commonValuesPath,
"r" )
as input_commonValues :
160 commonValuesDict.update( json.load( input_commonValues ) )
162 plotsDefStrList_v2 = []
163 for plotDefStr
in plotsDefStrList_v1 :
164 newPlotDefStr = plotDefStr
165 if commonValuesDict :
166 for key, value
in commonValuesDict.items() :
167 plotDefStr_tmp = newPlotDefStr.replace(
"$"+key, value[0] )
168 newPlotDefStr = plotDefStr_tmp
169 plotsDefStrList_v2.append( newPlotDefStr )
173 getLabel( flags, flags.PhysVal.IDTPM.currentTrkAna.TestType ),
174 getLabel( flags, flags.PhysVal.IDTPM.currentTrkAna.RefType )
178 for plotsDefStr
in plotsDefStrList_v2 :
179 if (
"$TRKTAG" not in plotsDefStr )
and (
"$TRKTYPE" not in plotsDefStr ) :
180 plotsDefStrList.append( plotsDefStr )
182 for trkLabel
in trkLabels :
183 newPlotsDefStr = plotsDefStr.replace(
"$TRKTYPE", trkLabel[0] ).
replace(
"$TRKTAG", trkLabel[1] )
184 plotsDefStrList.append( newPlotsDefStr )
186 return plotsDefStrList