summaryrefslogtreecommitdiffstats
path: root/Tools/scripts/untabify.py
diff options
context:
space:
mode:
authorFlorent Xicluna <florent.xicluna@gmail.com>2010-08-09 12:24:20 (GMT)
committerFlorent Xicluna <florent.xicluna@gmail.com>2010-08-09 12:24:20 (GMT)
commite4a3380bb07a1bae5fde5d7b4e96519ca603319c (patch)
treedaec3d767896f943aa29af95cf1090b58b4ebddd /Tools/scripts/untabify.py
parentaba74bddd69f98217e6148e117aec0d607f1d7f7 (diff)
downloadcpython-e4a3380bb07a1bae5fde5d7b4e96519ca603319c.zip
cpython-e4a3380bb07a1bae5fde5d7b4e96519ca603319c.tar.gz
cpython-e4a3380bb07a1bae5fde5d7b4e96519ca603319c.tar.bz2
Clean up syntax for some scripts.
Diffstat (limited to 'Tools/scripts/untabify.py')
-rwxr-xr-xTools/scripts/untabify.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/Tools/scripts/untabify.py b/Tools/scripts/untabify.py
index f21b7c8..1ad589c 100755
--- a/Tools/scripts/untabify.py
+++ b/Tools/scripts/untabify.py
@@ -6,6 +6,7 @@ import os
import sys
import getopt
+
def main():
tabsize = 8
try:
@@ -23,11 +24,11 @@ def main():
for filename in args:
process(filename, tabsize)
+
def process(filename, tabsize):
try:
- f = open(filename)
- text = f.read()
- f.close()
+ with open(filename) as f:
+ text = f.read()
except IOError as msg:
print("%r: I/O error: %s" % (filename, msg))
return
@@ -43,10 +44,10 @@ def process(filename, tabsize):
os.rename(filename, backup)
except os.error:
pass
- f = open(filename, "w")
- f.write(newtext)
- f.close()
+ with open(filename, "w") as f:
+ f.write(newtext)
print(filename)
+
if __name__ == '__main__':
main()