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
Changelog
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+
- Clone the repository
git clone https://github.com/tolstislon/phone-gen.git cd phone-gen
- Install dev dependencies
pipenv install --dev pipenv shell
- Run ruff format
pipenv run format
- Run ruff check
pipenv run check
- Run the tests
pipenv run tests
Metadata
Release files for phone-gen 3.0.34
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| phone_gen-3.0.34.tar.gz | 41.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| phone_gen-3.0.34-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 75.0 kB
Release files / phone_gen-3.0.34.tar.gz
| Download URL | phone_gen-3.0.34.tar.gz |
|---|---|
| Size | 41.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b6e37d8e7af371bd20fd093259d29028f71b3f860827bb483f6456ad24035960
|
|
BLAKE2b-256 checksum How to use checksums |
71f1797b502fa00e3926943cbdb41fbcf0b2251aa119f2dffc609c08f388999b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Release files / phone_gen-3.0.34-py3-none-any.whl
| Download URL | phone_gen-3.0.34-py3-none-any.whl |
|---|---|
| Size | 33.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cd6a53d3e694348914dfc8fc98eef5450ead82bbd7eefac0abbf95c39e6fe0ad
|
|
BLAKE2b-256 checksum How to use checksums |
b707a612020c15c3847a24f32c91c10ea2115bb4af6db21635c0a9b4bcc02281
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|