47 Merge the files in the input list to the output file.
48 @param inlist: list of filenames of input files
49 @param out: output filename
52 from PyUtils.Helpers
import release_metadata
54 rematch = re.compile(
r'(\S*)\s+(\S*)\s+{')
56 kwlist =
set([
'algorithm',
'compositeAlgorithm',
'reference',
'thresholds'])
65 f = os.path.join(dir, template)
66 if not os.access(f, os.R_OK):
68 if not _is_ok(dir, options):
69 print (dir,
'excluded from merge')
71 print (
'Processing', f)
75 reclevel = 0; reclist = []; kws = []
78 stripline = line.strip()
79 if len(stripline) == 0:
81 if stripline[0] ==
'#':
83 if stripline[0] ==
'}' and reclevel > 0:
85 reclevel -= 1; reclist.pop(); kws.pop()
87 match = rematch.search(line)
90 kws.append(match.group(1)); reclevel += 1; reclist.append(match.group(2))
94 fullname =
'/'.
join(reclist)
96 if fullname
in kwhash[match.group(1)]:
98 print (
'ERROR: repeated definition of %s %s' % (match.group(1), fullname))
99 print (
' Current file is %s' % f)
100 print (
' Earlier definition was in %s' % kwhash[match.group(1)][fullname])
101 print (
' Please fix this. Merging will now stop. Output file has not been created.')
104 kwhash[match.group(1)][fullname] = f
108 outobj =
open(out,
'w')
109 outobj.write(
'# ****************************\n')
110 outobj.write(
'metadata GitInfo {\n')
111 outobj.write(
' Hash = %s\n' % (
release_metadata()[
'nightly release']
or "unknown"))
113 outobj.write(
'# ****************************\n\n')
118 line +=
'# ' + f +
'\n'
119 line = line.replace(
'$',
'')