summaryrefslogtreecommitdiff
path: root/utils/reindent.py
diff options
context:
space:
mode:
authorVille Skyttä <ville.skytta@iki.fi>2016-07-07 18:53:34 +0300
committerVille Skyttä <ville.skytta@iki.fi>2016-07-07 18:53:34 +0300
commite8a8be5788fcf761d61d2e584e25a7d08b93cc95 (patch)
tree5f458c979197ef94c9a4a73dd4b04ec5db1de508 /utils/reindent.py
parent593708a39cda458386b6c7352bebb62df6191af7 (diff)
downloadsphinx-git-e8a8be5788fcf761d61d2e584e25a7d08b93cc95.tar.gz
Handle more file closing with "with"
Diffstat (limited to 'utils/reindent.py')
-rwxr-xr-xutils/reindent.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/utils/reindent.py b/utils/reindent.py
index 7679045cb..ee13a634a 100755
--- a/utils/reindent.py
+++ b/utils/reindent.py
@@ -127,8 +127,8 @@ def check(file):
errprint("%s: I/O Error: %s" % (file, str(msg)))
return
- r = Reindenter(f)
- f.close()
+ with f:
+ r = Reindenter(f)
if r.run():
if verbose:
print("changed.")
@@ -140,9 +140,8 @@ def check(file):
shutil.copyfile(file, bak)
if verbose:
print("backed up", file, "to", bak)
- f = open(file, "w")
- r.write(f)
- f.close()
+ with open(file, "w") as f:
+ r.write(f)
if verbose:
print("wrote new", file)
return True