From 8e10c93e31aa2d46e1de65389b1c87e42b7d5708 Mon Sep 17 00:00:00 2001 From: Tristan Lee Date: Fri, 15 Sep 2023 02:43:30 -0500 Subject: [PATCH] made the process_output_dir function more reliable on Windows --- tiktok_hashtag_analysis/cli.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tiktok_hashtag_analysis/cli.py b/tiktok_hashtag_analysis/cli.py index 37141d5..b2583cd 100644 --- a/tiktok_hashtag_analysis/cli.py +++ b/tiktok_hashtag_analysis/cli.py @@ -99,6 +99,11 @@ def process_output_dir( if not os.access(path=_output_dir, mode=os.W_OK): parser.error(error_message(_output_dir)) else: + # On Windows, os.access is unreliable + temp_file = _output_dir / "test.txt" + with open(temp_file, 'w') as f: + f.write("test") + os.remove(temp_file) return _output_dir except PermissionError: parser.error(error_message(_output_dir))