Metadata-Version: 2.1
Name: phone-gen
Version: 2.1.2
Summary: International phone number generation
Home-page: https://github.com/tolstislon/phone-gen
Author: tolstislon
Author-email: tolstislon@gmail.com
License: MIT License
Keywords: testing,test-data,phone-number,phone
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Software Development :: Testing
Classifier: Topic :: Communications :: Telephony
Requires-Python: >=3.5
Description-Content-Type: text/markdown

# Phone Gen

[![PyPI](https://img.shields.io/pypi/v/phone-gen?color=%2301a001&label=pypi&logo=version)](https://pypi.org/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://pypi.org/project/phone-gen/)
[![Downloads](https://pepy.tech/badge/phone-gen)](https://pepy.tech/project/phone-gen)

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

Contributing
----
Contributions are very welcome.

##### How to build a version with libphonenumber below v8.12.3

Need Python 3.6 or more.

1. `git pull https://github.com/tolstislon/phone-gen.git`
2. `cd phone-gen`
3. `pip install requests`
4. `python dev_tools/patterns_generator.py -t {Desired Tag}`
5. `python setup.py install`


# Changelog

## Version 2:

* **2.1.2** Updating patterns to libphonenumber v8.12.34
* **2.1.1** Updating patterns to libphonenumber v8.12.33
* **2.1.0** 
  * Python 3.10 supported
  * Added github actions
  * Updating patterns to libphonenumber v8.12.32
* **2.0.14** Updating patterns to libphonenumber v8.12.31
* **2.0.13** Updating patterns to libphonenumber v8.12.30
* **2.0.12** Updating patterns to libphonenumber v8.12.29
* **2.0.11** Updating patterns to libphonenumber v8.12.28
* **2.0.10** Updating patterns to libphonenumber v8.12.27
* **2.0.9** Updating patterns to libphonenumber v8.12.26
* **2.0.8** Updating patterns to libphonenumber v8.12.25
* **2.0.7** Updating patterns to libphonenumber v8.12.24
* **2.0.6** Updating patterns to libphonenumber v8.12.23
* **2.0.5** Updating patterns to libphonenumber v8.12.22
* **2.0.4** Updating patterns to libphonenumber v8.12.21
* **2.0.3** Updating patterns to libphonenumber v8.12.20
* **2.0.2** Updating patterns to libphonenumber v8.12.19
* **2.0.1** Updating patterns to libphonenumber v8.12.18
* **2.0.0**
    * Added support for mobile phone numbers
    * Added separate calls to get mobile phone number and national phone number

## Version 1:

* **1.4.0** Added load_alt_patters function
* **1.3.14** Updating patterns to libphonenumber v8.12.17
* **1.3.13** Updating patterns to libphonenumber v8.12.16
* **1.3.12** Updating patterns to libphonenumber v8.12.15
* **1.3.11** Updating patterns to libphonenumber v8.12.14
* **1.3.10** Updating patterns to libphonenumber v8.12.13
* **1.3.9** Updating patterns to libphonenumber v8.12.12
* **1.3.8** Updating patterns to libphonenumber v8.12.11
* **1.3.7** Updating patterns to libphonenumber v8.12.10
* **1.3.6** Updating patterns to libphonenumber v8.12.9
* **1.3.5** Updating patterns to libphonenumber v8.12.8
* **1.3.4** Updating patterns to libphonenumber v8.12.7
* **1.3.3** Updating patterns to libphonenumber v8.12.6
* **1.3.2** Fix `MI` invalid pattern
* **1.3.1** Updating patterns to libphonenumber v8.12.5
* **1.3.0** Added the ability to build a module with old versions of libphonenumber
* **1.2.0** Added phone number generation by `country name` and `ISO 3166-3`
* **1.1.1** Updating patterns to libphonenumber v8.12.4
* **1.1.0** Added cli
* **1.0.0** The first stable release

