Files
sci-gui-agent-benchmark/at_processing/ubuntu_node_statistics.py
David Chang e95e8e55ea ver Mar11th
updated filter_nodes
2024-03-11 12:33:47 +08:00

23 lines
636 B
Python

#!/usr/bin/python3
import lxml.etree
from lxml.etree import _Element
from typing import Counter
import json
import collections
file_name = "3"
with open("{:}.json".format(file_name)) as f:
xml_str: str = json.load(f)["AT"]
root: _Element = lxml.etree.fromstring(xml_str)
with open("{:}.xml".format(file_name), "w") as f:
f.write(lxml.etree.tostring(root, encoding="unicode", pretty_print=True))
#root: _Element = lxml.etree.parse("{:}.xml".format(file_name)).getroot()
node_types: Counter[str] = collections.Counter()
for n in root.iter():
node_types[n.tag] += 1
for n in sorted(node_types):
print(n, node_types[n])