Skip to content
This repository was archived by the owner on Nov 1, 2023. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion owid/datautils/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down Expand Up @@ -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(
Expand Down