diff options
author | Nicolas Dechesne <nicolas.dechesne@linaro.org> | 2017-11-29 23:19:28 +0100 |
---|---|---|
committer | Nicolas Dechesne <nicolas.dechesne@linaro.org> | 2017-12-01 09:30:04 +0100 |
commit | 7317a799c7588a2c98ccced42232e1908659ee9b (patch) | |
tree | a588db4392cee3d07097d50f767e6f7b413d1f29 | |
parent | 99f455a92e9bb38a660b74662ef4f9c0614d8032 (diff) |
rawprogram-sanitizer: add new tool
Small utility to beautify internal rawprogram/patch xml files.
Signed-off-by: Nicolas Dechesne <nicolas.dechesne@linaro.org>
-rw-r--r-- | rawprogram-sanitizer.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/rawprogram-sanitizer.py b/rawprogram-sanitizer.py new file mode 100644 index 0000000..d9ad473 --- /dev/null +++ b/rawprogram-sanitizer.py @@ -0,0 +1,39 @@ +#!/usr/bin/python + +import struct, os, sys +import re +from types import * +import pprint +import operator +from xml.etree import ElementTree as ET +from collections import defaultdict + +def usage(): + print("Usage: Combine rawprogram*.xml and patch*.xml into a single sanitized XML command file\n") + +def main(): + + db = defaultdict(list) + patches = ET.Element("patches") + programs = ET.Element("data") + + for arg in sys.argv[1:]: + print("Processing file: " + arg) + root = ET.parse(arg).getroot() + + for element in root: + if element.tag == 'patch': + patches.append(element) + elif element.tag == 'program': + if element.attrib['filename']: + programs.append(element) + else: + print("Unknown element: " + element.tag) + + tree = ET.ElementTree(patches) + tree.write("patch.xml") + tree = ET.ElementTree(programs) + tree.write("rawprogram.xml") + +if __name__ == "__main__": + main() |