-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathcommon.py
More file actions
36 lines (25 loc) · 971 Bytes
/
common.py
File metadata and controls
36 lines (25 loc) · 971 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#! /usr/bin/env python3
def get_read_branch_names(xml_path):
"""
Open a framework job report XML file and return the list of branch names
that have bean read from the input files.
If the ReadBranches element looks like
<ReadBranches>
<Branch Name="FEDRawDataCollection_rawDataCollector__LHC." ReadCount="2926"/>
</ReadBranches>
this function would return [ 'FEDRawDataCollection_rawDataCollector__LHC' ].
"""
import xml.etree.ElementTree as ET
tree = ET.parse(xml_path)
root = tree.getroot()
read_branches = root.find("ReadBranches")
if read_branches is None:
return []
branch_names = []
for branch in read_branches.findall("Branch"):
name = branch.get("Name")
if name:
branch_names.append(name.rstrip(".")) # remove trailing dot(s)
return branch_names
if __name__ == "__main__":
print('\n'.join(get_read_branch_names('test/report.xml')))