File: fix-plugin-names.py

package info (click to toggle)
yade 2019.01a-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 16,568 kB
  • sloc: cpp: 56,330; python: 30,148; ansic: 6,463; sh: 123; makefile: 56
file content (22 lines) | stat: -rw-r--r-- 568 bytes parent folder | download | duplicates (10)
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()