Skip to content

Commit

Permalink
Up
Browse files Browse the repository at this point in the history
  • Loading branch information
barseghyanartur committed Sep 16, 2024
1 parent f402d1f commit a84f0cd
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 30 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.9.7
-----
2024-09-17

- Minor (documentation) fixes.

0.9.6
-----
2024-09-16
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Update version ONLY here
VERSION := 0.9.6
VERSION := 0.9.7
SHELL := /bin/bash
# Makefile for project
VENV := ~/.virtualenvs/fake.py/bin/activate
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ texts, (person) names, URLs, dates, file names, IPs, primitive Python data
types (such as `uuid`, `str`, `int`, `float`, `bool`), GEO data such as city,
country, geo-location, country code, latitude, longitude and locales,
IBANs and ISBNs, as well as byte content for multiple file formats
including `PDF`, `DOCX`, `ODT`, `PNG`, `SVG`, `BMP`, `GIF`, `TIF`, `PPM`
including `PDF`, `DOCX`, `ODT`, `PNG`, `SVG`, `BMP`, `GIF`, `TIF`, `PPM`,
`WAV`, `ZIP`, `TAR` and `EML`.

The package also supports file creation on the filesystem and includes
Expand Down
42 changes: 15 additions & 27 deletions fake.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
Callable,
Coroutine,
Dict,
Iterable,
List,
Literal,
Optional,
Expand All @@ -62,7 +63,7 @@
from uuid import UUID

__title__ = "fake.py"
__version__ = "0.9.6"
__version__ = "0.9.7"
__author__ = "Artur Barseghyan <artur.barseghyan@gmail.com>"
__copyright__ = "2023-2024 Artur Barseghyan"
__license__ = "MIT"
Expand Down Expand Up @@ -561,17 +562,6 @@ def generate_filename(

return str(dir_path / f"{basename}.{extension}")

# if basename:
# return str(dir_path / f"{basename}.{extension}")
# else:
# temp_file = NamedTemporaryFile(
# prefix=prefix,
# dir=str(dir_path),
# suffix=f".{extension}",
# delete=False,
# )
# return temp_file.name

def write_text(
self: "FileSystemStorage",
filename: str,
Expand Down Expand Up @@ -2153,7 +2143,7 @@ def bin(

@provider(tags=("Archive",))
def zip(self, options: Optional[Dict[str, Any]] = None, **kwargs):
"""Create a ZIP archive.
"""Create a ZIP archive file as bytes.
Usage example. A complex case.
Expand Down Expand Up @@ -2182,7 +2172,7 @@ def zip(self, options: Optional[Dict[str, Any]] = None, **kwargs):
# Specific
if options:
# Complex case
_count = options.get("count", 5)
_count = options.get("count", 1)
_create_inner_file_func = options.get(
"create_inner_file_func", create_inner_txt_file
)
Expand All @@ -2192,7 +2182,7 @@ def zip(self, options: Optional[Dict[str, Any]] = None, **kwargs):

else:
# Defaults
_count = 5
_count = 1
_create_inner_file_func = create_inner_txt_file
_create_inner_file_args = {}
_dir_path = Path("")
Expand Down Expand Up @@ -2243,12 +2233,10 @@ def zip(self, options: Optional[Dict[str, Any]] = None, **kwargs):
def tar(
self,
options: Optional[Dict[str, Any]] = None,
# Once Python 3.7 is deprecated, add the following annotation:
# Optional[Literal["gz", "bz2", "xz"]] = None
compression: Optional[str] = None,
compression: Optional[Literal["gz", "bz2", "xz"]] = None,
**kwargs,
) -> BytesValue:
"""Generate a TAR file with random text.
"""Generate a TAR archive file as bytes.
:param options: Options (non-structured) for complex types, such as
ZIP.
Expand Down Expand Up @@ -2286,7 +2274,7 @@ def tar(
# Specific
if options:
# Complex case
_count = options.get("count", 5)
_count = options.get("count", 1)
_create_inner_file_func = options.get(
"create_inner_file_func", create_inner_txt_file
)
Expand All @@ -2296,7 +2284,7 @@ def tar(

else:
# Defaults
_count = 5
_count = 1
_create_inner_file_func = create_inner_txt_file
_create_inner_file_args = {}
_dir_path = Path("")
Expand Down Expand Up @@ -2359,7 +2347,7 @@ def eml(
subject: Optional[str] = None,
**kwargs,
) -> BytesValue:
"""Generate an EML file with random text.
"""Generate an EML file bytes.
:param options: Options (non-structured) for complex types, such as
ZIP.
Expand Down Expand Up @@ -2923,7 +2911,7 @@ def tar_file(
basename: Optional[str] = None,
prefix: Optional[str] = None,
options: Optional[Dict[str, Any]] = None,
compression: Optional[str] = None,
compression: Optional[Literal["gz", "bz2", "xz"]] = None,
**kwargs,
) -> StringValue:
"""Create a TAR archive file."""
Expand Down Expand Up @@ -3468,7 +3456,7 @@ def create_inner_tar_file(
basename: Optional[str] = None,
prefix: Optional[str] = None,
options: Optional[Dict[str, Any]] = None,
compression: Optional[str] = None,
compression: Optional[Literal["gz", "bz2", "xz"]] = None,
metadata: Optional[MetaData] = None,
**kwargs,
) -> StringValue:
Expand Down Expand Up @@ -4698,7 +4686,7 @@ def get_argparse_type(param_type) -> Any:

def organize_providers(provider_tags) -> Dict[str, Any]:
"""Organize providers by category for easier navigation."""
categories = {}
categories: Dict[str, Any] = {}
for _provider, tags in provider_tags:
for tag in tags:
if tag not in categories:
Expand Down Expand Up @@ -4860,9 +4848,9 @@ def setUp(self):
]

def test_organize_providers_empty(self):
provider_tags = []
provider_tags: List[Tuple[str, Iterable[str]]] = []
result = organize_providers(provider_tags)
expected = {}
expected: Dict[str, Any] = {}
self.assertEqual(result, expected)

def test_organize_providers_single_tag(self):
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "fake.py"
description = "Minimalistic, standalone alternative fake data generator with no dependencies."
readme = "README.rst"
version = "0.9.6"
version = "0.9.7"
dependencies = []
authors = [
{name = "Artur Barseghyan", email = "artur.barseghyan@gmail.com"},
Expand Down

0 comments on commit a84f0cd

Please sign in to comment.