Skip to content

Commit

Permalink
ensure directory is present
Browse files Browse the repository at this point in the history
  • Loading branch information
christinahedges committed Jul 11, 2024
1 parent 93aefd1 commit c24ae32
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
src/lkprf/data
src/lkprf/data/*.fits
sandbox

# Byte-compiled / optimized / DLL files
Expand Down
2 changes: 2 additions & 0 deletions src/lkprf/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ def _download_file(url, file_path):
try:
response = requests.get(url)
response.raise_for_status() # Ensure the request was successful
if not os.path.isdir('/'.join(file_path.split('/')[:-1])):
os.mkdir('/'.join(file_path.split('/')[:-1]))
with open(file_path, "wb") as f:
f.write(response.content)
except requests.exceptions.HTTPError as http_err:
Expand Down

0 comments on commit c24ae32

Please sign in to comment.