Skip to content

Commit 990fa44

Browse files
committed
python3 refactor/modernize/fix
1 parent ed2c104 commit 990fa44

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

topic.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ def add_toc(fn):
1313
out_s = subprocess.Popen(
1414
["bash", "-c", "./github-markdown-toc/gh-md-toc - < " + fn],
1515
stdout=subprocess.PIPE).stdout.read().decode('utf-8')
16-
out_s += open(fn).read()
16+
with open(fn, "rt") as fh:
17+
out_s += fh.read()
1718
return out_s
1819

1920

@@ -26,7 +27,9 @@ def main(argv):
2627
parser.add_argument('--input', type=str, required=True,
2728
help='Input filename')
2829
args = parser.parse_args(argv[1:])
29-
open(args.output, "wt").write(add_toc(args.input))
30+
output_text = add_toc(args.input)
31+
with open(args.output, "wt") as ofh:
32+
ofh.write(output_text)
3033

3134

3235
main(sys.argv)

0 commit comments

Comments
 (0)