1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- import os
- import sys
- import re
- import io
- import xml.etree.ElementTree as ET
- assert len(sys.argv) == 3, "usage:\ntxtmerge.py <input_dir> <output_file_name>"
- idir = str(sys.argv[1])
- oname = str(sys.argv[2])
- tree = ET.parse('isample.qproj')
- root = tree.getroot()
- ofile = io.open(oname, 'w', encoding='utf-16', newline='\r\n')
- for location in root.iter('Location'):
- iname = location.attrib['name']
- iname = iname.replace("$","_")
- try:
- ifile = io.open(os.path.join(idir,iname + '.qsrc'), 'rt', encoding='utf-8')
- text = ifile.read()
-
-
- if text[-1] != u'\n':
- text += u'\n\n'
- ofile.write(text)
- ifile.close()
- except IOError:
- print("WARNING: missing location %s" % iname)
- pass
- ofile.close()
-
-
|