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
>>> import optional_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.
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
optional_faker-1.0.0.post2.tar.gz
(15.1 kB
view hashes)
Built Distribution
Close
Hashes for optional_faker-1.0.0.post2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | af77ceff0bfa0febd4b35de629d4d031835875148e9eea77168ecba3f968c396 |
|
MD5 | c01087ff3238580e62b167b91ce952b6 |
|
BLAKE2b-256 | b324b0e30b2d3e5f7a7ad053b3c1d31fbb4f5b7bcf2c1dc06785a2d007cddb1a |
Close
Hashes for optional_faker-1.0.0.post2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 25dfac7fedba41adfa1c70bfa32aa157345c3d14342fc537dcf21e6a4c389efe |
|
MD5 | b7d43086dc0a5cb59ef64c0f0c3a5bb3 |
|
BLAKE2b-256 | 7ce91c8d2787b76647a1eab00d12a9917bc9598c4afbe06bed08acfa468016f8 |