Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
57684190
Commit
57684190
authored
Sep 14, 1998
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Utility to untabify stubber results.
parent
ba9ddfb8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
0 deletions
+50
-0
Tools/scripts/untabify.py
Tools/scripts/untabify.py
+50
-0
No files found.
Tools/scripts/untabify.py
0 → 100755
View file @
57684190
#! /usr/bin/env python
"Replace tabs with spaces in argument files. Print names of changed files."
import
os
import
sys
import
string
import
getopt
def
main
():
tabsize
=
8
try
:
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
"t:"
)
if
not
args
:
raise
getopt
.
error
,
"At least one file argument required"
except
getopt
.
error
,
msg
:
print
msg
print
"usage:"
,
sys
.
argv
[
0
],
"file ..."
return
for
file
in
args
:
process
(
file
,
tabsize
)
def
process
(
file
,
tabsize
):
try
:
f
=
open
(
file
)
text
=
f
.
read
()
f
.
close
()
except
IOError
,
msg
:
print
"%s: I/O error: %s"
%
(
`file`
,
str
(
msg
))
return
newtext
=
string
.
expandtabs
(
text
,
tabsize
)
if
newtext
==
text
:
return
backup
=
file
+
"~"
try
:
os
.
unlink
(
backup
)
except
os
.
error
:
pass
try
:
os
.
rename
(
file
,
backup
)
except
os
.
error
:
pass
f
=
open
(
file
,
"w"
)
f
.
write
(
newtext
)
f
.
close
()
print
file
if
__name__
==
'__main__'
:
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment