File: fix-plugin-names.py

package info (click to toggle)
yade 2025.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 33,308 kB
  • sloc: cpp: 93,298; python: 50,409; sh: 577; makefile: 162
file content (22 lines) | stat: -rw-r--r-- 616 bytes parent folder | download | duplicates (2)
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()