Clean up syntax for some scripts.
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 sys
import getopt
+
def main():
tabsize = 8
try:
@@ -23,11 +24,11 @@
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 @@
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()