ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigConfiguration
TrigConfIO
python
TransformXML2JSON.py
Go to the documentation of this file.
1
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
2
3
def
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
replace
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition
hcg.cxx:312
split
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition
hcg.cxx:179
python.TransformXML2JSON.transformXML2Json
transformXML2Json(xmlFile)
Definition
TransformXML2JSON.py:3
Generated on
for ATLAS Offline Software by
1.17.0