We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ed2c104 commit 990fa44Copy full SHA for 990fa44
topic.py
@@ -13,7 +13,8 @@ def add_toc(fn):
13
out_s = subprocess.Popen(
14
["bash", "-c", "./github-markdown-toc/gh-md-toc - < " + fn],
15
stdout=subprocess.PIPE).stdout.read().decode('utf-8')
16
- out_s += open(fn).read()
+ with open(fn, "rt") as fh:
17
+ out_s += fh.read()
18
return out_s
19
20
@@ -26,7 +27,9 @@ def main(argv):
26
27
parser.add_argument('--input', type=str, required=True,
28
help='Input filename')
29
args = parser.parse_args(argv[1:])
- 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)
33
34
35
main(sys.argv)
0 commit comments