phone-gen


Namephone-gen JSON
Version 2.4.4 PyPI version JSON
download
home_pagehttps://github.com/tolstislon/phone-gen
SummaryInternational phone number generation
upload_time2024-04-19 13:39:21
maintainerNone
docs_urlNone
authortolstislon
requires_python>=3.7
licenseMIT License
keywords testing test-data phone-number phone test-data-generator
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Phone Gen

[![PyPI](https://img.shields.io/pypi/v/phone-gen?color=%2301a001&label=pypi&logo=version)](https://pypi.org/project/phone-gen/)
[![Downloads](https://pepy.tech/badge/phone-gen)](https://pepy.tech/project/phone-gen)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/phone-gen.svg)](https://pypi.org/project/phone-gen/)
[![PyPI - Implementation](https://img.shields.io/pypi/implementation/phone-gen)](https://github.com/tolstislon/phone-gen)  

[![Code style: black](https://github.com/tolstislon/phone-gen/workflows/tests/badge.svg)](https://github.com/tolstislon/phone-gen/actions/workflows/python-package.yml)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)

International phone number generation

**This module was created exclusively for generating test data**


Installation
----
Install using pip with

```bash
pip install phone-gen
```

Example
----

```python
from phone_gen import PhoneNumber

phone_number = PhoneNumber("GB")  # ISO 3166-2
# or
phone_number = PhoneNumber("GBR")  # ISO 3166-3
# or
phone_number = PhoneNumber("Great Britain")  # Country name

# Get a phone number
number = phone_number.get_number()
print(number)  # +442908124840

# Get a country code
country_code = phone_number.get_code()
print(country_code)  # 44

# Get a phone number without a country code
number = phone_number.get_number(full=False)
print(number)  # 183782623

# Get a mobile phone number
number = phone_number.get_mobile()
print(number)  # +447911899521

# Get a national phone number
number = phone_number.get_national()
print(number)  # +442408055065
```

##### pytest fixture

```python
import pytest
from phone_gen import PhoneNumber


@pytest.fixture
def phone_number():
    def wrap(code):
        return PhoneNumber(code).get_number()

    yield wrap


def test_one(phone_number):
    number = phone_number("DE")
    ...
```

Using the CLI
----

```bash
usage: phone-gen [-h] [-v] [-n] country [country ...]

International phone number generation

positional arguments:
  country         Country code or country name. Example: "GB" or "GBR" or "Great Britain"

optional arguments:
  -h, --help      show this help message and exit
  -v, --version   show program's version number and exit
  -f, --not-full  Get a phone number without a country code
  -m, --mobile    Get mobile phone number
  -n, --national  Get national phone number
```

Example

```bash
# Get a phone number

$ phone-gen DE
+49791774007056

$ phone-gen DEU
+499968635

$ phone-gen Germany
+49960335800


# Get a phone number without a country code
$ phone-gen -f DE
66999511

$ phone-gen -f Germany
877595

# Get mobile phone number
$ phone-gen -m DE
+491601376066

# Get national phone number
$ phone-gen -n DE
+4940381
```

Resources
----

* [Google's libphonenumber](https://github.com/google/libphonenumber)
* Modified [strgen](https://github.com/paul-wolf/strgen) library

Changelog
----

* [Releases](https://github.com/tolstislon/phone-gen/releases)

Contributing
----

#### Contributions are very welcome.

You might want to:

* Fix spelling errors
* Improve documentation
* Add tests for untested code
* Add new features
* Fix bugs

#### Getting started

* python 3.11
* pipenv 2022.12.19+

1. Clone the repository
    ```bash
    git clone https://github.com/tolstislon/phone-gen.git
    cd phone-gen
   ```
2. Install dev dependencies
    ```bash
    pipenv install --dev
    pipenv shell
   ```
3. Run the linters
    ```bash
    black phone_gen/ 
    flake8 phone_gen/
   ```
4. Run the tests
    ```bash
    pytest tests/
   ```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/tolstislon/phone-gen",
    "name": "phone-gen",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "testing, test-data, phone-number, phone, test-data-generator",
    "author": "tolstislon",
    "author_email": "tolstislon@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/a0/a9/e0402d3e19aea6cb80ca03f2e00f100f0e2d540e3a5d93b010f608003117/phone_gen-2.4.4.tar.gz",
    "platform": null,
    "description": "# Phone Gen\n\n[![PyPI](https://img.shields.io/pypi/v/phone-gen?color=%2301a001&label=pypi&logo=version)](https://pypi.org/project/phone-gen/)\n[![Downloads](https://pepy.tech/badge/phone-gen)](https://pepy.tech/project/phone-gen)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/phone-gen.svg)](https://pypi.org/project/phone-gen/)\n[![PyPI - Implementation](https://img.shields.io/pypi/implementation/phone-gen)](https://github.com/tolstislon/phone-gen)  \n\n[![Code style: black](https://github.com/tolstislon/phone-gen/workflows/tests/badge.svg)](https://github.com/tolstislon/phone-gen/actions/workflows/python-package.yml)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n\nInternational phone number generation\n\n**This module was created exclusively for generating test data**\n\n\nInstallation\n----\nInstall using pip with\n\n```bash\npip install phone-gen\n```\n\nExample\n----\n\n```python\nfrom phone_gen import PhoneNumber\n\nphone_number = PhoneNumber(\"GB\")  # ISO 3166-2\n# or\nphone_number = PhoneNumber(\"GBR\")  # ISO 3166-3\n# or\nphone_number = PhoneNumber(\"Great Britain\")  # Country name\n\n# Get a phone number\nnumber = phone_number.get_number()\nprint(number)  # +442908124840\n\n# Get a country code\ncountry_code = phone_number.get_code()\nprint(country_code)  # 44\n\n# Get a phone number without a country code\nnumber = phone_number.get_number(full=False)\nprint(number)  # 183782623\n\n# Get a mobile phone number\nnumber = phone_number.get_mobile()\nprint(number)  # +447911899521\n\n# Get a national phone number\nnumber = phone_number.get_national()\nprint(number)  # +442408055065\n```\n\n##### pytest fixture\n\n```python\nimport pytest\nfrom phone_gen import PhoneNumber\n\n\n@pytest.fixture\ndef phone_number():\n    def wrap(code):\n        return PhoneNumber(code).get_number()\n\n    yield wrap\n\n\ndef test_one(phone_number):\n    number = phone_number(\"DE\")\n    ...\n```\n\nUsing the CLI\n----\n\n```bash\nusage: phone-gen [-h] [-v] [-n] country [country ...]\n\nInternational phone number generation\n\npositional arguments:\n  country         Country code or country name. Example: \"GB\" or \"GBR\" or \"Great Britain\"\n\noptional arguments:\n  -h, --help      show this help message and exit\n  -v, --version   show program's version number and exit\n  -f, --not-full  Get a phone number without a country code\n  -m, --mobile    Get mobile phone number\n  -n, --national  Get national phone number\n```\n\nExample\n\n```bash\n# Get a phone number\n\n$ phone-gen DE\n+49791774007056\n\n$ phone-gen DEU\n+499968635\n\n$ phone-gen Germany\n+49960335800\n\n\n# Get a phone number without a country code\n$ phone-gen -f DE\n66999511\n\n$ phone-gen -f Germany\n877595\n\n# Get mobile phone number\n$ phone-gen -m DE\n+491601376066\n\n# Get national phone number\n$ phone-gen -n DE\n+4940381\n```\n\nResources\n----\n\n* [Google's libphonenumber](https://github.com/google/libphonenumber)\n* Modified [strgen](https://github.com/paul-wolf/strgen) library\n\nChangelog\n----\n\n* [Releases](https://github.com/tolstislon/phone-gen/releases)\n\nContributing\n----\n\n#### Contributions are very welcome.\n\nYou might want to:\n\n* Fix spelling errors\n* Improve documentation\n* Add tests for untested code\n* Add new features\n* Fix bugs\n\n#### Getting started\n\n* python 3.11\n* pipenv 2022.12.19+\n\n1. Clone the repository\n    ```bash\n    git clone https://github.com/tolstislon/phone-gen.git\n    cd phone-gen\n   ```\n2. Install dev dependencies\n    ```bash\n    pipenv install --dev\n    pipenv shell\n   ```\n3. Run the linters\n    ```bash\n    black phone_gen/ \n    flake8 phone_gen/\n   ```\n4. Run the tests\n    ```bash\n    pytest tests/\n   ```\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "International phone number generation",
    "version": "2.4.4",
    "project_urls": {
        "Homepage": "https://github.com/tolstislon/phone-gen"
    },
    "split_keywords": [
        "testing",
        " test-data",
        " phone-number",
        " phone",
        " test-data-generator"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3d99c171152b481cd51facbf0fc50b104b2e9dbcb1c18923189f8b7fd3b7f7c5",
                "md5": "0321dd9366d0e4535ffec567a2b87665",
                "sha256": "ed5d6e54476d8acd21339fc237fab8de72d9c8c49042818ba608699d319196da"
            },
            "downloads": -1,
            "filename": "phone_gen-2.4.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0321dd9366d0e4535ffec567a2b87665",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 35336,
            "upload_time": "2024-04-19T13:39:19",
            "upload_time_iso_8601": "2024-04-19T13:39:19.263128Z",
            "url": "https://files.pythonhosted.org/packages/3d/99/c171152b481cd51facbf0fc50b104b2e9dbcb1c18923189f8b7fd3b7f7c5/phone_gen-2.4.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a0a9e0402d3e19aea6cb80ca03f2e00f100f0e2d540e3a5d93b010f608003117",
                "md5": "746518979c45e9e38bdde178d0555aa4",
                "sha256": "e869a7c091b1e33349effb7dd089677756145b1ac0c699e0642f68ad61e450c0"
            },
            "downloads": -1,
            "filename": "phone_gen-2.4.4.tar.gz",
            "has_sig": false,
            "md5_digest": "746518979c45e9e38bdde178d0555aa4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 42278,
            "upload_time": "2024-04-19T13:39:21",
            "upload_time_iso_8601": "2024-04-19T13:39:21.437730Z",
            "url": "https://files.pythonhosted.org/packages/a0/a9/e0402d3e19aea6cb80ca03f2e00f100f0e2d540e3a5d93b010f608003117/phone_gen-2.4.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-19 13:39:21",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "tolstislon",
    "github_project": "phone-gen",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "phone-gen"
}
        
Elapsed time: 0.22680s