From 890b070dacc4a9834e2cab0c4d454803053e2d70 Mon Sep 17 00:00:00 2001 From: lucasrodes Date: Thu, 11 May 2023 11:37:36 +0200 Subject: [PATCH] fix(extension): missing extension in downloaded file --- owid/datautils/decorators.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/owid/datautils/decorators.py b/owid/datautils/decorators.py index ca8f78b..d4493f4 100644 --- a/owid/datautils/decorators.py +++ b/owid/datautils/decorators.py @@ -6,6 +6,7 @@ from owid.datautils.s3 import S3 import tempfile from typing import Callable, Any, Optional +from pathlib import Path def enable_file_download(path_arg_name: Optional[str] = None) -> Callable[[Any], Any]: @@ -41,7 +42,8 @@ def wrapper_download(*args: Any, **kwargs: Any) -> Any: # Check if download is needed and download path = str(path) if path.startswith(prefixes_flat): # Download from URL and run function - with tempfile.NamedTemporaryFile() as temp_file: + suffix = Path(path).suffix.lower() + with tempfile.NamedTemporaryFile(suffix=suffix) as temp_file: # Download file from URL if path.startswith(prefixes["url"]): download_file_from_url(