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
|
#!/usr/bin/python3
import glob
import os
from xml.dom.minidom import parseString
from codecs import open
outfile = 'bugpatterns.xml'
out = open(outfile, encoding='utf-8', mode='wb')
out.write('''<?xml version="1.0"?>
<patterns>
''')
for path in sorted(glob.glob('*.xml')):
if path == outfile: continue
pkg = os.path.splitext(path)[0]
dom = parseString(open(path).read())
out.write('\n<!-- Converted from %s -->\n\n' % path)
for pattern in dom.getElementsByTagName('pattern'):
xml = pattern.toxml()
out.write(' ')
out.write(xml)
out.write('\n')
out.write('</patterns>\n')
|