# 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)
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.12
* pipenv 2023.11.15+
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 black
```bash
pipenv run black
```
4. Run flake8
```bash
pipenv run flake
```
5. Run the tests
```bash
pipenv run tests
```
Raw data
{
"_id": null,
"home_page": "https://github.com/tolstislon/phone-gen",
"name": "phone-gen",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"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/ad/3d/fb6dd1b08921e08f2b2193831636a7faa30dfd11322b3c1744a2f31dd7cc/phone_gen-3.0.10.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\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.12\n* pipenv 2023.11.15+\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 black\n ```bash\n pipenv run black\n ```\n4. Run flake8\n ```bash\n pipenv run flake\n ```\n5. Run the tests\n ```bash\n pipenv run tests\n ```\n",
"bugtrack_url": null,
"license": "MIT License",
"summary": "International phone number generation",
"version": "3.0.10",
"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": "d9bca4ec1a3fd45190060bc1bf99d8a0bc3a9ea7a50a44496dd17d025b39fdc8",
"md5": "fe418d0a35d127c02d8898ae6b9488a0",
"sha256": "af3761324b229294b2aa0078ffffeb824eeec1b87a246029991f1bd8e23a5f1e"
},
"downloads": -1,
"filename": "phone_gen-3.0.10-py3-none-any.whl",
"has_sig": false,
"md5_digest": "fe418d0a35d127c02d8898ae6b9488a0",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 33101,
"upload_time": "2024-12-13T11:08:24",
"upload_time_iso_8601": "2024-12-13T11:08:24.802008Z",
"url": "https://files.pythonhosted.org/packages/d9/bc/a4ec1a3fd45190060bc1bf99d8a0bc3a9ea7a50a44496dd17d025b39fdc8/phone_gen-3.0.10-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "ad3dfb6dd1b08921e08f2b2193831636a7faa30dfd11322b3c1744a2f31dd7cc",
"md5": "42d6c864410e999b7c633e6012722291",
"sha256": "4bc5ed95943c7a84bc028509215b1a05b995f02354fcc6d0ac9adb7ed24d53b3"
},
"downloads": -1,
"filename": "phone_gen-3.0.10.tar.gz",
"has_sig": false,
"md5_digest": "42d6c864410e999b7c633e6012722291",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 40152,
"upload_time": "2024-12-13T11:08:27",
"upload_time_iso_8601": "2024-12-13T11:08:27.585335Z",
"url": "https://files.pythonhosted.org/packages/ad/3d/fb6dd1b08921e08f2b2193831636a7faa30dfd11322b3c1744a2f31dd7cc/phone_gen-3.0.10.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-13 11:08:27",
"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"
}