summaryrefslogtreecommitdiff
path: root/rawprogram-sanitizer.py
diff options
context:
space:
mode:
Diffstat (limited to 'rawprogram-sanitizer.py')
-rw-r--r--rawprogram-sanitizer.py39
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()