International phone number generation
Project description
Phone Gen
International phone number generation
This module was created exclusively for generating test data
Installation
Install using pip with
pip install phone-gen
Example
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
pytest fixture
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
usage: phone-gen [-h] [-v] [-n] country [country ...]
International phone number generation
positional arguments:
country Country code or country name. Example: "GB" or "Great Britain"
optional arguments:
-h, --help show this help message and exit
-v, --version show program's version number and exit
-n, --not-full Get a phone number without a country code
Example
# 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 DE -n
66999511
$ phone-gen Germany -n
877595
Resources
- Google's libphonenumber
- Modified strgen library
Contributing
Contributions are very welcome.
How to build a version with libphonenumber below v8.12.3
Need Python 3.6 or more.
git pull https://github.com/tolstislon/phone-gen.git
cd phone-gen
pip install requests
python dev_tools/patterns_generator.py -t {Desired Tag}
python setup.py install
Changelog
- 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
andISO 3166-3
- 1.1.1 Updating patterns to libphonenumber v8.12.4
- 1.1.0 Added cli
- 1.0.0 The first stable release
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 Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for phone_gen-1.3.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6ba695c0f25e5b767199361d3e7aaa1d257a1d84690e2c25bf2f17e7f6dcebd1 |
|
MD5 | 6dd884f9dcf0d3500ab0c07ee2c1b6cc |
|
BLAKE2b-256 | b1e6f53d7be8fddc7f9dfcad2613513d6b4afa3f49c0378ec0e75d1c5f7f7f40 |