File tree Expand file tree Collapse file tree 2 files changed +15
-6
lines changed
src/power_grid_model_io/utils Expand file tree Collapse file tree 2 files changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -214,12 +214,8 @@ def get_download_path(
214214 unique_key: A unique string that can be used to generate a filename (e.g. a url).
215215 """
216216
217- # If no dir_path is given, use the system's designated folder for temporary files.
218- if dir_path is None :
219- dir_path = Path (tempfile .gettempdir ())
220-
221217 # If no specific download path was given, we need to generate a unique key (based on the given unique key)
222- if file_name is None or unique_key is not None :
218+ if dir_path is None or file_name is None :
223219 if unique_key is None :
224220 raise ValueError ("Supply a unique key in order to auto generate a download path." )
225221
@@ -233,7 +229,12 @@ def get_download_path(
233229 file_name = Path (f"{ unique_key } .download" )
234230 # Otherwise, use the unique key as a sub directory
235231 else :
236- dir_path /= unique_key
232+ assert dir_path is None # sanity check
233+ dir_path = Path (tempfile .gettempdir ()) / unique_key
234+
235+ # If no dir_path is given, use the system's designated folder for temporary files.
236+ if dir_path is None :
237+ dir_path = Path (tempfile .gettempdir ())
237238
238239 # Combine the two paths
239240 assert file_name is not None
Original file line number Diff line number Diff line change @@ -366,6 +366,14 @@ def test_get_download_path(temp_dir: Path):
366366 assert path == temp_dir / "file_name.zip"
367367
368368
369+ def test_get_download_path__ignore_unique_key (temp_dir : Path ):
370+ # Act
371+ path = get_download_path (dir_path = temp_dir , file_name = "file_name.zip" , unique_key = "foo" )
372+
373+ # Assert
374+ assert path == temp_dir / "file_name.zip"
375+
376+
369377def test_get_download_path__auto_dir ():
370378 # Act
371379 path = get_download_path (file_name = "file_name.zip" , unique_key = "foo" )
You can’t perform that action at this time.
0 commit comments