ATLAS Offline Software
Loading...
Searching...
No Matches
python.TransformXML2JSON Namespace Reference

Functions

 transformXML2Json (xmlFile)

Function Documentation

◆ transformXML2Json()

python.TransformXML2JSON.transformXML2Json ( xmlFile)
transforms a Run-2 style configuration xml file into a json file

Definition at line 3 of file TransformXML2JSON.py.

3def transformXML2Json(xmlFile):
4 '''
5 transforms a Run-2 style configuration xml file into a json file
6 '''
7
8 # protection in case we start to provide json
9 if xmlFile.endswith(".json"):
10 return xmlFile
11
12 import os
13
14 from AthenaCommon.Logging import logging
15 msg = logging.getLogger( 'XML2Json' )
16
17 msg.info("Attempting to convert %s", xmlFile)
18
19 # since there is no path resolver yet
20 fullXmlFile = None
21 for p in (['./'] + os.environ["XMLPATH"].split(':')):
22 if os.path.exists( "%s/%s" % (p, xmlFile) ):
23 fullXmlFile = "%s/%s" % (p, xmlFile)
24 break
25 if os.path.exists( "%s/TriggerMenuXML/%s" % (p, xmlFile) ):
26 fullXmlFile = "%s/TriggerMenuXML/%s" % (p, xmlFile)
27 break
28 if os.path.exists( "%s/TriggerMenuMT/%s" % (p, xmlFile) ):
29 fullXmlFile = "%s/TriggerMenuMT/%s" % (p, xmlFile)
30 break
31
32 if not fullXmlFile:
33 msg.error("Did not find file %s", xmlFile)
34 return ""
35
36 localJsonFile = "./" + xmlFile.rsplit("/",1)[-1].replace(".xml",".json")
37 msg.info("Converting %s to %s", fullXmlFile, localJsonFile)
38
39 from TrigConfIO.MenuXML2JSONConverter import XML2JsonConverter
40 converter = XML2JsonConverter()
41 converter.convertFile( fullXmlFile, localJsonFile )
42
43 return localJsonFile
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition hcg.cxx:310
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition hcg.cxx:177