]> git.donarmstrong.com Git - lilypond.git/blob - buildscripts/analyse-cxx-log.py
(mail_address_url): don't add
[lilypond.git] / buildscripts / analyse-cxx-log.py
1 #!/usr/bin/python
2 import sys
3 import os
4 import re
5 import string
6
7 if len (sys.argv) < 5:
8         print 'args: LOGFILE CLASS FUNC NEW_FUNC'
9         
10 func = sys.argv[3]
11 new_func = sys.argv[4]
12 klazz = sys.argv[2]
13 log_ls = open (sys.argv[1]).readlines ()
14 regex = re.compile ("([^:]+):([0-9]+): error: .class ([_a-zA-Z]+). has no member named .%s." % func)
15
16 files = {}
17
18 for l in log_ls:
19         m =  regex.search (l)
20         if not m:
21                 continue
22         print l
23
24         file = m.group (1)
25         line_no = string.atoi (m.group (2))
26         klass = m.group (3)
27         
28         if klass <> klazz:
29                 continue
30
31         if not files.has_key (file):
32                 files[file] = open (file).read ().split ('\n')
33
34         line_no -= 1 
35         files[file][line_no] = re.sub (func, new_func, files[file][line_no])
36
37
38 for (f,ls) in files.items():
39         print 'writing ', f 
40         os.rename (f, f + '~')
41         open (f, 'w').write ('\n'.join (ls))
42