From 951790d972744d9dbd4108983e65eecb2aa2e7fb Mon Sep 17 00:00:00 2001 From: anonymousdouble <112695649+anonymousdouble@users.noreply.github.com> Date: Tue, 19 Dec 2023 14:59:06 +1100 Subject: [PATCH] Update cli.py (#178) refactor with With statement to open file to make code more Pythonic --- slackviewer/cli.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/slackviewer/cli.py b/slackviewer/cli.py index 1e2d085..951fc61 100644 --- a/slackviewer/cli.py +++ b/slackviewer/cli.py @@ -51,5 +51,5 @@ def export(archive_dir): source_file=export_file_info["basename"], channels=channel_list ) - outfile = open(export_file_info["stripped_name"] + '.html', 'w') - outfile.write(html.encode('utf-8')) + with open(export_file_info['stripped_name'] + '.html', 'w') as outfile: + outfile.write(html.encode('utf-8'))