Skip to content

Commit

Permalink
CLI: Raise FileExistsError to prevent overwriting files
Browse files Browse the repository at this point in the history
  • Loading branch information
neon-ninja committed Aug 16, 2022
1 parent 8fd973b commit f1c40d9
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions facebook_scraper/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import time
from datetime import datetime, timedelta
import re
import os


_scraper = FacebookScraper()
Expand Down Expand Up @@ -402,6 +403,9 @@ def write_posts_to_csv(
if encoding is None:
encoding = locale.getpreferredencoding()

if os.path.isfile(filename):
raise FileExistsError(f"{filename} exists")

if filename == "-":
output_file = sys.stdout
else:
Expand Down

0 comments on commit f1c40d9

Please sign in to comment.