summaryrefslogtreecommitdiff
path: root/doc/postprocess.py
diff options
context:
space:
mode:
Diffstat (limited to 'doc/postprocess.py')
-rwxr-xr-xdoc/postprocess.py10
1 files changed, 3 insertions, 7 deletions
diff --git a/doc/postprocess.py b/doc/postprocess.py
index b6d067437..e4cbecf7b 100755
--- a/doc/postprocess.py
+++ b/doc/postprocess.py
@@ -23,18 +23,14 @@ def main():
p.error('unknown mode %s' % mode)
for fn in args:
- f = io.open(fn, 'r', encoding="utf-8")
- try:
+ with io.open(fn, 'r', encoding="utf-8") as f:
if mode == 'html':
lines = process_html(fn, f.readlines())
elif mode == 'tex':
lines = process_tex(f.readlines())
- finally:
- f.close()
- f = io.open(fn, 'w', encoding="utf-8")
- f.write("".join(lines))
- f.close()
+ with io.open(fn, 'w', encoding="utf-8") as f:
+ f.write("".join(lines))
def process_html(fn, lines):
return lines