1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
import os, re
for root, dirs, files in os.walk('.'):
for name in files:
if not name.endswith('.cpp'):
continue
#if name!='BssSnowGrain.cpp': continue
modified = False
new = []
for l in open(root + '/' + name):
m = re.match('(.*)YADE_PLUGIN\(([^)]*)\)(.*)', l)
if m:
modified = True
plugins = ''.join(['(' + pl.strip()[1:-1] + ')' for pl in m.group(2).split(',')])
new.append(m.group(1) + 'YADE_PLUGIN(' + plugins + ')' + m.group(3))
else:
new.append(l)
if modified:
print(root + '/' + name)
f = open(root + '/' + name, 'w')
for l in new:
f.write(l)
f.close()
|