blob: 682a338f0961d778a2be11e4eef27eda67072905 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
inputFile = "c:/eclipse/workspace/org.eclipse.jdt.core/aspectj/org/aspectj/workbench/resources/FileAdapter.java"
text = open(inputFile, 'r').read()
#print text
import re, string
methodPat = re.compile(r"public [^{]*\([^{]*{[^}]*}") #^[{]\)^[{]{", re.DOTALL) #{ .* }", re.DOTALL)
throwException = """throw new RuntimeException("unimplemented");"""
for method in methodPat.findall(text):
print method
newMethod = method[:len(method)-1]
startBody = newMethod.find("{")
newMethod = newMethod[:startBody+1]
newMethod = newMethod + "\n\t" + throwException + "\n\t}"
text = text.replace(method, newMethod)
print text
open(inputFile, 'w').write(text)
|