FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cpython/Tools/scripts/fixps.py at v3.6.15 · python/cpython · GitHub
python
cpython
Repository navigation
Code
Issues
5k+
(5k+)
Pull requests
2.6k
(2.6k)
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
cpython
/
Tools
/
scripts
/
fixps.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
33 lines (28 loc) · 899 Bytes
Breadcrumbs
cpython
/
Tools
/
scripts
/
fixps.py
Copy path
File metadata and controls
executable file
·
33 lines (28 loc) · 899 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env python3
# Fix Python script(s) to reference the interpreter via /usr/bin/env python.
# Warning: this overwrites the file without making a backup.
import
sys
import
re
def
main
():
for
filename
in
sys
.
argv
[
1
:]:
try
:
f
=
open
(
filename
,
'r'
)
except
IOError
as
msg
:
print
(
filename
,
': can
\'
t open :'
,
msg
)
continue
line
=
f
.
readline
()
if
not
re
.
match
(
'^#! */usr/local/bin/python'
,
line
):
print
(
filename
,
': not a /usr/local/bin/python script'
)
f
.
close
()
continue
rest
=
f
.
read
()
f
.
close
()
line
=
re
.
sub
(
'/usr/local/bin/python'
,
'/usr/bin/env python'
,
line
)
print
(
filename
,
':'
,
repr
(
line
))
f
=
open
(
filename
,
"w"
)
f
.
write
(
line
)
f
.
write
(
rest
)
f
.
close
()
if
__name__
==
'__main__'
:
main
()
Back
|
FazBrowse Home
|
New Git URL