python: Migrate open statements to use with.

This is low priority, but it's nice to be consistently using the best
practice pattern.

Fixes: #12419.
This commit is contained in:
Wyatt Hoodes
2019-07-14 09:37:08 -10:00
committed by Tim Abbott
parent e97179fc87
commit e331a758c3
30 changed files with 101 additions and 81 deletions

View File

@@ -7,7 +7,8 @@ def show_all_branches(fns):
# type: (List[str]) -> None
for fn in fns:
print(fn)
text = open(fn).read()
with open(fn, 'r') as f:
text = f.read()
branches = html_branches(text, fn=fn)
for branch in branches:
print(branch.text())
@@ -25,7 +26,8 @@ class Grepper:
all_branches = [] # type: List[HtmlTreeBranch]
for fn in fns:
text = open(fn).read()
with open(fn, 'r') as f:
text = f.read()
branches = html_branches(text, fn=fn)
all_branches += branches