Serves empty files of many types
Project description
EmptyFiles.Python
TL;DR Null Object pattern for files.
Contents
This project will create an empty file of a type requested. If possible, that file will be the smallest valid file for that type. For example, an empty jpg will be a 1x1 pixel jpg.
Setup
From pypi:
pip install empty-files
Usage
This code:
from empty_files.empty_files import create_empty_file
create_empty_file("temp/empty.jpg")
will create the following image
Null Object Pattern
Issue: null/None causes extra checks in order to avoid errors.
Solution: return an empty version of the object, so methods can be used normally.
Example:
if last_name returns "" instead of None,
we can write:
name_length = len(person.last_name())
instead of :
name_length = 0
if (person.last_name())
name_length = len(person.last_name())
Attributions
The empty files are taken from Simon Cropp's Empty Files.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file empty-files-0.0.9.tar.gz.
File metadata
- Download URL: empty-files-0.0.9.tar.gz
- Upload date:
- Size: 6.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
22e74de327271ef9592a661aaa53bb1d5fa6cfd539dac7315625c8b30b7292ae
|
|
| MD5 |
a5c0f147062a99a39098db6ed3bf9ddd
|
|
| BLAKE2b-256 |
0e19ac55ab18403da2885b3fd5baa7974b12d8a3c59ee56ea185a9a80632839b
|
File details
Details for the file empty_files-0.0.9-py3-none-any.whl.
File metadata
- Download URL: empty_files-0.0.9-py3-none-any.whl
- Upload date:
- Size: 7.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9af04feacd5858d1255a00e76926a2d760f6d05c3c5a8df58abd6be21da742c2
|
|
| MD5 |
c876b8caaec81523a708debbb46cf0e0
|
|
| BLAKE2b-256 |
3c4cd5b6973c9f10992a2aee9c4cb542b25ebdabe907243d6c9650c89dbf578b
|