Mercurial > cpython-lru_cache-weakref
annotate Tools/scripts/fixps.py @ 6719:faebc1940432 legacy-trunk
Understand -Xlinker option.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Tue, 02 Dec 1997 20:38:11 +0000 |
| parents | e708f568b8b7 |
| children | 8d2a8a49d983 |
| rev | line source |
|---|---|
|
4569
e708f568b8b7
Changed so that it replaces /usr/local/bin/python with /usr/bin/env python.
Guido van Rossum <guido@python.org>
parents:
1106
diff
changeset
|
1 #! /usr/bin/env python |
| 1104 | 2 |
|
4569
e708f568b8b7
Changed so that it replaces /usr/local/bin/python with /usr/bin/env python.
Guido van Rossum <guido@python.org>
parents:
1106
diff
changeset
|
3 # Fix Python script(s) to reference the interpreter via /usr/bin/env python. |
| 1104 | 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() | |
|
4569
e708f568b8b7
Changed so that it replaces /usr/local/bin/python with /usr/bin/env python.
Guido van Rossum <guido@python.org>
parents:
1106
diff
changeset
|
18 if regex.match('^#! */usr/local/bin/python', line) < 0: |
|
e708f568b8b7
Changed so that it replaces /usr/local/bin/python with /usr/bin/env python.
Guido van Rossum <guido@python.org>
parents:
1106
diff
changeset
|
19 print file, ': not a /usr/local/bin/python script' |
| 1104 | 20 f.close() |
| 21 continue | |
| 22 rest = f.read() | |
|
4569
e708f568b8b7
Changed so that it replaces /usr/local/bin/python with /usr/bin/env python.
Guido van Rossum <guido@python.org>
parents:
1106
diff
changeset
|
23 line = regsub.sub('/usr/local/bin/python', |
|
e708f568b8b7
Changed so that it replaces /usr/local/bin/python with /usr/bin/env python.
Guido van Rossum <guido@python.org>
parents:
1106
diff
changeset
|
24 '/usr/bin/env python', line) |
| 1104 | 25 print file, ':', `line` |
| 26 f.seek(0) | |
| 27 f.write(line) | |
| 28 f.write(rest) | |
| 29 f.close() | |
| 30 | |
| 31 | |
| 32 main() |
