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
# 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
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 "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
# 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
- Modified strgen library
Changelog
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
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
phone_gen-2.2.6-py3-none-any.whl
(34.5 kB
view hashes)
Close
Hashes for phone_gen-2.2.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7e8e803f8edfd3d9d1321f3517f19333705db31767f9ed6210c83e7b4edb2792 |
|
MD5 | 8d3b0046399b267229a8d2db8efe3c74 |
|
BLAKE2b-256 | 17e4afa370e5240220a580d3e995db801742ed14c93d1aa7adc1d416c77bb13d |