annotate Tools/scripts/pathfix.py @ 58689:514b56efd89a 3.1

Merged revisions 77962 via svnmerge from svn+ssh://pythondev@svn.python.org/python/branches/py3k ................ r77962 | r.david.murray | 2010-02-04 11:41:57 -0500 (Thu, 04 Feb 2010) | 17 lines Merged revisions 77943,77959-77960 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r77943 | r.david.murray | 2010-02-03 08:36:23 -0500 (Wed, 03 Feb 2010) | 2 lines Explicitly mention the default value for formatdate's usegmt parameter. ........ r77959 | nick.coghlan | 2010-02-04 07:43:58 -0500 (Thu, 04 Feb 2010) | 1 line Issue 6760: Clarify args handling for subprocess.Popen. Patch by Chris Rebert ........ r77960 | r.david.murray | 2010-02-04 11:33:31 -0500 (Thu, 04 Feb 2010) | 2 lines Add Chris Rebert to ACKS for issue 6760 Popen doc improvements. ........ ................
author R. David Murray <rdmurray@bitdance.com>
date Thu, 04 Feb 2010 16:44:31 +0000
parents 2644f54e3676
children e3e6aa633f33
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
56221
2644f54e3676 Merged revisions 75061-75062 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 42084
diff changeset
1 #!/usr/bin/env python3
1799
60660341ee10 newslist.py: Added search for .newslistrc.py;
Guido van Rossum <guido@python.org>
parents:
diff changeset
2
60660341ee10 newslist.py: Added search for .newslistrc.py;
Guido van Rossum <guido@python.org>
parents:
diff changeset
3 # Change the #! line occurring in Python scripts. The new interpreter
60660341ee10 newslist.py: Added search for .newslistrc.py;
Guido van Rossum <guido@python.org>
parents:
diff changeset
4 # pathname must be given with a -i option.
60660341ee10 newslist.py: Added search for .newslistrc.py;
Guido van Rossum <guido@python.org>
parents:
diff changeset
5 #
60660341ee10 newslist.py: Added search for .newslistrc.py;
Guido van Rossum <guido@python.org>
parents:
diff changeset
6 # Command line arguments are files or directories to be processed.
60660341ee10 newslist.py: Added search for .newslistrc.py;
Guido van Rossum <guido@python.org>
parents:
diff changeset
7 # Directories are searched recursively for files whose name looks
60660341ee10 newslist.py: Added search for .newslistrc.py;
Guido van Rossum <guido@python.org>
parents:
diff changeset
8 # like a python module.
60660341ee10 newslist.py: Added search for .newslistrc.py;
Guido van Rossum <guido@python.org>
parents:
diff changeset
9 # Symbolic links are always ignored (except as explicit directory
60660341ee10 newslist.py: Added search for .newslistrc.py;
Guido van Rossum <guido@python.org>
parents:
diff changeset
10 # arguments). Of course, the original file is kept as a back-up
60660341ee10 newslist.py: Added search for .newslistrc.py;
Guido van Rossum <guido@python.org>
parents:
diff changeset
11 # (with a "~" attached to its name).
60660341ee10 newslist.py: Added search for .newslistrc.py;
Guido van Rossum <guido@python.org>
parents:
diff changeset
12 #
60660341ee10 newslist.py: Added search for .newslistrc.py;
Guido van Rossum <guido@python.org>
parents:
diff changeset
13 # Undoubtedly you can do this using find and sed or perl, but this is
60660341ee10 newslist.py: Added search for .newslistrc.py;
Guido van Rossum <guido@python.org>
parents:
diff changeset
14 # a nice example of Python code that recurses down a directory tree
60660341ee10 newslist.py: Added search for .newslistrc.py;
Guido van Rossum <guido@python.org>
parents:
diff changeset
15 # and uses regular expressions. Also note several subtleties like
60660341ee10 newslist.py: Added search for .newslistrc.py;
Guido van Rossum <guido@python.org>
parents:
diff changeset
16 # preserving the file's mode and avoiding to even write a temp file
60660341ee10 newslist.py: Added search for .newslistrc.py;
Guido van Rossum <guido@python.org>
parents:
diff changeset
17 # when no changes are needed for a file.
60660341ee10 newslist.py: Added search for .newslistrc.py;
Guido van Rossum <guido@python.org>
parents:
diff changeset
18 #
60660341ee10 newslist.py: Added search for .newslistrc.py;
Guido van Rossum <guido@python.org>
parents:
diff changeset
19 # NB: by changing only the function fixfile() you can turn this
60660341ee10 newslist.py: Added search for .newslistrc.py;
Guido van Rossum <guido@python.org>
parents:
diff changeset
20 # into a program for a different change to Python programs...
60660341ee10 newslist.py: Added search for .newslistrc.py;
Guido van Rossum <guido@python.org>
parents:
diff changeset
21
60660341ee10 newslist.py: Added search for .newslistrc.py;
Guido van Rossum <guido@python.org>
parents:
diff changeset
22 import sys
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 33076
diff changeset
23 import re
1799
60660341ee10 newslist.py: Added search for .newslistrc.py;
Guido van Rossum <guido@python.org>
parents:
diff changeset
24 import os
60660341ee10 newslist.py: Added search for .newslistrc.py;
Guido van Rossum <guido@python.org>
parents:
diff changeset
25 from stat import *
60660341ee10 newslist.py: Added search for .newslistrc.py;
Guido van Rossum <guido@python.org>
parents:
diff changeset
26 import getopt
60660341ee10 newslist.py: Added search for .newslistrc.py;
Guido van Rossum <guido@python.org>
parents:
diff changeset
27
60660341ee10 newslist.py: Added search for .newslistrc.py;
Guido van Rossum <guido@python.org>
parents:
diff changeset
28 err = sys.stderr.write
60660341ee10 newslist.py: Added search for .newslistrc.py;
Guido van Rossum <guido@python.org>
parents:
diff changeset
29 dbg = err
60660341ee10 newslist.py: Added search for .newslistrc.py;
Guido van Rossum <guido@python.org>
parents:
diff changeset
30 rep = sys.stdout.write
60660341ee10 newslist.py: Added search for .newslistrc.py;
Guido van Rossum <guido@python.org>
parents:
diff changeset
31
60660341ee10 newslist.py: Added search for .newslistrc.py;
Guido van Rossum <guido@python.org>
parents:
diff changeset
32 new_interpreter = None
60660341ee10 newslist.py: Added search for .newslistrc.py;
Guido van Rossum <guido@python.org>
parents:
diff changeset
33
60660341ee10 newslist.py: Added search for .newslistrc.py;
Guido van Rossum <guido@python.org>
parents:
diff changeset
34 def main():
15930
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
35 global new_interpreter
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
36 usage = ('usage: %s -i /interpreter file-or-directory ...\n' %
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
37 sys.argv[0])
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
38 try:
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
39 opts, args = getopt.getopt(sys.argv[1:], 'i:')
40587
6b18a095c2e7 SF patch 1631942 by Collin Winter:
Guido van Rossum <guido@python.org>
parents: 37879
diff changeset
40 except getopt.error as msg:
15930
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
41 err(msg + '\n')
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
42 err(usage)
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
43 sys.exit(2)
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
44 for o, a in opts:
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
45 if o == '-i':
56221
2644f54e3676 Merged revisions 75061-75062 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 42084
diff changeset
46 new_interpreter = a.encode()
2644f54e3676 Merged revisions 75061-75062 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 42084
diff changeset
47 if not new_interpreter or not new_interpreter.startswith(b'/') or \
2644f54e3676 Merged revisions 75061-75062 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 42084
diff changeset
48 not args:
15930
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
49 err('-i option or file-or-directory missing\n')
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
50 err(usage)
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
51 sys.exit(2)
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
52 bad = 0
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
53 for arg in args:
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
54 if os.path.isdir(arg):
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
55 if recursedown(arg): bad = 1
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
56 elif os.path.islink(arg):
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
57 err(arg + ': will not process symbolic links\n')
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
58 bad = 1
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
59 else:
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
60 if fix(arg): bad = 1
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
61 sys.exit(bad)
1799
60660341ee10 newslist.py: Added search for .newslistrc.py;
Guido van Rossum <guido@python.org>
parents:
diff changeset
62
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 33076
diff changeset
63 ispythonprog = re.compile('^[a-zA-Z0-9_]+\.py$')
1799
60660341ee10 newslist.py: Added search for .newslistrc.py;
Guido van Rossum <guido@python.org>
parents:
diff changeset
64 def ispython(name):
56221
2644f54e3676 Merged revisions 75061-75062 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 42084
diff changeset
65 return bool(ispythonprog.match(name))
1799
60660341ee10 newslist.py: Added search for .newslistrc.py;
Guido van Rossum <guido@python.org>
parents:
diff changeset
66
60660341ee10 newslist.py: Added search for .newslistrc.py;
Guido van Rossum <guido@python.org>
parents:
diff changeset
67 def recursedown(dirname):
31515
71a294bd7950 Replace backticks with repr() or "%r"
Walter Dörwald <walter@livinglogic.de>
parents: 25219
diff changeset
68 dbg('recursedown(%r)\n' % (dirname,))
15930
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
69 bad = 0
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
70 try:
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
71 names = os.listdir(dirname)
40587
6b18a095c2e7 SF patch 1631942 by Collin Winter:
Guido van Rossum <guido@python.org>
parents: 37879
diff changeset
72 except os.error as msg:
31515
71a294bd7950 Replace backticks with repr() or "%r"
Walter Dörwald <walter@livinglogic.de>
parents: 25219
diff changeset
73 err('%s: cannot list directory: %r\n' % (dirname, msg))
15930
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
74 return 1
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
75 names.sort()
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
76 subdirs = []
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
77 for name in names:
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
78 if name in (os.curdir, os.pardir): continue
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
79 fullname = os.path.join(dirname, name)
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
80 if os.path.islink(fullname): pass
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
81 elif os.path.isdir(fullname):
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
82 subdirs.append(fullname)
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
83 elif ispython(name):
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
84 if fix(fullname): bad = 1
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
85 for fullname in subdirs:
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
86 if recursedown(fullname): bad = 1
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
87 return bad
1799
60660341ee10 newslist.py: Added search for .newslistrc.py;
Guido van Rossum <guido@python.org>
parents:
diff changeset
88
60660341ee10 newslist.py: Added search for .newslistrc.py;
Guido van Rossum <guido@python.org>
parents:
diff changeset
89 def fix(filename):
31515
71a294bd7950 Replace backticks with repr() or "%r"
Walter Dörwald <walter@livinglogic.de>
parents: 25219
diff changeset
90 ## dbg('fix(%r)\n' % (filename,))
15930
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
91 try:
56221
2644f54e3676 Merged revisions 75061-75062 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 42084
diff changeset
92 f = open(filename, 'rb')
40587
6b18a095c2e7 SF patch 1631942 by Collin Winter:
Guido van Rossum <guido@python.org>
parents: 37879
diff changeset
93 except IOError as msg:
31515
71a294bd7950 Replace backticks with repr() or "%r"
Walter Dörwald <walter@livinglogic.de>
parents: 25219
diff changeset
94 err('%s: cannot open: %r\n' % (filename, msg))
15930
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
95 return 1
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
96 line = f.readline()
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
97 fixed = fixline(line)
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
98 if line == fixed:
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
99 rep(filename+': no change\n')
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
100 f.close()
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
101 return
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
102 head, tail = os.path.split(filename)
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
103 tempname = os.path.join(head, '@' + tail)
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
104 try:
56221
2644f54e3676 Merged revisions 75061-75062 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 42084
diff changeset
105 g = open(tempname, 'wb')
40587
6b18a095c2e7 SF patch 1631942 by Collin Winter:
Guido van Rossum <guido@python.org>
parents: 37879
diff changeset
106 except IOError as msg:
15930
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
107 f.close()
31515
71a294bd7950 Replace backticks with repr() or "%r"
Walter Dörwald <walter@livinglogic.de>
parents: 25219
diff changeset
108 err('%s: cannot create: %r\n' % (tempname, msg))
15930
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
109 return 1
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
110 rep(filename + ': updating\n')
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
111 g.write(fixed)
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
112 BUFSIZE = 8*1024
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
113 while 1:
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
114 buf = f.read(BUFSIZE)
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
115 if not buf: break
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
116 g.write(buf)
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
117 g.close()
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
118 f.close()
1799
60660341ee10 newslist.py: Added search for .newslistrc.py;
Guido van Rossum <guido@python.org>
parents:
diff changeset
119
15930
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
120 # Finishing touch -- move files
1799
60660341ee10 newslist.py: Added search for .newslistrc.py;
Guido van Rossum <guido@python.org>
parents:
diff changeset
121
15930
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
122 # First copy the file's mode to the temp file
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
123 try:
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
124 statbuf = os.stat(filename)
42084
229c28cb9afb Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 40587
diff changeset
125 os.chmod(tempname, statbuf[ST_MODE] & 0o7777)
40587
6b18a095c2e7 SF patch 1631942 by Collin Winter:
Guido van Rossum <guido@python.org>
parents: 37879
diff changeset
126 except os.error as msg:
31515
71a294bd7950 Replace backticks with repr() or "%r"
Walter Dörwald <walter@livinglogic.de>
parents: 25219
diff changeset
127 err('%s: warning: chmod failed (%r)\n' % (tempname, msg))
15930
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
128 # Then make a backup of the original file as filename~
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
129 try:
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
130 os.rename(filename, filename + '~')
40587
6b18a095c2e7 SF patch 1631942 by Collin Winter:
Guido van Rossum <guido@python.org>
parents: 37879
diff changeset
131 except os.error as msg:
31515
71a294bd7950 Replace backticks with repr() or "%r"
Walter Dörwald <walter@livinglogic.de>
parents: 25219
diff changeset
132 err('%s: warning: backup failed (%r)\n' % (filename, msg))
15930
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
133 # Now move the temp file to the original file
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
134 try:
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
135 os.rename(tempname, filename)
40587
6b18a095c2e7 SF patch 1631942 by Collin Winter:
Guido van Rossum <guido@python.org>
parents: 37879
diff changeset
136 except os.error as msg:
31515
71a294bd7950 Replace backticks with repr() or "%r"
Walter Dörwald <walter@livinglogic.de>
parents: 25219
diff changeset
137 err('%s: rename failed (%r)\n' % (filename, msg))
15930
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
138 return 1
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
139 # Return succes
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
140 return 0
1799
60660341ee10 newslist.py: Added search for .newslistrc.py;
Guido van Rossum <guido@python.org>
parents:
diff changeset
141
60660341ee10 newslist.py: Added search for .newslistrc.py;
Guido van Rossum <guido@python.org>
parents:
diff changeset
142 def fixline(line):
56221
2644f54e3676 Merged revisions 75061-75062 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 42084
diff changeset
143 if not line.startswith(b'#!'):
15930
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
144 return line
56221
2644f54e3676 Merged revisions 75061-75062 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 42084
diff changeset
145 if b"python" not in line:
15930
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4568
diff changeset
146 return line
56221
2644f54e3676 Merged revisions 75061-75062 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 42084
diff changeset
147 return b'#! ' + new_interpreter + b'\n'
1799
60660341ee10 newslist.py: Added search for .newslistrc.py;
Guido van Rossum <guido@python.org>
parents:
diff changeset
148
33074
981fff7363b9 [Patch #1005491 ] use __name__ == '__main__' in scripts
Andrew M. Kuchling <amk@amk.ca>
parents: 31515
diff changeset
149 if __name__ == '__main__':
981fff7363b9 [Patch #1005491 ] use __name__ == '__main__' in scripts
Andrew M. Kuchling <amk@amk.ca>
parents: 31515
diff changeset
150 main()