diff --git a/pyproject.toml b/pyproject.toml index 74f4d66..2db68f8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "somepytools" -version = "1.2.0" +version = "1.2.1" description = "Just some useful Python tools" authors = ["Vladilav Goncharenko "] maintainers = ["Vladislav Goncharenko "] diff --git a/somepytools/__init__.py b/somepytools/__init__.py index c68196d..a955fda 100644 --- a/somepytools/__init__.py +++ b/somepytools/__init__.py @@ -1 +1 @@ -__version__ = "1.2.0" +__version__ = "1.2.1" diff --git a/somepytools/general.py b/somepytools/general.py index 85bd65f..04c4575 100644 --- a/somepytools/general.py +++ b/somepytools/general.py @@ -2,11 +2,12 @@ from functools import wraps from inspect import getfullargspec from pathlib import Path +from urllib.parse import urlparse from urllib.request import urlopen from zipfile import ZipFile from .constants import SIZE_CONSTANTS -from .typing import Any, Directory, File, get_args +from .typing import Any, Directory, File, Optional, get_args def str2pathlib(func): @@ -75,13 +76,14 @@ def wrapper(*args, **kwargs): @str2pathlib -def download_url(url: str, save_path: File): +def download_url(url: str, save_path: Optional[File] = None): """Downloads and saves data from url Args: url: address of file to download save_path: file path to save to """ + save_path = save_path or urlparse(url).path.split("/")[-1] with urlopen(url) as response: with open(save_path, "wb") as file: file.write(response.read())