Mercurial > cpython-lru_cache-weakref
annotate Tools/scripts/fixps.py @ 3044:7e7bb00a0a2e legacy-trunk
Added functionality: locate CW projects, copy them, empty them and
binhex them.
| author | Jack Jansen <jack.jansen@cwi.nl> |
|---|---|
| date | Thu, 31 Aug 1995 13:47:14 +0000 |
| parents | 8ea546047f01 |
| children | e708f568b8b7 |
| rev | line source |
|---|---|
| 1104 | 1 #! /usr/local/bin/python |
| 2 | |
| 3 # Fix Python script(s) to reference the interpreter in /usr/local/bin. | |
| 4 | |
| 5 import sys | |
| 6 import regex | |
| 7 import regsub | |
| 8 | |
| 9 | |
| 10 def main(): | |
| 11 for file in sys.argv[1:]: | |
| 12 try: | |
| 13 f = open(file, 'r+') | |
| 14 except IOError: | |
|
1106
8ea546047f01
Fix bug when reporting error
Guido van Rossum <guido@python.org>
parents:
1104
diff
changeset
|
15 print file, ': can\'t open for update' |
| 1104 | 16 continue |
| 17 line = f.readline() | |
| 18 if regex.match('^#! */usr/local/python', line) < 0: | |
| 19 print file, ': not a /usr/local/python script' | |
| 20 f.close() | |
| 21 continue | |
| 22 rest = f.read() | |
| 23 line = regsub.sub('/usr/local/python', \ | |
| 24 '/usr/local/bin/python', line) | |
| 25 print file, ':', `line` | |
| 26 f.seek(0) | |
| 27 f.write(line) | |
| 28 f.write(rest) | |
| 29 f.close() | |
| 30 | |
| 31 | |
| 32 main() |
