Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7ac4ea9

Browse files
committed
Python: CG trace: use standardized etree import
makes it easy to switch out XML library.
1 parent ba4207f commit 7ac4ea9

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

python/tools/recorded-call-graph-metrics/cg_trace.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import dis
3030
import dataclasses
3131
import csv
32-
import xml.etree.ElementTree as ET
32+
import xml.etree.ElementTree as etree
3333

3434
# Copy-Paste and uncomment for interactive ipython sessions
3535
# import IPython; IPython.embed(); sys.exit()
@@ -168,19 +168,19 @@ class XMLExporter(Exporter):
168168
@staticmethod
169169
def export(recorded_calls, outfile_path):
170170

171-
root = ET.Element('root')
171+
root = etree.Element('root')
172172

173173
for (call, callee) in sorted(recorded_calls):
174174
data = {
175175
**Exporter.dataclass_to_dict(call),
176176
**Exporter.dataclass_to_dict(callee)
177177
}
178178

179-
rc = ET.SubElement(root, 'recorded_call')
179+
rc = etree.SubElement(root, 'recorded_call')
180180
# this xml library only supports serializing attributes that have string values
181181
rc.attrib = {k: str(v) for k, v in data.items()}
182182

183-
tree = ET.ElementTree(root)
183+
tree = etree.ElementTree(root)
184184
tree.write(outfile_path, encoding='utf-8')
185185

186186

0 commit comments

Comments
 (0)