diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 8eef41b..9fdd21e 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -16,6 +16,12 @@ are used for versioning (schema follows below): 0.3.4 to 0.4). - All backwards incompatible changes are mentioned in this document. +0.1.1 +----- +2024-09-11 + +- Minor optimisations. + 0.1 ----- 2024-08-14 diff --git a/Makefile b/Makefile index 4187008..5a497dc 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ # Update version ONLY here -VERSION := 0.1 +VERSION := 0.1.1 SHELL := /bin/bash # Makefile for project VENV := ~/.virtualenvs/fake-py-django-storage/bin/activate diff --git a/docs/requirements.txt b/docs/requirements.txt index 84070c9..6c16908 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -18,22 +18,22 @@ backports-tarfile==1.2.0 # via jaraco-context black==24.8.0 # via fake-py-django-storage (pyproject.toml) -boto3==1.34.158 +boto3==1.35.16 # via # django-storages # moto -botocore==1.34.158 +botocore==1.35.16 # via # boto3 # moto # s3transfer -build==1.2.1 +build==1.2.2 # via pip-tools -cachetools==5.4.0 +cachetools==5.5.0 # via google-auth -certifi==2024.7.4 +certifi==2024.8.30 # via requests -cffi==1.17.0 +cffi==1.17.1 # via cryptography charset-normalizer==3.3.2 # via requests @@ -44,7 +44,7 @@ click==8.1.7 # pydoclint coverage==7.6.1 # via pytest-cov -cryptography==43.0.0 +cryptography==43.0.1 # via # azure-storage-blob # moto @@ -53,13 +53,13 @@ decorator==5.1.1 # via ipython detect-secrets==1.5.0 # via fake-py-django-storage (pyproject.toml) -django==5.1 +django==5.1.1 # via # fake-py-django-storage (pyproject.toml) # django-storages django-storages==1.14.4 # via fake-py-django-storage (pyproject.toml) -doc8==1.1.1 +doc8==1.1.2 # via fake-py-django-storage (pyproject.toml) docstring-parser-fork==0.0.9 # via pydoclint @@ -75,40 +75,42 @@ exceptiongroup==1.2.2 # via # ipython # pytest -executing==2.0.1 +executing==2.1.0 # via stack-data -fake-py==0.9.3 +fake-py==0.9.5 # via fake-py-django-storage (pyproject.toml) -google-api-core==2.19.1 +google-api-core==2.19.2 # via # google-cloud-core # google-cloud-storage -google-auth==2.33.0 +google-auth==2.34.0 # via # google-api-core # google-cloud-core # google-cloud-storage google-cloud-core==2.4.1 # via google-cloud-storage -google-cloud-storage==1.44.0 +google-cloud-storage==2.18.2 # via django-storages -google-crc32c==1.5.0 - # via google-resumable-media +google-crc32c==1.6.0 + # via + # google-cloud-storage + # google-resumable-media google-resumable-media==2.7.2 # via google-cloud-storage -googleapis-common-protos==1.63.2 +googleapis-common-protos==1.65.0 # via google-api-core -idna==3.7 +idna==3.8 # via requests imagesize==1.4.1 # via sphinx -importlib-metadata==8.2.0 +importlib-metadata==8.5.0 # via # keyring # twine iniconfig==2.0.0 # via pytest -ipython==8.26.0 +ipython==8.27.0 # via fake-py-django-storage (pyproject.toml) isodate==0.6.1 # via azure-storage-blob @@ -116,7 +118,7 @@ isort==5.13.2 # via fake-py-django-storage (pyproject.toml) jaraco-classes==3.4.0 # via keyring -jaraco-context==5.3.0 +jaraco-context==6.0.1 # via keyring jaraco-functools==4.0.2 # via keyring @@ -146,13 +148,13 @@ matplotlib-inline==0.1.7 # via ipython mdurl==0.1.2 # via markdown-it-py -more-itertools==10.4.0 +more-itertools==10.5.0 # via # jaraco-classes # jaraco-functools -moto==5.0.12 +moto==5.0.14 # via fake-py-django-storage (pyproject.toml) -mypy==1.11.1 +mypy==1.11.2 # via fake-py-django-storage (pyproject.toml) mypy-extensions==1.0.0 # via @@ -172,7 +174,7 @@ parso==0.8.4 # via jedi pathspec==0.12.1 # via black -pbr==6.0.0 +pbr==6.1.0 # via stevedore pexpect==4.9.0 # via ipython @@ -182,7 +184,7 @@ pip-tools==7.4.1 # via fake-py-django-storage (pyproject.toml) pkginfo==1.10.0 # via twine -platformdirs==4.2.2 +platformdirs==4.3.2 # via black pluggy==1.5.0 # via pytest @@ -190,25 +192,24 @@ prompt-toolkit==3.0.47 # via ipython proto-plus==1.24.0 # via google-api-core -protobuf==5.27.3 +protobuf==5.28.1 # via # google-api-core - # google-cloud-storage # googleapis-common-protos # proto-plus ptyprocess==0.7.0 # via pexpect pure-eval==0.2.3 # via stack-data -pyasn1==0.6.0 +pyasn1==0.6.1 # via # pyasn1-modules # rsa -pyasn1-modules==0.4.0 +pyasn1-modules==0.4.1 # via google-auth pycparser==2.22 # via cffi -pydoclint==0.5.6 +pydoclint==0.5.7 # via fake-py-django-storage (pyproject.toml) pygments==2.18.0 # via @@ -221,14 +222,14 @@ pyproject-hooks==1.1.0 # via # build # pip-tools -pytest==8.3.2 +pytest==8.3.3 # via # fake-py-django-storage (pyproject.toml) # pytest-cov # pytest-django pytest-cov==5.0.0 # via fake-py-django-storage (pyproject.toml) -pytest-django==4.8.0 +pytest-django==4.9.0 # via fake-py-django-storage (pyproject.toml) pytest-rst==0.1.5 # via fake-py-django-storage (pyproject.toml) @@ -261,23 +262,22 @@ restructuredtext-lint==1.4.0 # via doc8 rfc3986==2.0.0 # via twine -rich==13.7.1 +rich==13.8.1 # via twine rsa==4.9 # via google-auth -ruff==0.5.7 +ruff==0.6.4 # via fake-py-django-storage (pyproject.toml) s3transfer==0.10.2 # via boto3 secretstorage==3.3.3 # via keyring -setuptools==72.1.0 +setuptools==74.1.2 # via pip-tools six==1.16.0 # via # asttokens # azure-core - # google-cloud-storage # isodate # python-dateutil snowballstemmer==2.2.0 @@ -310,7 +310,7 @@ sqlparse==0.5.1 # via django stack-data==0.6.3 # via ipython -stevedore==5.2.0 +stevedore==5.3.0 # via doc8 tomli==2.0.1 # via @@ -342,15 +342,15 @@ urllib3==2.2.2 # requests # responses # twine -uv==0.2.34 +uv==0.4.9 # via fake-py-django-storage (pyproject.toml) wcwidth==0.2.13 # via prompt-toolkit -werkzeug==3.0.3 +werkzeug==3.0.4 # via moto wheel==0.44.0 # via pip-tools xmltodict==0.13.0 # via moto -zipp==3.19.2 +zipp==3.20.1 # via importlib-metadata diff --git a/fakepy/django_storage/__init__.py b/fakepy/django_storage/__init__.py index a66b2fc..4a9fffd 100644 --- a/fakepy/django_storage/__init__.py +++ b/fakepy/django_storage/__init__.py @@ -2,4 +2,4 @@ __author__ = "Artur Barseghyan " __copyright__ = "2024 Artur Barseghyan" __license__ = "MIT" -__version__ = "0.1" +__version__ = "0.1.1" diff --git a/fakepy/django_storage/base.py b/fakepy/django_storage/base.py index 35cd7c1..88fd3cd 100644 --- a/fakepy/django_storage/base.py +++ b/fakepy/django_storage/base.py @@ -1,7 +1,6 @@ import os from abc import abstractmethod from pathlib import Path -from tempfile import NamedTemporaryFile from typing import Optional, Union from django.core.files.base import ContentFile @@ -74,15 +73,11 @@ def generate_filename( if not extension: raise Exception("Extension shall be given!") - if basename: - filename = f"{basename}.{extension}" - else: - temp_file = NamedTemporaryFile( - prefix=prefix, - suffix=f".{extension}", - delete=False, - ) - filename = Path(temp_file.name).name + if not basename: + basename = self.generate_basename(prefix) + + filename = f"{basename}.{extension}" + return os.path.join(dir_path, filename) def write_text( diff --git a/pyproject.toml b/pyproject.toml index 434d767..52c9cf6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,9 +2,9 @@ name = "fake-py-django-storage" description = "Django storage for fake.py" readme = "README.rst" -version = "0.1" +version = "0.1.1" dependencies = [ - "fake.py", + "fake.py>=0.9.5", "django", ] authors = [