Skip to main content

Serves empty files of many types

Project description

EmptyFiles.Python

PyPI version Test

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")

snippet source | anchor

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

empty-files-0.0.9.tar.gz (6.8 kB view hashes)

Uploaded Source

Built Distribution

empty_files-0.0.9-py3-none-any.whl (7.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page