Small wrapper around faker, to make values optional!
Project description
optional-faker
Small wrapper around faker, to make values optional!
Note that faker added own optional
proxy, which however can be used only with callables. This is why in version 2.0.0 we renamed our method to none_or
.
Example
>>> from faker import Faker
>>> import optional_faker
>>>
>>> fake = Faker()
>>> Faker.seed(1555)
>>>
>>> # `fake.none_or` can take any value, and return it, or None.
>>> fake.none_or(fake.pystr())
'scHhghRDleajCHjEYWAu'
>>> fake.none_or(fake.pystr())
None
>>> # or it can take callable, and *args with **kwargs
>>> # that will be passed to this callable.
>>> fake.none_or(fake.pystr, 1, max_chars=10)
'zmZUcJVTYX'
>>> fake.none_or(fake.pystr, 1, max_chars=10)
None
>>> # there is no explicit check is callable a faker part,
>>> # so you can pass anything.
>>> fake.none_or(lambda: "my callable!")
'my callable!'
>>> fake.none_or(lambda: "my callable!")
None
Installing
pip install optional-faker
And then you need to import optional_faker
anywhere but before creating Faker
instance.
Installing for local developing
git clone https://github.com/PerchunPak/optional-faker.git
cd optional-faker
Installing poetry
Next we need install poetry
with recommended way.
If you use Linux, use command:
curl -sSL https://install.python-poetry.org | python -
If you use Windows, open PowerShell with admin privileges and use:
(Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | python -
Installing dependencies
poetry install
If something is not clear
You can always write me!
Updating
pip install -U optional-faker
For local development
For updating, just re-download repository,
if you used git
for downloading, just run git pull
.
Thanks
This project was inspired by faker-optional.
This project was generated with python-template.
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
File details
Details for the file optional_faker-2.1.0.tar.gz
.
File metadata
- Download URL: optional_faker-2.1.0.tar.gz
- Upload date:
- Size: 14.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.12.1 Linux/6.2.0-1018-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0a09f1db6a3f96d65e28c606e084e8c3259c1a6d4955a84e5f19c801137cc253 |
|
MD5 | 15b279431c9003953f84eab3fa7a0d2e |
|
BLAKE2b-256 | c7a7a3057ca990bc5b6e1df8f341de6ba651262f398813330778123de9cc25ff |
File details
Details for the file optional_faker-2.1.0-py3-none-any.whl
.
File metadata
- Download URL: optional_faker-2.1.0-py3-none-any.whl
- Upload date:
- Size: 14.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.12.1 Linux/6.2.0-1018-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1e6a9c1c576a8de6a7d266955364e162991a3aab03d77130ad0932fbec8012c9 |
|
MD5 | c65e74c9ac12e81485d503649544f635 |
|
BLAKE2b-256 | 0b6075f0766fcb0ec9714c897e1f801653724280b99270fe41f7ee34f91f2a68 |