Skip to main content

International phone number generation

Project description

Phone Gen

PyPI PyPI - Python Version PyPI - Implementation Downloads Build Status codecov

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

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

  • 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

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

If you're not sure about the file name format, learn more about wheel file names.

phone_gen-1.3.8-py2.py3-none-any.whl (28.6 kB view details)

Uploaded Python 2Python 3

File details

Details for the file phone_gen-1.3.8-py2.py3-none-any.whl.

File metadata

  • Download URL: phone_gen-1.3.8-py2.py3-none-any.whl
  • Upload date:
  • Size: 28.6 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.1

File hashes

Hashes for phone_gen-1.3.8-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 8c922ad9c3dc81b37e7f149b2a21cb81d47cdb35f4a499bd567e16717323cf12
MD5 bb2d74e0c16e6cb5414cd6b713e77f4f
BLAKE2b-256 47b8100626eaba4b5adfe8da7846b4cf32f333eff36bb5d9f4151443f28ab98b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page