Small wrapper around faker, to make values optional!
Project description
optional-faker
Small wrapper around faker, to make values optional!
Example
>>> from faker import Faker
>>>
>>> fake = Faker()
>>> Faker.seed(444)
>>>
>>> # `fake.optional` can take any value, and return it, or None.
>>> fake.optional(fake.pystr())
'qazSMGwqdElzLTggMaPM'
>>> fake.optional(fake.pystr())
None
>>> # or it can take callable, and *args with **kwargs
>>> # that will be passed to this callable.
>>> fake.optional(fake.pystr, 1, max_chars=10)
'hmIEP'
>>> fake.optional(fake.pystr, 1, max_chars=10)
None
>>> # there is no explicit check is callable a faker part,
>>> # so you can pass anything.
>>> fake.optional(lambda: "my callable!")
'my callable!'
>>> fake.optional(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. Current template version: 4a2261d1a645d05e269c2f4b02c0b68203ad72fa. See what updated.
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
Hashes for optional_faker-1.0.0.post1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | f21335e145bf05359df927271a60df595457dcb7fbfbe2fa082550a090639127 |
|
MD5 | 0f8ead602eb42729f001d1556000cf35 |
|
BLAKE2b-256 | b5fb159a4e15871db854c3319fb4fa27c11ce7377f6f6ec451a33240fab8b926 |
Hashes for optional_faker-1.0.0.post1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d8d454fd51c93f4e67a31ccd6187238e013696cb98d8f750225167ab8029324d |
|
MD5 | 5d9e02950bb2e5a354c0362ef79f6dd7 |
|
BLAKE2b-256 | 7261e43524f79767c9b7e54fbe7cbd3e1c2fe0d5469c5da52bc59efd545afc62 |