Remove obsolete warning filters in regrtest.py (from issue #7092 -- patch by
[python.git] / Tools / scripts / fixps.py
blob2ff15f41efddb65417ae800f36532072511ca118
1 #!/usr/bin/env python
3 # Fix Python script(s) to reference the interpreter via /usr/bin/env python.
4 # Warning: this overwrites the file without making a backup.
6 import sys
7 import re
10 def main():
11 for filename in sys.argv[1:]:
12 try:
13 f = open(filename, 'r')
14 except IOError, msg:
15 print filename, ': can\'t open :', msg
16 continue
17 line = f.readline()
18 if not re.match('^#! */usr/local/bin/python', line):
19 print filename, ': not a /usr/local/bin/python script'
20 f.close()
21 continue
22 rest = f.read()
23 f.close()
24 line = re.sub('/usr/local/bin/python',
25 '/usr/bin/env python', line)
26 print filename, ':', repr(line)
27 f = open(filename, "w")
28 f.write(line)
29 f.write(rest)
30 f.close()
32 if __name__ == '__main__':
33 main()