5 transforms a Run-2 style configuration xml file into a json file
9 if xmlFile.endswith(
".json"):
14 from AthenaCommon.Logging
import logging
15 msg = logging.getLogger(
'XML2Json' )
17 msg.info(
"Attempting to convert %s", xmlFile)
21 for p
in ([
'./'] + os.environ[
"XMLPATH"].
split(
':')):
22 if os.path.exists(
"%s/%s" % (p, xmlFile) ):
23 fullXmlFile =
"%s/%s" % (p, xmlFile)
25 if os.path.exists(
"%s/TriggerMenuXML/%s" % (p, xmlFile) ):
26 fullXmlFile =
"%s/TriggerMenuXML/%s" % (p, xmlFile)
28 if os.path.exists(
"%s/TriggerMenuMT/%s" % (p, xmlFile) ):
29 fullXmlFile =
"%s/TriggerMenuMT/%s" % (p, xmlFile)
33 msg.error(
"Did not find file %s", xmlFile)
36 localJsonFile =
"./" + xmlFile.rsplit(
"/",1)[-1].
replace(
".xml",
".json")
37 msg.info(
"Converting %s to %s", fullXmlFile, localJsonFile)
39 from TrigConfIO.MenuXML2JSONConverter
import XML2JsonConverter
40 converter = XML2JsonConverter()
41 converter.convertFile( fullXmlFile, localJsonFile )