Skip to content

Commit

Permalink
made the process_output_dir function more reliable on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
trislee committed Sep 15, 2023
1 parent fc61489 commit 8e10c93
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tiktok_hashtag_analysis/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 8e10c93

Please sign in to comment.