optional-faker


Nameoptional-faker JSON
Version 2.1.0 PyPI version JSON
download
home_pagehttps://github.com/PerchunPak/optional-faker
SummarySmall wrapper around faker, to make values optional!
upload_time2023-12-15 21:52:46
maintainer
docs_urlNone
authorPerchunPak
requires_python>=3.8.1,<4
licenseGPL3
keywords faker
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # optional-faker

[![Support Ukraine](https://badgen.net/badge/support/UKRAINE/?color=0057B8&labelColor=FFD700)](https://www.gov.uk/government/news/ukraine-what-you-can-do-to-help)

[![Build Status](https://github.com/PerchunPak/optional-faker/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/PerchunPak/optional-faker/actions?query=workflow%3Atest)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Python support versions badge (from pypi)](https://img.shields.io/pypi/pyversions/optional-faker)](https://www.python.org/downloads/)

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

```py
>>> 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

```bash
pip install optional-faker
```

And then you need to import `optional_faker` anywhere but before creating `Faker` instance.

## Installing for local developing

```bash
git clone https://github.com/PerchunPak/optional-faker.git
cd optional-faker
```

### Installing `poetry`

Next we need install `poetry` with [recommended way](https://python-poetry.org/docs/master/#installation).

If you use Linux, use command:

```bash
curl -sSL https://install.python-poetry.org | python -
```

If you use Windows, open PowerShell with admin privileges and use:

```powershell
(Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | python -
```

### Installing dependencies

```bash
poetry install
```

### If something is not clear

You can always write me!

## Updating

```bash
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](https://github.com/lyz-code/faker-optional).

This project was generated with [python-template](https://github.com/PerchunPak/python-template).

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/PerchunPak/optional-faker",
    "name": "optional-faker",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8.1,<4",
    "maintainer_email": "",
    "keywords": "faker",
    "author": "PerchunPak",
    "author_email": "pypi@perchun.it",
    "download_url": "https://files.pythonhosted.org/packages/c7/a7/a3057ca990bc5b6e1df8f341de6ba651262f398813330778123de9cc25ff/optional_faker-2.1.0.tar.gz",
    "platform": null,
    "description": "# optional-faker\n\n[![Support Ukraine](https://badgen.net/badge/support/UKRAINE/?color=0057B8&labelColor=FFD700)](https://www.gov.uk/government/news/ukraine-what-you-can-do-to-help)\n\n[![Build Status](https://github.com/PerchunPak/optional-faker/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/PerchunPak/optional-faker/actions?query=workflow%3Atest)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n[![Python support versions badge (from pypi)](https://img.shields.io/pypi/pyversions/optional-faker)](https://www.python.org/downloads/)\n\nSmall wrapper around faker, to make values optional!\n\nNote 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`.\n\n## Example\n\n```py\n>>> from faker import Faker\n>>> import optional_faker\n>>>\n>>> fake = Faker()\n>>> Faker.seed(1555)\n>>>\n>>> # `fake.none_or` can take any value, and return it, or None.\n>>> fake.none_or(fake.pystr())\n'scHhghRDleajCHjEYWAu'\n>>> fake.none_or(fake.pystr())\nNone\n>>> # or it can take callable, and *args with **kwargs\n>>> # that will be passed to this callable.\n>>> fake.none_or(fake.pystr, 1, max_chars=10)\n'zmZUcJVTYX'\n>>> fake.none_or(fake.pystr, 1, max_chars=10)\nNone\n>>> # there is no explicit check is callable a faker part,\n>>> # so you can pass anything.\n>>> fake.none_or(lambda: \"my callable!\")\n'my callable!'\n>>> fake.none_or(lambda: \"my callable!\")\nNone\n```\n\n## Installing\n\n```bash\npip install optional-faker\n```\n\nAnd then you need to import `optional_faker` anywhere but before creating `Faker` instance.\n\n## Installing for local developing\n\n```bash\ngit clone https://github.com/PerchunPak/optional-faker.git\ncd optional-faker\n```\n\n### Installing `poetry`\n\nNext we need install `poetry` with [recommended way](https://python-poetry.org/docs/master/#installation).\n\nIf you use Linux, use command:\n\n```bash\ncurl -sSL https://install.python-poetry.org | python -\n```\n\nIf you use Windows, open PowerShell with admin privileges and use:\n\n```powershell\n(Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | python -\n```\n\n### Installing dependencies\n\n```bash\npoetry install\n```\n\n### If something is not clear\n\nYou can always write me!\n\n## Updating\n\n```bash\npip install -U optional-faker\n```\n\n### For local development\n\nFor updating, just re-download repository,\nif you used `git` for downloading, just run `git pull`.\n\n## Thanks\n\nThis project was inspired by [faker-optional](https://github.com/lyz-code/faker-optional).\n\nThis project was generated with [python-template](https://github.com/PerchunPak/python-template).\n",
    "bugtrack_url": null,
    "license": "GPL3",
    "summary": "Small wrapper around faker, to make values optional!",
    "version": "2.1.0",
    "project_urls": {
        "Homepage": "https://github.com/PerchunPak/optional-faker",
        "Repository": "https://github.com/PerchunPak/optional-faker"
    },
    "split_keywords": [
        "faker"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0b6075f0766fcb0ec9714c897e1f801653724280b99270fe41f7ee34f91f2a68",
                "md5": "c65e74c9ac12e81485d503649544f635",
                "sha256": "1e6a9c1c576a8de6a7d266955364e162991a3aab03d77130ad0932fbec8012c9"
            },
            "downloads": -1,
            "filename": "optional_faker-2.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c65e74c9ac12e81485d503649544f635",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8.1,<4",
            "size": 14679,
            "upload_time": "2023-12-15T21:52:45",
            "upload_time_iso_8601": "2023-12-15T21:52:45.289390Z",
            "url": "https://files.pythonhosted.org/packages/0b/60/75f0766fcb0ec9714c897e1f801653724280b99270fe41f7ee34f91f2a68/optional_faker-2.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c7a7a3057ca990bc5b6e1df8f341de6ba651262f398813330778123de9cc25ff",
                "md5": "15b279431c9003953f84eab3fa7a0d2e",
                "sha256": "0a09f1db6a3f96d65e28c606e084e8c3259c1a6d4955a84e5f19c801137cc253"
            },
            "downloads": -1,
            "filename": "optional_faker-2.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "15b279431c9003953f84eab3fa7a0d2e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8.1,<4",
            "size": 14500,
            "upload_time": "2023-12-15T21:52:46",
            "upload_time_iso_8601": "2023-12-15T21:52:46.947906Z",
            "url": "https://files.pythonhosted.org/packages/c7/a7/a3057ca990bc5b6e1df8f341de6ba651262f398813330778123de9cc25ff/optional_faker-2.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-15 21:52:46",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "PerchunPak",
    "github_project": "optional-faker",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "optional-faker"
}
        
Elapsed time: 2.06587s