Skip to content

Commit

Permalink
download_if_necessary creates local path if it does not already exist
Browse files Browse the repository at this point in the history
  • Loading branch information
andreArtelt committed Mar 18, 2024
1 parent 786722e commit ad1d92e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions epyt_flow/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ def download_if_necessary(download_path: str, url: str, verbose: bool = True) ->
"""
Downloads a file from a given URL if it does not already exist in a given path.
Note that if the path (folder) does not already exist, it will be created.
Parameters
----------
download_path : `str`
Expand All @@ -121,6 +123,9 @@ def download_if_necessary(download_path: str, url: str, verbose: bool = True) ->
The default is True.
"""
folder_path = str(Path(download_path).parent.absolute())
create_path_if_not_exist(folder_path)

if not os.path.isfile(download_path):
response = requests.get(url, stream=verbose, allow_redirects=True, timeout=1000)

Expand Down

0 comments on commit ad1d92e

Please sign in to comment.