From b76bbc3c47d913a80b3383b2cf79c7a6c067ca51 Mon Sep 17 00:00:00 2001 From: Vladislav Goncharenko Date: Sat, 23 Apr 2022 22:46:42 +0300 Subject: [PATCH 1/2] added defalut arg to download function --- somepytools/general.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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()) From 231f2422108ebd5a57c9816ea08a2290e0ab3a9b Mon Sep 17 00:00:00 2001 From: Vladislav Goncharenko Date: Sat, 23 Apr 2022 22:49:02 +0300 Subject: [PATCH 2/2] bumped version --- pyproject.toml | 2 +- somepytools/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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"